Index: cc/raster/raster_source_unittest.cc |
diff --git a/cc/raster/raster_source_unittest.cc b/cc/raster/raster_source_unittest.cc |
index 25401371fa5bc12ab8a17380f9657968cb265f51..68bbb6e96dade1db9fc05b5f21cbf789f81751ec 100644 |
--- a/cc/raster/raster_source_unittest.cc |
+++ b/cc/raster/raster_source_unittest.cc |
@@ -96,6 +96,89 @@ TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) { |
EXPECT_EQ(solid_color, color); |
} |
+TEST(RasterSourceTest, AnalyzeIsSolidScaled) { |
+ gfx::Size layer_bounds(400, 400); |
+ const std::vector<float> recording_scales = {1.25f, 1.33f, 1.5f, 1.6f, |
+ 1.66f, 2.f, 2.25f, 2.5f}; |
+ for (float recording_scale : recording_scales) { |
+ std::unique_ptr<FakeRecordingSource> recording_source = |
+ FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
+ recording_source->SetRecordingScaleFactor(recording_scale); |
+ |
+ PaintFlags solid_flags; |
+ SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
+ solid_flags.setColor(solid_color); |
+ |
+ SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
+ SkColor color = SK_ColorTRANSPARENT; |
+ PaintFlags non_solid_flags; |
+ bool is_solid_color = false; |
+ non_solid_flags.setColor(non_solid_color); |
+ |
+ recording_source->add_draw_rect_with_flags( |
+ gfx::ScaleToEnclosingRect(gfx::Rect(layer_bounds), recording_scale), |
+ solid_flags); |
+ recording_source->Rerecord(); |
+ |
+ scoped_refptr<RasterSource> raster = recording_source->CreateRasterSource(); |
+ |
+ // Ensure everything is solid. |
+ for (int y = 0; y <= 300; y += 100) { |
+ for (int x = 0; x <= 300; x += 100) { |
+ gfx::Rect rect(x, y, 100, 100); |
+ is_solid_color = raster->PerformSolidColorAnalysis(rect, &color); |
+ EXPECT_TRUE(is_solid_color) |
+ << rect.ToString() << " recording_scale: " << recording_scale; |
+ EXPECT_EQ(solid_color, color) |
+ << rect.ToString() << " recording_scale: " << recording_scale; |
+ } |
+ } |
+ |
+ // Add one non-solid pixel and recreate the raster source. |
+ recording_source->add_draw_rect_with_flags( |
+ gfx::Rect(std::round(50 * recording_scale), |
+ std::round(50 * recording_scale), 1, 1), |
+ non_solid_flags); |
+ recording_source->Rerecord(); |
+ raster = recording_source->CreateRasterSource(); |
+ |
+ color = SK_ColorTRANSPARENT; |
+ is_solid_color = |
+ raster->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), &color); |
+ EXPECT_FALSE(is_solid_color) << " recording_scale: " << recording_scale; |
+ |
+ color = SK_ColorTRANSPARENT; |
+ is_solid_color = |
+ raster->PerformSolidColorAnalysis(gfx::Rect(0, 0, 51, 51), &color); |
+ EXPECT_FALSE(is_solid_color) << " recording_scale: " << recording_scale; |
+ |
+ color = SK_ColorTRANSPARENT; |
+ is_solid_color = |
+ raster->PerformSolidColorAnalysis(gfx::Rect(51, 0, 100, 100), &color); |
+ EXPECT_TRUE(is_solid_color) << " recording_scale: " << recording_scale; |
+ EXPECT_EQ(solid_color, color) << " recording_scale: " << recording_scale; |
+ |
+ // Boundaries should be clipped. |
+ color = SK_ColorTRANSPARENT; |
+ is_solid_color = |
+ raster->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), &color); |
+ EXPECT_TRUE(is_solid_color) << " recording_scale: " << recording_scale; |
+ EXPECT_EQ(solid_color, color) << " recording_scale: " << recording_scale; |
+ |
+ color = SK_ColorTRANSPARENT; |
+ is_solid_color = |
+ raster->PerformSolidColorAnalysis(gfx::Rect(0, 350, 100, 100), &color); |
+ EXPECT_TRUE(is_solid_color) << " recording_scale: " << recording_scale; |
+ EXPECT_EQ(solid_color, color) << " recording_scale: " << recording_scale; |
+ |
+ color = SK_ColorTRANSPARENT; |
+ is_solid_color = raster->PerformSolidColorAnalysis( |
+ gfx::Rect(350, 350, 100, 100), &color); |
+ EXPECT_TRUE(is_solid_color) << " recording_scale: " << recording_scale; |
+ EXPECT_EQ(solid_color, color) << " recording_scale: " << recording_scale; |
+ } |
+} |
+ |
TEST(RasterSourceTest, PixelRefIteratorDiscardableRefsOneTile) { |
gfx::Size layer_bounds(512, 512); |