Index: cc/trees/layer_tree_host_pixeltest_filters.cc |
diff --git a/cc/trees/layer_tree_host_pixeltest_filters.cc b/cc/trees/layer_tree_host_pixeltest_filters.cc |
index c8c8c7adf3f5f72bc0f3305f9a312cd25076f430..5303ed1afb9d7b39839e4d1ea6f9d46b2e4cad4b 100644 |
--- a/cc/trees/layer_tree_host_pixeltest_filters.cc |
+++ b/cc/trees/layer_tree_host_pixeltest_filters.cc |
@@ -157,6 +157,80 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) { |
"background_filter_blur_off_axis.png"))); |
} |
+class LayerTreeHostFiltersScaledPixelTest |
+ : public LayerTreeHostFiltersPixelTest { |
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
+ // Required so that device scale is inherited by content scale. |
+ settings->layer_transforms_should_scale_layer_contents = true; |
+ } |
+ |
+ virtual void SetupTree() OVERRIDE { |
+ layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
+ LayerTreePixelTest::SetupTree(); |
+ } |
+ |
+ protected: |
+ void RunPixelTestType(int content_size, |
+ float device_scale_factor, |
+ PixelTestType test_type) { |
+ int half_content = content_size / 2; |
+ |
+ scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer( |
+ gfx::Rect(0, 0, content_size, content_size), SK_ColorWHITE); |
+ |
+ scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
+ gfx::Rect(0, 0, content_size, content_size), SK_ColorGREEN); |
+ root->AddChild(background); |
+ |
+ // Add a blue layer that completely covers the green layer. |
+ scoped_refptr<SolidColorLayer> foreground = CreateSolidColorLayer( |
+ gfx::Rect(0, 0, content_size, content_size), SK_ColorBLUE); |
+ background->AddChild(foreground); |
+ |
+ // Add an alpha threshold filter to the blue layer which will filter out |
+ // everything except the lower right corner. |
+ FilterOperations filters; |
+ SkRegion alpha_region; |
+ alpha_region.setRect( |
+ half_content, half_content, content_size, content_size); |
+ filters.Append( |
+ FilterOperation::CreateAlphaThresholdFilter(alpha_region, 1.f, 0.f)); |
+ foreground->SetFilters(filters); |
+ |
+ device_scale_factor_ = device_scale_factor; |
+ RunPixelTest( |
+ test_type, |
+ background, |
+ base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
+ } |
+ |
+ float device_scale_factor_; |
+}; |
+ |
+TEST_F(LayerTreeHostFiltersScaledPixelTest, StandardDpi_GLBitmap) { |
+ RunPixelTestType(100, 1.f, GL_WITH_BITMAP); |
+} |
+ |
+TEST_F(LayerTreeHostFiltersScaledPixelTest, StandardDpi_GLDefault) { |
+ RunPixelTestType(100, 1.f, GL_WITH_DEFAULT); |
+} |
+ |
+TEST_F(LayerTreeHostFiltersScaledPixelTest, StandardDpi_Software) { |
+ RunPixelTestType(100, 1.f, SOFTWARE_WITH_BITMAP); |
+} |
+ |
+TEST_F(LayerTreeHostFiltersScaledPixelTest, HiDpi_GLBitmap) { |
+ RunPixelTestType(50, 2.f, GL_WITH_BITMAP); |
+} |
+ |
+TEST_F(LayerTreeHostFiltersScaledPixelTest, HiDpi_GLDefault) { |
+ RunPixelTestType(50, 2.f, GL_WITH_DEFAULT); |
+} |
+ |
+TEST_F(LayerTreeHostFiltersScaledPixelTest, HiDpi_Software) { |
+ RunPixelTestType(50, 2.f, SOFTWARE_WITH_BITMAP); |
+} |
+ |
class ImageFilterClippedPixelTest : public LayerTreeHostFiltersPixelTest { |
protected: |
void RunPixelTestType(PixelTestType test_type) { |