OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <map> | 5 #include <map> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
10 #include "cc/test/fake_rendering_stats_instrumentation.h" | 10 #include "cc/test/fake_rendering_stats_instrumentation.h" |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 | 1227 |
1228 // No invalidation when shrinking. | 1228 // No invalidation when shrinking. |
1229 EXPECT_EQ(Region().ToString(), invalidation.ToString()); | 1229 EXPECT_EQ(Region().ToString(), invalidation.ToString()); |
1230 invalidation.Clear(); | 1230 invalidation.Clear(); |
1231 } | 1231 } |
1232 | 1232 |
1233 TEST_F(PicturePileTest, SolidRectangleIsSolid) { | 1233 TEST_F(PicturePileTest, SolidRectangleIsSolid) { |
1234 // If the client has no contents, the solid state will be true. | 1234 // If the client has no contents, the solid state will be true. |
1235 Region invalidation1(tiling_rect()); | 1235 Region invalidation1(tiling_rect()); |
1236 UpdateAndExpandInvalidation(&invalidation1, tiling_size(), tiling_rect()); | 1236 UpdateAndExpandInvalidation(&invalidation1, tiling_size(), tiling_rect()); |
1237 EXPECT_TRUE(pile_->IsSolidColor()); | 1237 EXPECT_TRUE(pile_->is_solid_color()); |
1238 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), pile_->GetSolidColor()); | 1238 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), pile_->solid_color()); |
1239 | 1239 |
1240 // If there is a single rect that covers the view, the solid | 1240 // If there is a single rect that covers the view, the solid |
1241 // state will be true. | 1241 // state will be true. |
1242 SkPaint paint; | 1242 SkPaint paint; |
1243 paint.setColor(SK_ColorCYAN); | 1243 paint.setColor(SK_ColorCYAN); |
1244 client_.add_draw_rect(tiling_rect(), paint); | 1244 client_.add_draw_rect(tiling_rect(), paint); |
1245 Region invalidation2(tiling_rect()); | 1245 Region invalidation2(tiling_rect()); |
1246 UpdateAndExpandInvalidation(&invalidation2, tiling_size(), tiling_rect()); | 1246 UpdateAndExpandInvalidation(&invalidation2, tiling_size(), tiling_rect()); |
1247 EXPECT_TRUE(pile_->IsSolidColor()); | 1247 EXPECT_TRUE(pile_->is_solid_color()); |
1248 EXPECT_EQ(SK_ColorCYAN, pile_->GetSolidColor()); | 1248 EXPECT_EQ(SK_ColorCYAN, pile_->solid_color()); |
1249 | 1249 |
1250 // If a second smaller rect is draw that doesn't cover the viewport | 1250 // If a second smaller rect is draw that doesn't cover the viewport |
1251 // completely, the solid state will be false. | 1251 // completely, the solid state will be false. |
1252 gfx::Rect smallRect = tiling_rect(); | 1252 gfx::Rect smallRect = tiling_rect(); |
1253 smallRect.Inset(10, 10, 10, 10); | 1253 smallRect.Inset(10, 10, 10, 10); |
1254 client_.add_draw_rect(smallRect, paint); | 1254 client_.add_draw_rect(smallRect, paint); |
1255 Region invalidation3(tiling_rect()); | 1255 Region invalidation3(tiling_rect()); |
1256 UpdateAndExpandInvalidation(&invalidation3, tiling_size(), tiling_rect()); | 1256 UpdateAndExpandInvalidation(&invalidation3, tiling_size(), tiling_rect()); |
1257 EXPECT_FALSE(pile_->IsSolidColor()); | 1257 EXPECT_FALSE(pile_->is_solid_color()); |
1258 | 1258 |
1259 // If a third rect is drawn over everything, we should be solid again. | 1259 // If a third rect is drawn over everything, we should be solid again. |
1260 paint.setColor(SK_ColorRED); | 1260 paint.setColor(SK_ColorRED); |
1261 client_.add_draw_rect(tiling_rect(), paint); | 1261 client_.add_draw_rect(tiling_rect(), paint); |
1262 Region invalidation4(tiling_rect()); | 1262 Region invalidation4(tiling_rect()); |
1263 UpdateAndExpandInvalidation(&invalidation4, tiling_size(), tiling_rect()); | 1263 UpdateAndExpandInvalidation(&invalidation4, tiling_size(), tiling_rect()); |
1264 EXPECT_TRUE(pile_->IsSolidColor()); | 1264 EXPECT_TRUE(pile_->is_solid_color()); |
1265 EXPECT_EQ(SK_ColorRED, pile_->GetSolidColor()); | 1265 EXPECT_EQ(SK_ColorRED, pile_->solid_color()); |
1266 | 1266 |
1267 // If we draw too many, we don't bother doing the analysis and we should no | 1267 // If we draw too many, we don't bother doing the analysis and we should no |
1268 // longer be in a solid state. There are 8 rects, two clips and a translate. | 1268 // longer be in a solid state. There are 8 rects, two clips and a translate. |
1269 client_.add_draw_rect(tiling_rect(), paint); | 1269 client_.add_draw_rect(tiling_rect(), paint); |
1270 client_.add_draw_rect(tiling_rect(), paint); | 1270 client_.add_draw_rect(tiling_rect(), paint); |
1271 client_.add_draw_rect(tiling_rect(), paint); | 1271 client_.add_draw_rect(tiling_rect(), paint); |
1272 client_.add_draw_rect(tiling_rect(), paint); | 1272 client_.add_draw_rect(tiling_rect(), paint); |
1273 client_.add_draw_rect(tiling_rect(), paint); | 1273 client_.add_draw_rect(tiling_rect(), paint); |
1274 Region invalidation5(tiling_rect()); | 1274 Region invalidation5(tiling_rect()); |
1275 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); | 1275 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); |
1276 EXPECT_FALSE(pile_->IsSolidColor()); | 1276 EXPECT_FALSE(pile_->is_solid_color()); |
1277 } | 1277 } |
1278 | 1278 |
1279 } // namespace | 1279 } // namespace |
1280 } // namespace cc | 1280 } // namespace cc |
OLD | NEW |