1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <gtest/gtest.h>
18
19 #include <BakedOpRenderer.h>
20 #include <tests/common/TestUtils.h>
21
22 using namespace android::uirenderer;
23
24 const BakedOpRenderer::LightInfo sLightInfo = { 128, 128 };
25
RENDERTHREAD_TEST(BakedOpRenderer,startRepaintLayer_clear)26 RENDERTHREAD_TEST(BakedOpRenderer, startRepaintLayer_clear) {
27 BakedOpRenderer renderer(Caches::getInstance(), renderThread.renderState(), true, sLightInfo);
28 OffscreenBuffer layer(renderThread.renderState(), Caches::getInstance(), 200u, 200u);
29
30 layer.dirty(Rect(200, 200));
31 {
32 renderer.startRepaintLayer(&layer, Rect(200, 200));
33 EXPECT_TRUE(layer.region.isEmpty()) << "Repaint full layer should clear region";
34 renderer.endLayer();
35 }
36
37 layer.dirty(Rect(200, 200));
38 {
39 renderer.startRepaintLayer(&layer, Rect(100, 200)); // repainting left side
40 EXPECT_TRUE(layer.region.isRect());
41 //ALOGD("bounds %d %d %d %d", RECT_ARGS(layer.region.getBounds()));
42 EXPECT_EQ(android::Rect(100, 0, 200, 200), layer.region.getBounds())
43 << "Left side being repainted, so right side should be clear";
44 renderer.endLayer();
45 }
46
47 // right side is now only dirty portion
48 {
49 renderer.startRepaintLayer(&layer, Rect(100, 0, 200, 200)); // repainting right side
50 EXPECT_TRUE(layer.region.isEmpty())
51 << "Now right side being repainted, so region should be entirely clear";
52 renderer.endLayer();
53 }
54 }
55