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 604eabba00759cbb3ce59f3eaf6e3c029f637b53..d2a6507f940e6a062f3a1f739240c35d33ba45bd 100644 |
--- a/cc/trees/layer_tree_host_pixeltest_filters.cc |
+++ b/cc/trees/layer_tree_host_pixeltest_filters.cc |
@@ -150,51 +150,58 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) { |
"background_filter_blur_off_axis.png"))); |
} |
-TEST_F(LayerTreeHostFiltersPixelTest, ImageFilterClipped) { |
- scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer( |
- gfx::Rect(200, 200), SK_ColorBLACK); |
- |
- scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
- gfx::Rect(200, 200), SK_ColorYELLOW); |
- root->AddChild(background); |
- |
- scoped_refptr<SolidColorLayer> foreground = CreateSolidColorLayer( |
- gfx::Rect(200, 200), SK_ColorRED); |
- background->AddChild(foreground); |
- |
- SkScalar matrix[20]; |
- memset(matrix, 0, 20 * sizeof(matrix[0])); |
- // This filter does a red-blue swap, so the foreground becomes blue. |
- matrix[2] = matrix[6] = matrix[10] = matrix[18] = SK_Scalar1; |
- skia::RefPtr<SkColorFilter> colorFilter(skia::AdoptRef( |
- new SkColorMatrixFilter(matrix))); |
- // We filter only the bottom 200x100 pixels of the foreground. |
- SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100)); |
- skia::RefPtr<SkImageFilter> filter = |
- skia::AdoptRef(SkColorFilterImageFilter::Create( |
- colorFilter.get(), |
- NULL, |
- &crop_rect)); |
- FilterOperations filters; |
- filters.Append(FilterOperation::CreateReferenceFilter(filter)); |
- |
- // Make the foreground layer's render surface be clipped by the background |
- // layer. |
- background->SetMasksToBounds(true); |
- foreground->SetFilters(filters); |
- |
- // Then we translate the foreground up by 100 pixels in Y, so the cropped |
- // region is moved to to the top. This ensures that the crop rect is being |
- // correctly transformed in skia by the amount of clipping that the |
- // compositor performs. |
- gfx::Transform transform; |
- transform.Translate(0.0, -100.0); |
- foreground->SetTransform(transform); |
+class ImageFilterClippedPixelTest : public LayerTreeHostFiltersPixelTest { |
+ protected: |
+ void RunPixelTestType(PixelTestType test_type) { |
+ scoped_refptr<SolidColorLayer> root = |
+ CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
+ |
+ scoped_refptr<SolidColorLayer> background = |
+ CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorYELLOW); |
+ root->AddChild(background); |
+ |
+ scoped_refptr<SolidColorLayer> foreground = |
+ CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorRED); |
+ background->AddChild(foreground); |
+ |
+ SkScalar matrix[20]; |
+ memset(matrix, 0, 20 * sizeof(matrix[0])); |
+ // This filter does a red-blue swap, so the foreground becomes blue. |
+ matrix[2] = matrix[6] = matrix[10] = matrix[18] = SK_Scalar1; |
+ skia::RefPtr<SkColorFilter> colorFilter( |
+ skia::AdoptRef(new SkColorMatrixFilter(matrix))); |
+ // We filter only the bottom 200x100 pixels of the foreground. |
+ SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100)); |
+ skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( |
+ SkColorFilterImageFilter::Create(colorFilter.get(), NULL, &crop_rect)); |
+ FilterOperations filters; |
+ filters.Append(FilterOperation::CreateReferenceFilter(filter)); |
+ |
+ // Make the foreground layer's render surface be clipped by the background |
+ // layer. |
+ background->SetMasksToBounds(true); |
+ foreground->SetFilters(filters); |
+ |
+ // Then we translate the foreground up by 100 pixels in Y, so the cropped |
+ // region is moved to to the top. This ensures that the crop rect is being |
+ // correctly transformed in skia by the amount of clipping that the |
+ // compositor performs. |
+ gfx::Transform transform; |
+ transform.Translate(0.0, -100.0); |
+ foreground->SetTransform(transform); |
+ |
+ RunPixelTest(test_type, |
+ background, |
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); |
+ } |
+}; |
+ |
+TEST_F(ImageFilterClippedPixelTest, ImageFilterClipped_GL) { |
+ RunPixelTestType(GL_WITH_BITMAP); |
+} |
- RunPixelTest(GL_WITH_BITMAP, |
- background, |
- base::FilePath(FILE_PATH_LITERAL( |
- "blue_yellow.png"))); |
+TEST_F(ImageFilterClippedPixelTest, ImageFilterClipped_Software) { |
+ RunPixelTestType(SOFTWARE_WITH_BITMAP); |
} |
} // namespace |