Index: cc/trees/layer_tree_host_pixeltest_masks.cc |
diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc |
index eecc5a0e3eddc68ea43530e3359c64e3f1705bf0..a560d5e6ff512e1eae7b1fef3a7b7a34b56c1359 100644 |
--- a/cc/trees/layer_tree_host_pixeltest_masks.cc |
+++ b/cc/trees/layer_tree_host_pixeltest_masks.cc |
@@ -282,6 +282,114 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { |
#endif // !defined(OS_WIN) |
+class CheckerContentLayerClient : public ContentLayerClient { |
+ public: |
+ explicit CheckerContentLayerClient(const gfx::Size& bounds) |
+ : bounds_(bounds) {} |
+ ~CheckerContentLayerClient() override {} |
+ bool FillsBoundsCompletely() const override { return false; } |
+ void PaintContents(SkCanvas* canvas, |
+ const gfx::Rect& rect, |
+ PaintingControlSetting picture_control) override { |
+ SkPaint paint; |
+ paint.setStyle(SkPaint::kStroke_Style); |
+ paint.setStrokeWidth(SkIntToScalar(3)); |
+ paint.setColor(SK_ColorGREEN); |
+ canvas->clear(SK_ColorTRANSPARENT); |
+ for (int i = 0; i < bounds_.width(); i += 11) { |
+ canvas->drawLine(i, 0, i, bounds_.height(), paint); |
+ } |
+ } |
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
+ const gfx::Rect& clip, |
+ PaintingControlSetting picture_control) override { |
+ NOTIMPLEMENTED(); |
+ return DisplayItemList::Create(); |
+ } |
+ |
+ private: |
+ gfx::Size bounds_; |
+}; |
+ |
+class CircleContentLayerClient : public ContentLayerClient { |
+ public: |
+ explicit CircleContentLayerClient(const gfx::Size& bounds) |
+ : bounds_(bounds) {} |
+ ~CircleContentLayerClient() override {} |
+ bool FillsBoundsCompletely() const override { return false; } |
+ void PaintContents(SkCanvas* canvas, |
+ const gfx::Rect& rect, |
+ PaintingControlSetting picture_control) override { |
+ SkPaint paint; |
+ paint.setStyle(SkPaint::kFill_Style); |
+ paint.setColor(SK_ColorWHITE); |
+ canvas->clear(SK_ColorTRANSPARENT); |
+ canvas->drawCircle(bounds_.width() / 2, |
+ bounds_.height() / 2, |
+ bounds_.width() / 4, |
+ paint); |
+ } |
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
+ const gfx::Rect& clip, |
+ PaintingControlSetting picture_control) override { |
+ NOTIMPLEMENTED(); |
+ return DisplayItemList::Create(); |
+ } |
+ |
+ private: |
+ gfx::Size bounds_; |
+}; |
+ |
+using LayerTreeHostMasksForBackgroundFiltersPixelTest = |
+ ParameterizedPixelResourceTest; |
+ |
+INSTANTIATE_TEST_CASE_P( |
+ PixelResourceTest, |
+ LayerTreeHostMasksForBackgroundFiltersPixelTest, |
+ ::testing::Values( |
+ // SOFTWARE, Background filters aren't implemented in software |
+ // GL_GPU_RASTER_2D_DRAW, Gpu rasterisation has errors in accuracy |
+ GL_ONE_COPY_2D_STAGING_2D_DRAW, |
+ GL_ONE_COPY_RECT_STAGING_2D_DRAW, |
+ GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW, |
+ GL_ZERO_COPY_2D_DRAW, |
+ GL_ZERO_COPY_RECT_DRAW, |
+ GL_ZERO_COPY_EXTERNAL_DRAW, |
+ GL_ASYNC_UPLOAD_2D_DRAW)); |
+ |
+TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, |
+ MaskOfLayerWithBackgroundFilter) { |
+ scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
+ gfx::Rect(200, 200), SK_ColorWHITE); |
+ |
+ gfx::Size picture_bounds(200, 200); |
+ CheckerContentLayerClient picture_client(picture_bounds); |
+ scoped_refptr<PictureLayer> picture = PictureLayer::Create(&picture_client); |
+ picture->SetBounds(picture_bounds); |
+ picture->SetIsDrawable(true); |
+ |
+ scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer( |
+ gfx::Rect(200, 200), SK_ColorTRANSPARENT); |
+ background->AddChild(picture); |
+ background->AddChild(blur); |
+ |
+ FilterOperations filters; |
+ filters.Append(FilterOperation::CreateBlurFilter(2.f)); |
+ blur->SetBackgroundFilters(filters); |
+ |
+ gfx::Size mask_bounds(200, 200); |
+ CircleContentLayerClient mask_client(mask_bounds); |
+ scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); |
+ mask->SetBounds(mask_bounds); |
+ mask->SetIsDrawable(true); |
+ mask->SetIsMask(true); |
+ blur->SetMaskLayer(mask.get()); |
+ |
+ RunPixelResourceTest(background, |
+ base::FilePath( |
+ FILE_PATH_LITERAL("mask_of_background_filter.png"))); |
+} |
+ |
} // namespace |
} // namespace cc |