| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "cc/test/fake_picture_pile_impl.h" | 6 #include "cc/test/fake_picture_pile_impl.h" |
| 7 #include "cc/test/skia_common.h" | 7 #include "cc/test/skia_common.h" |
| 8 #include "skia/ext/refptr.h" | 8 #include "skia/ext/refptr.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkPixelRef.h" | 10 #include "third_party/skia/include/core/SkPixelRef.h" |
| 11 #include "third_party/skia/include/core/SkShader.h" | 11 #include "third_party/skia/include/core/SkShader.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) { | 18 TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) { |
| 19 gfx::Size tile_size(100, 100); | 19 gfx::Size tile_size(100, 100); |
| 20 gfx::Size layer_bounds(400, 400); | 20 gfx::Size layer_bounds(400, 400); |
| 21 | 21 |
| 22 scoped_refptr<FakePicturePileImpl> pile = | 22 scoped_ptr<FakePicturePile> recording_source = |
| 23 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 23 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 24 | 24 |
| 25 SkPaint solid_paint; |
| 25 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 26 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 26 SkPaint solid_paint; | |
| 27 solid_paint.setColor(solid_color); | 27 solid_paint.setColor(solid_color); |
| 28 | 28 |
| 29 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | 29 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
| 30 SkPaint non_solid_paint; | 30 SkPaint non_solid_paint; |
| 31 non_solid_paint.setColor(non_solid_color); | 31 non_solid_paint.setColor(non_solid_color); |
| 32 | 32 |
| 33 pile->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), solid_paint); | 33 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), |
| 34 pile->RerecordPile(); | 34 solid_paint); |
| 35 recording_source->RerecordPile(); |
| 35 | 36 |
| 36 // Ensure everything is solid | 37 scoped_refptr<FakePicturePileImpl> pile = |
| 38 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 39 |
| 40 // Ensure everything is solid. |
| 37 for (int y = 0; y <= 300; y += 100) { | 41 for (int y = 0; y <= 300; y += 100) { |
| 38 for (int x = 0; x <= 300; x += 100) { | 42 for (int x = 0; x <= 300; x += 100) { |
| 39 RasterSource::SolidColorAnalysis analysis; | 43 RasterSource::SolidColorAnalysis analysis; |
| 40 gfx::Rect rect(x, y, 100, 100); | 44 gfx::Rect rect(x, y, 100, 100); |
| 41 pile->PerformSolidColorAnalysis(rect, 1.0, &analysis); | 45 pile->PerformSolidColorAnalysis(rect, 1.0, &analysis); |
| 42 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString(); | 46 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString(); |
| 43 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString(); | 47 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString(); |
| 44 } | 48 } |
| 45 } | 49 } |
| 46 | 50 |
| 47 // One pixel non solid | 51 // Add one non-solid pixel and recreate the raster source. |
| 48 pile->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), non_solid_paint); | 52 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), |
| 49 pile->RerecordPile(); | 53 non_solid_paint); |
| 54 recording_source->RerecordPile(); |
| 55 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 50 | 56 |
| 51 RasterSource::SolidColorAnalysis analysis; | 57 RasterSource::SolidColorAnalysis analysis; |
| 52 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.0, &analysis); | 58 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.0, &analysis); |
| 53 EXPECT_FALSE(analysis.is_solid_color); | 59 EXPECT_FALSE(analysis.is_solid_color); |
| 54 | 60 |
| 55 pile->PerformSolidColorAnalysis(gfx::Rect(100, 0, 100, 100), 1.0, &analysis); | 61 pile->PerformSolidColorAnalysis(gfx::Rect(100, 0, 100, 100), 1.0, &analysis); |
| 56 EXPECT_TRUE(analysis.is_solid_color); | 62 EXPECT_TRUE(analysis.is_solid_color); |
| 57 EXPECT_EQ(analysis.solid_color, solid_color); | 63 EXPECT_EQ(analysis.solid_color, solid_color); |
| 58 | 64 |
| 59 // Boundaries should be clipped | 65 // Boundaries should be clipped. |
| 60 analysis.is_solid_color = false; | 66 analysis.is_solid_color = false; |
| 61 pile->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), 1.0, &analysis); | 67 pile->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), 1.0, &analysis); |
| 62 EXPECT_TRUE(analysis.is_solid_color); | 68 EXPECT_TRUE(analysis.is_solid_color); |
| 63 EXPECT_EQ(analysis.solid_color, solid_color); | 69 EXPECT_EQ(analysis.solid_color, solid_color); |
| 64 | 70 |
| 65 analysis.is_solid_color = false; | 71 analysis.is_solid_color = false; |
| 66 pile->PerformSolidColorAnalysis(gfx::Rect(0, 350, 100, 100), 1.0, &analysis); | 72 pile->PerformSolidColorAnalysis(gfx::Rect(0, 350, 100, 100), 1.0, &analysis); |
| 67 EXPECT_TRUE(analysis.is_solid_color); | 73 EXPECT_TRUE(analysis.is_solid_color); |
| 68 EXPECT_EQ(analysis.solid_color, solid_color); | 74 EXPECT_EQ(analysis.solid_color, solid_color); |
| 69 | 75 |
| 70 analysis.is_solid_color = false; | 76 analysis.is_solid_color = false; |
| 71 pile->PerformSolidColorAnalysis(gfx::Rect(350, 350, 100, 100), 1.0, | 77 pile->PerformSolidColorAnalysis(gfx::Rect(350, 350, 100, 100), 1.0, |
| 72 &analysis); | 78 &analysis); |
| 73 EXPECT_TRUE(analysis.is_solid_color); | 79 EXPECT_TRUE(analysis.is_solid_color); |
| 74 EXPECT_EQ(analysis.solid_color, solid_color); | 80 EXPECT_EQ(analysis.solid_color, solid_color); |
| 75 } | 81 } |
| 76 | 82 |
| 77 TEST(PicturePileImplTest, AnalyzeIsSolidScaled) { | 83 TEST(PicturePileImplTest, AnalyzeIsSolidScaled) { |
| 78 gfx::Size tile_size(100, 100); | 84 gfx::Size tile_size(100, 100); |
| 79 gfx::Size layer_bounds(400, 400); | 85 gfx::Size layer_bounds(400, 400); |
| 80 | 86 |
| 81 scoped_refptr<FakePicturePileImpl> pile = | 87 scoped_ptr<FakePicturePile> recording_source = |
| 82 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 88 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 83 | 89 |
| 84 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 90 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 85 SkPaint solid_paint; | 91 SkPaint solid_paint; |
| 86 solid_paint.setColor(solid_color); | 92 solid_paint.setColor(solid_color); |
| 87 | 93 |
| 88 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | 94 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
| 89 SkPaint non_solid_paint; | 95 SkPaint non_solid_paint; |
| 90 non_solid_paint.setColor(non_solid_color); | 96 non_solid_paint.setColor(non_solid_color); |
| 91 | 97 |
| 92 pile->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), solid_paint); | 98 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), |
| 93 pile->RerecordPile(); | 99 solid_paint); |
| 100 recording_source->RerecordPile(); |
| 94 | 101 |
| 95 // Ensure everything is solid | 102 scoped_refptr<FakePicturePileImpl> pile = |
| 103 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 104 |
| 105 // Ensure everything is solid. |
| 96 for (int y = 0; y <= 30; y += 10) { | 106 for (int y = 0; y <= 30; y += 10) { |
| 97 for (int x = 0; x <= 30; x += 10) { | 107 for (int x = 0; x <= 30; x += 10) { |
| 98 RasterSource::SolidColorAnalysis analysis; | 108 RasterSource::SolidColorAnalysis analysis; |
| 99 gfx::Rect rect(x, y, 10, 10); | 109 gfx::Rect rect(x, y, 10, 10); |
| 100 pile->PerformSolidColorAnalysis(rect, 0.1f, &analysis); | 110 pile->PerformSolidColorAnalysis(rect, 0.1f, &analysis); |
| 101 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString(); | 111 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString(); |
| 102 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString(); | 112 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString(); |
| 103 } | 113 } |
| 104 } | 114 } |
| 105 | 115 |
| 106 // One pixel non solid | 116 // Add one non-solid pixel and recreate the raster source. |
| 107 pile->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), non_solid_paint); | 117 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), |
| 108 pile->RerecordPile(); | 118 non_solid_paint); |
| 119 recording_source->RerecordPile(); |
| 120 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 109 | 121 |
| 110 RasterSource::SolidColorAnalysis analysis; | 122 RasterSource::SolidColorAnalysis analysis; |
| 111 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &analysis); | 123 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &analysis); |
| 112 EXPECT_FALSE(analysis.is_solid_color); | 124 EXPECT_FALSE(analysis.is_solid_color); |
| 113 | 125 |
| 114 pile->PerformSolidColorAnalysis(gfx::Rect(10, 0, 10, 10), 0.1f, &analysis); | 126 pile->PerformSolidColorAnalysis(gfx::Rect(10, 0, 10, 10), 0.1f, &analysis); |
| 115 EXPECT_TRUE(analysis.is_solid_color); | 127 EXPECT_TRUE(analysis.is_solid_color); |
| 116 EXPECT_EQ(analysis.solid_color, solid_color); | 128 EXPECT_EQ(analysis.solid_color, solid_color); |
| 117 | 129 |
| 118 // Boundaries should be clipped | 130 // Boundaries should be clipped. |
| 119 analysis.is_solid_color = false; | 131 analysis.is_solid_color = false; |
| 120 pile->PerformSolidColorAnalysis(gfx::Rect(35, 0, 10, 10), 0.1f, &analysis); | 132 pile->PerformSolidColorAnalysis(gfx::Rect(35, 0, 10, 10), 0.1f, &analysis); |
| 121 EXPECT_TRUE(analysis.is_solid_color); | 133 EXPECT_TRUE(analysis.is_solid_color); |
| 122 EXPECT_EQ(analysis.solid_color, solid_color); | 134 EXPECT_EQ(analysis.solid_color, solid_color); |
| 123 | 135 |
| 124 analysis.is_solid_color = false; | 136 analysis.is_solid_color = false; |
| 125 pile->PerformSolidColorAnalysis(gfx::Rect(0, 35, 10, 10), 0.1f, &analysis); | 137 pile->PerformSolidColorAnalysis(gfx::Rect(0, 35, 10, 10), 0.1f, &analysis); |
| 126 EXPECT_TRUE(analysis.is_solid_color); | 138 EXPECT_TRUE(analysis.is_solid_color); |
| 127 EXPECT_EQ(analysis.solid_color, solid_color); | 139 EXPECT_EQ(analysis.solid_color, solid_color); |
| 128 | 140 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 PicturePileImpl::PixelRefIterator iterator( | 214 PicturePileImpl::PixelRefIterator iterator( |
| 203 gfx::Rect(0, 0, 128, 128), 0.5, pile.get()); | 215 gfx::Rect(0, 0, 128, 128), 0.5, pile.get()); |
| 204 EXPECT_FALSE(iterator); | 216 EXPECT_FALSE(iterator); |
| 205 } | 217 } |
| 206 } | 218 } |
| 207 | 219 |
| 208 TEST(PicturePileImplTest, PixelRefIteratorNoDiscardableRefs) { | 220 TEST(PicturePileImplTest, PixelRefIteratorNoDiscardableRefs) { |
| 209 gfx::Size tile_size(128, 128); | 221 gfx::Size tile_size(128, 128); |
| 210 gfx::Size layer_bounds(256, 256); | 222 gfx::Size layer_bounds(256, 256); |
| 211 | 223 |
| 212 scoped_refptr<FakePicturePileImpl> pile = | 224 scoped_ptr<FakePicturePile> recording_source = |
| 213 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 225 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 214 | |
| 215 SkPaint simple_paint; | 226 SkPaint simple_paint; |
| 216 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); | 227 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); |
| 217 | 228 |
| 218 SkBitmap non_discardable_bitmap; | 229 SkBitmap non_discardable_bitmap; |
| 219 CreateBitmap(gfx::Size(128, 128), "notdiscardable", &non_discardable_bitmap); | 230 CreateBitmap(gfx::Size(128, 128), "notdiscardable", &non_discardable_bitmap); |
| 220 | 231 |
| 221 pile->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), simple_paint); | 232 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), |
| 222 pile->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512), simple_paint); | 233 simple_paint); |
| 223 pile->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256), simple_paint); | 234 recording_source->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512), |
| 224 pile->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256), simple_paint); | 235 simple_paint); |
| 225 pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0)); | 236 recording_source->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256), |
| 226 pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 128)); | 237 simple_paint); |
| 227 pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(150, 150)); | 238 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256), |
| 239 simple_paint); |
| 240 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0)); |
| 241 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 128)); |
| 242 recording_source->add_draw_bitmap(non_discardable_bitmap, |
| 243 gfx::Point(150, 150)); |
| 244 recording_source->RerecordPile(); |
| 228 | 245 |
| 229 pile->RerecordPile(); | 246 scoped_refptr<FakePicturePileImpl> pile = |
| 247 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 230 | 248 |
| 231 // Tile sized iterators. | 249 // Tile sized iterators. |
| 232 { | 250 { |
| 233 PicturePileImpl::PixelRefIterator iterator( | 251 PicturePileImpl::PixelRefIterator iterator( |
| 234 gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); | 252 gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); |
| 235 EXPECT_FALSE(iterator); | 253 EXPECT_FALSE(iterator); |
| 236 } | 254 } |
| 237 { | 255 { |
| 238 PicturePileImpl::PixelRefIterator iterator( | 256 PicturePileImpl::PixelRefIterator iterator( |
| 239 gfx::Rect(0, 0, 256, 256), 2.0, pile.get()); | 257 gfx::Rect(0, 0, 256, 256), 2.0, pile.get()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 PicturePileImpl::PixelRefIterator iterator( | 293 PicturePileImpl::PixelRefIterator iterator( |
| 276 gfx::Rect(0, 0, 128, 128), 0.5, pile.get()); | 294 gfx::Rect(0, 0, 128, 128), 0.5, pile.get()); |
| 277 EXPECT_FALSE(iterator); | 295 EXPECT_FALSE(iterator); |
| 278 } | 296 } |
| 279 } | 297 } |
| 280 | 298 |
| 281 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefs) { | 299 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefs) { |
| 282 gfx::Size tile_size(128, 128); | 300 gfx::Size tile_size(128, 128); |
| 283 gfx::Size layer_bounds(256, 256); | 301 gfx::Size layer_bounds(256, 256); |
| 284 | 302 |
| 285 scoped_refptr<FakePicturePileImpl> pile = | 303 scoped_ptr<FakePicturePile> recording_source = |
| 286 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 304 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 287 | 305 |
| 288 SkBitmap discardable_bitmap[2][2]; | 306 SkBitmap discardable_bitmap[2][2]; |
| 289 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]); | 307 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]); |
| 290 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][0]); | 308 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][0]); |
| 291 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]); | 309 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]); |
| 292 | 310 |
| 293 // Discardable pixel refs are found in the following cells: | 311 // Discardable pixel refs are found in the following cells: |
| 294 // |---|---| | 312 // |---|---| |
| 295 // | x | | | 313 // | x | | |
| 296 // |---|---| | 314 // |---|---| |
| 297 // | x | x | | 315 // | x | x | |
| 298 // |---|---| | 316 // |---|---| |
| 299 pile->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); | 317 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); |
| 300 pile->add_draw_bitmap(discardable_bitmap[1][0], gfx::Point(0, 130)); | 318 recording_source->add_draw_bitmap(discardable_bitmap[1][0], |
| 301 pile->add_draw_bitmap(discardable_bitmap[1][1], gfx::Point(140, 140)); | 319 gfx::Point(0, 130)); |
| 320 recording_source->add_draw_bitmap(discardable_bitmap[1][1], |
| 321 gfx::Point(140, 140)); |
| 322 recording_source->RerecordPile(); |
| 302 | 323 |
| 303 pile->RerecordPile(); | 324 scoped_refptr<FakePicturePileImpl> pile = |
| 325 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 304 | 326 |
| 305 // Tile sized iterators. These should find only one pixel ref. | 327 // Tile sized iterators. These should find only one pixel ref. |
| 306 { | 328 { |
| 307 PicturePileImpl::PixelRefIterator iterator( | 329 PicturePileImpl::PixelRefIterator iterator( |
| 308 gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); | 330 gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); |
| 309 EXPECT_TRUE(iterator); | 331 EXPECT_TRUE(iterator); |
| 310 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); | 332 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); |
| 311 EXPECT_FALSE(++iterator); | 333 EXPECT_FALSE(++iterator); |
| 312 } | 334 } |
| 313 { | 335 { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 EXPECT_TRUE(++iterator); | 407 EXPECT_TRUE(++iterator); |
| 386 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); | 408 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); |
| 387 EXPECT_FALSE(++iterator); | 409 EXPECT_FALSE(++iterator); |
| 388 } | 410 } |
| 389 } | 411 } |
| 390 | 412 |
| 391 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) { | 413 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) { |
| 392 gfx::Size tile_size(256, 256); | 414 gfx::Size tile_size(256, 256); |
| 393 gfx::Size layer_bounds(512, 512); | 415 gfx::Size layer_bounds(512, 512); |
| 394 | 416 |
| 395 scoped_refptr<FakePicturePileImpl> pile = | 417 scoped_ptr<FakePicturePile> recording_source = |
| 396 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 418 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 397 | 419 |
| 398 SkBitmap discardable_bitmap[2][2]; | 420 SkBitmap discardable_bitmap[2][2]; |
| 399 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]); | 421 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]); |
| 400 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][1]); | 422 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][1]); |
| 401 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]); | 423 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]); |
| 402 | 424 |
| 403 // Discardable pixel refs are found in the following cells: | 425 // Discardable pixel refs are found in the following cells: |
| 404 // |---|---| | 426 // |---|---| |
| 405 // | x | x | | 427 // | x | x | |
| 406 // |---|---| | 428 // |---|---| |
| 407 // | | x | | 429 // | | x | |
| 408 // |---|---| | 430 // |---|---| |
| 409 pile->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); | 431 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); |
| 410 pile->add_draw_bitmap(discardable_bitmap[0][1], gfx::Point(260, 0)); | 432 recording_source->add_draw_bitmap(discardable_bitmap[0][1], |
| 411 pile->add_draw_bitmap(discardable_bitmap[1][1], gfx::Point(260, 260)); | 433 gfx::Point(260, 0)); |
| 434 recording_source->add_draw_bitmap(discardable_bitmap[1][1], |
| 435 gfx::Point(260, 260)); |
| 436 recording_source->RerecordPile(); |
| 412 | 437 |
| 413 pile->RerecordPile(); | 438 scoped_refptr<FakePicturePileImpl> pile = |
| 439 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 414 | 440 |
| 415 // Tile sized iterators. These should find only one pixel ref. | 441 // Tile sized iterators. These should find only one pixel ref. |
| 416 { | 442 { |
| 417 PicturePileImpl::PixelRefIterator iterator( | 443 PicturePileImpl::PixelRefIterator iterator( |
| 418 gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); | 444 gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); |
| 419 EXPECT_TRUE(iterator); | 445 EXPECT_TRUE(iterator); |
| 420 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); | 446 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); |
| 421 EXPECT_FALSE(++iterator); | 447 EXPECT_FALSE(++iterator); |
| 422 } | 448 } |
| 423 { | 449 { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 EXPECT_TRUE(*copy == discardable_bitmap[0][1].pixelRef()); | 542 EXPECT_TRUE(*copy == discardable_bitmap[0][1].pixelRef()); |
| 517 EXPECT_TRUE(++copy); | 543 EXPECT_TRUE(++copy); |
| 518 EXPECT_TRUE(*copy == discardable_bitmap[1][1].pixelRef()); | 544 EXPECT_TRUE(*copy == discardable_bitmap[1][1].pixelRef()); |
| 519 EXPECT_FALSE(++copy); | 545 EXPECT_FALSE(++copy); |
| 520 } | 546 } |
| 521 | 547 |
| 522 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsBaseNonDiscardable) { | 548 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsBaseNonDiscardable) { |
| 523 gfx::Size tile_size(256, 256); | 549 gfx::Size tile_size(256, 256); |
| 524 gfx::Size layer_bounds(512, 512); | 550 gfx::Size layer_bounds(512, 512); |
| 525 | 551 |
| 526 scoped_refptr<FakePicturePileImpl> pile = | 552 scoped_ptr<FakePicturePile> recording_source = |
| 527 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 553 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 528 | 554 |
| 529 SkBitmap non_discardable_bitmap; | 555 SkBitmap non_discardable_bitmap; |
| 530 CreateBitmap(gfx::Size(512, 512), "notdiscardable", &non_discardable_bitmap); | 556 CreateBitmap(gfx::Size(512, 512), "notdiscardable", &non_discardable_bitmap); |
| 531 | 557 |
| 532 SkBitmap discardable_bitmap[2][2]; | 558 SkBitmap discardable_bitmap[2][2]; |
| 533 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][0]); | 559 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][0]); |
| 534 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][1]); | 560 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][1]); |
| 535 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[1][1]); | 561 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[1][1]); |
| 536 | 562 |
| 537 // One large non-discardable bitmap covers the whole grid. | 563 // One large non-discardable bitmap covers the whole grid. |
| 538 // Discardable pixel refs are found in the following cells: | 564 // Discardable pixel refs are found in the following cells: |
| 539 // |---|---| | 565 // |---|---| |
| 540 // | x | x | | 566 // | x | x | |
| 541 // |---|---| | 567 // |---|---| |
| 542 // | | x | | 568 // | | x | |
| 543 // |---|---| | 569 // |---|---| |
| 544 pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0)); | 570 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0)); |
| 545 pile->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); | 571 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); |
| 546 pile->add_draw_bitmap(discardable_bitmap[0][1], gfx::Point(260, 0)); | 572 recording_source->add_draw_bitmap(discardable_bitmap[0][1], |
| 547 pile->add_draw_bitmap(discardable_bitmap[1][1], gfx::Point(260, 260)); | 573 gfx::Point(260, 0)); |
| 574 recording_source->add_draw_bitmap(discardable_bitmap[1][1], |
| 575 gfx::Point(260, 260)); |
| 576 recording_source->RerecordPile(); |
| 548 | 577 |
| 549 pile->RerecordPile(); | 578 scoped_refptr<FakePicturePileImpl> pile = |
| 579 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 550 | 580 |
| 551 // Tile sized iterators. These should find only one pixel ref. | 581 // Tile sized iterators. These should find only one pixel ref. |
| 552 { | 582 { |
| 553 PicturePileImpl::PixelRefIterator iterator( | 583 PicturePileImpl::PixelRefIterator iterator( |
| 554 gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); | 584 gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); |
| 555 EXPECT_TRUE(iterator); | 585 EXPECT_TRUE(iterator); |
| 556 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); | 586 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); |
| 557 EXPECT_FALSE(++iterator); | 587 EXPECT_FALSE(++iterator); |
| 558 } | 588 } |
| 559 { | 589 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 EXPECT_FALSE(++iterator); | 663 EXPECT_FALSE(++iterator); |
| 634 } | 664 } |
| 635 } | 665 } |
| 636 | 666 |
| 637 TEST(PicturePileImplTest, RasterFullContents) { | 667 TEST(PicturePileImplTest, RasterFullContents) { |
| 638 gfx::Size tile_size(1000, 1000); | 668 gfx::Size tile_size(1000, 1000); |
| 639 gfx::Size layer_bounds(3, 5); | 669 gfx::Size layer_bounds(3, 5); |
| 640 float contents_scale = 1.5f; | 670 float contents_scale = 1.5f; |
| 641 float raster_divisions = 2.f; | 671 float raster_divisions = 2.f; |
| 642 | 672 |
| 643 scoped_refptr<FakePicturePileImpl> pile = | 673 scoped_ptr<FakePicturePile> recording_source = |
| 644 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 674 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 675 recording_source->SetBackgroundColor(SK_ColorBLACK); |
| 676 recording_source->SetIsSolidColor(false); |
| 677 recording_source->SetRequiresClear(false); |
| 678 recording_source->SetClearCanvasWithDebugColor(false); |
| 679 |
| 645 // Because the caller sets content opaque, it also promises that it | 680 // Because the caller sets content opaque, it also promises that it |
| 646 // has at least filled in layer_bounds opaquely. | 681 // has at least filled in layer_bounds opaquely. |
| 647 SkPaint white_paint; | 682 SkPaint white_paint; |
| 648 white_paint.setColor(SK_ColorWHITE); | 683 white_paint.setColor(SK_ColorWHITE); |
| 649 pile->add_draw_rect_with_paint(gfx::Rect(layer_bounds), white_paint); | 684 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), |
| 685 white_paint); |
| 650 | 686 |
| 651 pile->SetMinContentsScale(contents_scale); | 687 recording_source->SetMinContentsScale(contents_scale); |
| 652 pile->set_background_color(SK_ColorBLACK); | 688 recording_source->RerecordPile(); |
| 653 pile->SetRequiresClear(false); | 689 |
| 654 pile->set_clear_canvas_with_debug_color(false); | 690 scoped_refptr<FakePicturePileImpl> pile = |
| 655 pile->RerecordPile(); | 691 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 656 | 692 |
| 657 gfx::Size content_bounds( | 693 gfx::Size content_bounds( |
| 658 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 694 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
| 659 | 695 |
| 660 // Simulate drawing into different tiles at different offsets. | 696 // Simulate drawing into different tiles at different offsets. |
| 661 int step_x = std::ceil(content_bounds.width() / raster_divisions); | 697 int step_x = std::ceil(content_bounds.width() / raster_divisions); |
| 662 int step_y = std::ceil(content_bounds.height() / raster_divisions); | 698 int step_y = std::ceil(content_bounds.height() / raster_divisions); |
| 663 for (int offset_x = 0; offset_x < content_bounds.width(); | 699 for (int offset_x = 0; offset_x < content_bounds.width(); |
| 664 offset_x += step_x) { | 700 offset_x += step_x) { |
| 665 for (int offset_y = 0; offset_y < content_bounds.height(); | 701 for (int offset_y = 0; offset_y < content_bounds.height(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 696 EXPECT_EQ(all_white, gfx::Rect(content_bounds).Contains(canvas_rect)); | 732 EXPECT_EQ(all_white, gfx::Rect(content_bounds).Contains(canvas_rect)); |
| 697 } | 733 } |
| 698 } | 734 } |
| 699 } | 735 } |
| 700 | 736 |
| 701 TEST(PicturePileImpl, RasterContentsTransparent) { | 737 TEST(PicturePileImpl, RasterContentsTransparent) { |
| 702 gfx::Size tile_size(1000, 1000); | 738 gfx::Size tile_size(1000, 1000); |
| 703 gfx::Size layer_bounds(5, 3); | 739 gfx::Size layer_bounds(5, 3); |
| 704 float contents_scale = 0.5f; | 740 float contents_scale = 0.5f; |
| 705 | 741 |
| 742 scoped_ptr<FakePicturePile> recording_source = |
| 743 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 744 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 745 recording_source->SetRequiresClear(true); |
| 746 recording_source->SetMinContentsScale(contents_scale); |
| 747 recording_source->SetClearCanvasWithDebugColor(false); |
| 748 recording_source->RerecordPile(); |
| 749 |
| 706 scoped_refptr<FakePicturePileImpl> pile = | 750 scoped_refptr<FakePicturePileImpl> pile = |
| 707 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 751 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 708 pile->set_background_color(SK_ColorTRANSPARENT); | |
| 709 pile->SetRequiresClear(true); | |
| 710 pile->SetMinContentsScale(contents_scale); | |
| 711 pile->set_clear_canvas_with_debug_color(false); | |
| 712 pile->RerecordPile(); | |
| 713 | |
| 714 gfx::Size content_bounds( | 752 gfx::Size content_bounds( |
| 715 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 753 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
| 716 | 754 |
| 717 gfx::Rect canvas_rect(content_bounds); | 755 gfx::Rect canvas_rect(content_bounds); |
| 718 canvas_rect.Inset(0, 0, -1, -1); | 756 canvas_rect.Inset(0, 0, -1, -1); |
| 719 | 757 |
| 720 SkBitmap bitmap; | 758 SkBitmap bitmap; |
| 721 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height()); | 759 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height()); |
| 722 SkCanvas canvas(bitmap); | 760 SkCanvas canvas(bitmap); |
| 723 | 761 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 736 }; | 774 }; |
| 737 | 775 |
| 738 TEST_P(OverlapTest, NoOverlap) { | 776 TEST_P(OverlapTest, NoOverlap) { |
| 739 gfx::Size tile_size(10, 10); | 777 gfx::Size tile_size(10, 10); |
| 740 gfx::Size layer_bounds(30, 30); | 778 gfx::Size layer_bounds(30, 30); |
| 741 gfx::Size bigger_than_layer_bounds(300, 300); | 779 gfx::Size bigger_than_layer_bounds(300, 300); |
| 742 float contents_scale = GetParam(); | 780 float contents_scale = GetParam(); |
| 743 // Pick an opaque color to not have to deal with premultiplication off-by-one. | 781 // Pick an opaque color to not have to deal with premultiplication off-by-one. |
| 744 SkColor test_color = SkColorSetARGB(255, 45, 56, 67); | 782 SkColor test_color = SkColorSetARGB(255, 45, 56, 67); |
| 745 | 783 |
| 746 scoped_refptr<FakePicturePileImpl> pile = | 784 scoped_ptr<FakePicturePile> recording_source = |
| 747 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 785 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 748 pile->set_background_color(SK_ColorTRANSPARENT); | 786 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 749 pile->SetRequiresClear(true); | 787 recording_source->SetRequiresClear(true); |
| 750 pile->SetMinContentsScale(MinContentsScale()); | 788 recording_source->SetMinContentsScale(MinContentsScale()); |
| 751 pile->set_clear_canvas_with_debug_color(true); | 789 recording_source->SetClearCanvasWithDebugColor(true); |
| 790 |
| 752 SkPaint color_paint; | 791 SkPaint color_paint; |
| 753 color_paint.setColor(test_color); | 792 color_paint.setColor(test_color); |
| 754 // Additive paint, so that if two paints overlap, the color will change. | 793 // Additive paint, so that if two paints overlap, the color will change. |
| 755 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode); | 794 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode); |
| 756 // Paint outside the layer to make sure that blending works. | 795 // Paint outside the layer to make sure that blending works. |
| 757 pile->add_draw_rect_with_paint(gfx::RectF(bigger_than_layer_bounds), | 796 recording_source->add_draw_rect_with_paint( |
| 758 color_paint); | 797 gfx::RectF(bigger_than_layer_bounds), color_paint); |
| 759 pile->RerecordPile(); | 798 recording_source->RerecordPile(); |
| 760 | 799 |
| 800 scoped_refptr<FakePicturePileImpl> pile = |
| 801 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 761 gfx::Size content_bounds( | 802 gfx::Size content_bounds( |
| 762 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 803 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
| 763 | 804 |
| 764 SkBitmap bitmap; | 805 SkBitmap bitmap; |
| 765 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); | 806 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); |
| 766 SkCanvas canvas(bitmap); | 807 SkCanvas canvas(bitmap); |
| 767 | 808 |
| 768 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds), contents_scale); | 809 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds), contents_scale); |
| 769 | 810 |
| 770 for (int y = 0; y < bitmap.height(); y++) { | 811 for (int y = 0; y < bitmap.height(); y++) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 786 | 827 |
| 787 INSTANTIATE_TEST_CASE_P(PicturePileImpl, | 828 INSTANTIATE_TEST_CASE_P(PicturePileImpl, |
| 788 OverlapTest, | 829 OverlapTest, |
| 789 ::testing::Values(1.f, 0.873f, 1.f / 4.f, 4.f)); | 830 ::testing::Values(1.f, 0.873f, 1.f / 4.f, 4.f)); |
| 790 | 831 |
| 791 TEST(PicturePileImplTest, PixelRefIteratorBorders) { | 832 TEST(PicturePileImplTest, PixelRefIteratorBorders) { |
| 792 // 3 tile width / 1 tile height pile | 833 // 3 tile width / 1 tile height pile |
| 793 gfx::Size tile_size(128, 128); | 834 gfx::Size tile_size(128, 128); |
| 794 gfx::Size layer_bounds(320, 128); | 835 gfx::Size layer_bounds(320, 128); |
| 795 | 836 |
| 796 // Fake picture pile impl uses a tile grid the size of the tile. So, | 837 // Fake picture pile uses a tile grid the size of the tile. So, |
| 797 // any iteration that intersects with a tile will return all pixel refs | 838 // any iteration that intersects with a tile will return all pixel refs |
| 798 // inside of it. | 839 // inside of it. |
| 799 scoped_refptr<FakePicturePileImpl> pile = | 840 scoped_ptr<FakePicturePile> recording_source = |
| 800 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 841 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 801 pile->SetMinContentsScale(0.5f); | 842 recording_source->SetMinContentsScale(0.5f); |
| 802 | 843 |
| 803 // Bitmaps 0-2 are exactly on tiles 0-2, so that they overlap the borders | 844 // Bitmaps 0-2 are exactly on tiles 0-2, so that they overlap the borders |
| 804 // of adjacent tiles. | 845 // of adjacent tiles. |
| 805 gfx::Rect bitmap_rects[] = {pile->tiling().TileBounds(0, 0), | 846 gfx::Rect bitmap_rects[] = { |
| 806 pile->tiling().TileBounds(1, 0), | 847 recording_source->tiling().TileBounds(0, 0), |
| 807 pile->tiling().TileBounds(2, 0), }; | 848 recording_source->tiling().TileBounds(1, 0), |
| 849 recording_source->tiling().TileBounds(2, 0), |
| 850 }; |
| 808 SkBitmap discardable_bitmap[arraysize(bitmap_rects)]; | 851 SkBitmap discardable_bitmap[arraysize(bitmap_rects)]; |
| 809 | 852 |
| 810 for (size_t i = 0; i < arraysize(bitmap_rects); ++i) { | 853 for (size_t i = 0; i < arraysize(bitmap_rects); ++i) { |
| 811 CreateBitmap(bitmap_rects[i].size(), "discardable", &discardable_bitmap[i]); | 854 CreateBitmap(bitmap_rects[i].size(), "discardable", &discardable_bitmap[i]); |
| 812 pile->add_draw_bitmap(discardable_bitmap[i], bitmap_rects[i].origin()); | 855 recording_source->add_draw_bitmap(discardable_bitmap[i], |
| 856 bitmap_rects[i].origin()); |
| 813 } | 857 } |
| 814 | 858 |
| 859 recording_source->RerecordPile(); |
| 860 |
| 861 scoped_refptr<FakePicturePileImpl> pile = |
| 862 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 863 |
| 815 // Sanity check that bitmaps 0-2 intersect the borders of their adjacent | 864 // Sanity check that bitmaps 0-2 intersect the borders of their adjacent |
| 816 // tiles, but not the actual tiles. | 865 // tiles, but not the actual tiles. |
| 817 EXPECT_TRUE( | 866 EXPECT_TRUE( |
| 818 bitmap_rects[0].Intersects(pile->tiling().TileBoundsWithBorder(1, 0))); | 867 bitmap_rects[0].Intersects(pile->tiling().TileBoundsWithBorder(1, 0))); |
| 819 EXPECT_FALSE(bitmap_rects[0].Intersects(pile->tiling().TileBounds(1, 0))); | 868 EXPECT_FALSE(bitmap_rects[0].Intersects(pile->tiling().TileBounds(1, 0))); |
| 820 EXPECT_TRUE( | 869 EXPECT_TRUE( |
| 821 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(0, 0))); | 870 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(0, 0))); |
| 822 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(0, 0))); | 871 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(0, 0))); |
| 823 EXPECT_TRUE( | 872 EXPECT_TRUE( |
| 824 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(2, 0))); | 873 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(2, 0))); |
| 825 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(2, 0))); | 874 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(2, 0))); |
| 826 EXPECT_TRUE( | 875 EXPECT_TRUE( |
| 827 bitmap_rects[2].Intersects(pile->tiling().TileBoundsWithBorder(1, 0))); | 876 bitmap_rects[2].Intersects(pile->tiling().TileBoundsWithBorder(1, 0))); |
| 828 EXPECT_FALSE(bitmap_rects[2].Intersects(pile->tiling().TileBounds(1, 0))); | 877 EXPECT_FALSE(bitmap_rects[2].Intersects(pile->tiling().TileBounds(1, 0))); |
| 829 | 878 |
| 830 pile->RerecordPile(); | |
| 831 | |
| 832 // Tile-sized iterators. | 879 // Tile-sized iterators. |
| 833 { | 880 { |
| 834 // Because tile 0's borders extend onto tile 1, it will include both | 881 // Because tile 0's borders extend onto tile 1, it will include both |
| 835 // bitmap 0 and 1. However, it should *not* include bitmap 2. | 882 // bitmap 0 and 1. However, it should *not* include bitmap 2. |
| 836 PicturePileImpl::PixelRefIterator iterator( | 883 PicturePileImpl::PixelRefIterator iterator( |
| 837 pile->tiling().TileBounds(0, 0), 1.f, pile.get()); | 884 pile->tiling().TileBounds(0, 0), 1.f, pile.get()); |
| 838 EXPECT_TRUE(iterator); | 885 EXPECT_TRUE(iterator); |
| 839 EXPECT_TRUE(*iterator == discardable_bitmap[0].pixelRef()); | 886 EXPECT_TRUE(*iterator == discardable_bitmap[0].pixelRef()); |
| 840 EXPECT_TRUE(++iterator); | 887 EXPECT_TRUE(++iterator); |
| 841 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef()); | 888 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 861 EXPECT_TRUE(iterator); | 908 EXPECT_TRUE(iterator); |
| 862 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef()); | 909 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef()); |
| 863 EXPECT_TRUE(++iterator); | 910 EXPECT_TRUE(++iterator); |
| 864 EXPECT_TRUE(*iterator == discardable_bitmap[2].pixelRef()); | 911 EXPECT_TRUE(*iterator == discardable_bitmap[2].pixelRef()); |
| 865 EXPECT_FALSE(++iterator); | 912 EXPECT_FALSE(++iterator); |
| 866 } | 913 } |
| 867 } | 914 } |
| 868 | 915 |
| 869 } // namespace | 916 } // namespace |
| 870 } // namespace cc | 917 } // namespace cc |
| OLD | NEW |