Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: cc/trees/layer_tree_host_pixeltest_masks.cc

Issue 959283004: Background filters are affected by masks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes and more tests Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/output/shader.cc ('K') | « cc/test/data/mask_of_layer_with_blend.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c67382e3b268a6157a6072b747fdb4cea251b148 100644
--- a/cc/trees/layer_tree_host_pixeltest_masks.cc
+++ b/cc/trees/layer_tree_host_pixeltest_masks.cc
@@ -282,6 +282,162 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
#endif // !defined(OS_WIN)
+class CheckerContentLayerClient : public ContentLayerClient {
+ public:
+ CheckerContentLayerClient(const gfx::Size& bounds,
+ SkColor color,
+ bool vertical)
+ : bounds_(bounds), color_(color), vertical_(vertical) {}
+ ~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(color_);
+ canvas->clear(SK_ColorTRANSPARENT);
+ if (vertical_) {
+ for (int i = 0; i < bounds_.width(); i += 11) {
+ canvas->drawLine(i, 0, i, bounds_.height(), paint);
+ }
+ } else {
+ for (int i = 0; i < bounds_.height(); i += 11) {
+ canvas->drawLine(0, i, bounds_.width(), i, paint);
+ }
+ }
+ }
+ scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
+ const gfx::Rect& clip,
+ PaintingControlSetting picture_control) override {
+ NOTIMPLEMENTED();
+ return DisplayItemList::Create();
+ }
+
+ private:
+ gfx::Size bounds_;
+ SkColor color_;
+ bool vertical_;
+};
+
+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
enne (OOO) 2015/03/04 19:58:44 Can you use a fuzzy pixel comparator? How inaccura
+ 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, SK_ColorGREEN, true);
+ 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")));
+}
+
+TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
+ MaskOfLayerWithBlend) {
+ scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
+ gfx::Rect(200, 200), SK_ColorWHITE);
+
+ gfx::Size picture_bounds(200, 200);
+ CheckerContentLayerClient picture_client_vertical(
+ picture_bounds, SK_ColorGREEN, true);
+ scoped_refptr<PictureLayer> picture_vertical =
+ PictureLayer::Create(&picture_client_vertical);
+ picture_vertical->SetBounds(picture_bounds);
+ picture_vertical->SetIsDrawable(true);
+
+ CheckerContentLayerClient picture_client_horizontal(
+ picture_bounds, SK_ColorMAGENTA, false);
+ scoped_refptr<PictureLayer> picture_horizontal =
+ PictureLayer::Create(&picture_client_horizontal);
+ picture_horizontal->SetBounds(picture_bounds);
+ picture_horizontal->SetIsDrawable(true);
+ picture_horizontal->SetContentsOpaque(false);
+ picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode);
+
+ background->AddChild(picture_vertical);
+ background->AddChild(picture_horizontal);
+
+ 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);
+ picture_horizontal->SetMaskLayer(mask.get());
+
+ RunPixelResourceTest(background,
+ base::FilePath(
+ FILE_PATH_LITERAL("mask_of_layer_with_blend.png")));
+}
+
} // namespace
} // namespace cc
« cc/output/shader.cc ('K') | « cc/test/data/mask_of_layer_with_blend.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698