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

Unified Diff: cc/trees/layer_tree_host_pixeltest_masks.cc

Issue 2828353003: Determine mask UVs based on texture size (Closed)
Patch Set: Feedback Created 3 years, 7 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
« no previous file with comments | « cc/test/fake_picture_layer.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | 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 1c28c7fa862d8f9cbfbdd968d475e483c3580f64..d90ee78761a25909fd419755200765a7281bba24 100644
--- a/cc/trees/layer_tree_host_pixeltest_masks.cc
+++ b/cc/trees/layer_tree_host_pixeltest_masks.cc
@@ -13,6 +13,7 @@
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_image.h"
#include "cc/paint/paint_recorder.h"
+#include "cc/test/fake_picture_layer.h"
#include "cc/test/layer_tree_pixel_resource_test.h"
#include "cc/test/pixel_comparator.h"
#include "cc/test/solid_color_content_layer_client.h"
@@ -149,6 +150,67 @@ TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png")));
}
+TEST_P(LayerTreeHostMasksPixelTest, MaskOfLargerLayer) {
+ scoped_refptr<SolidColorLayer> background =
+ CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE);
+
+ scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
+ gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
+ background->AddChild(green);
+
+ gfx::Size mask_bounds(50, 50);
+ MaskContentLayerClient client(mask_bounds);
+ scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
+ mask->SetBounds(mask_bounds);
+ mask->SetIsDrawable(true);
+ mask->SetLayerMaskType(mask_type_);
+ green->SetMaskLayer(mask.get());
+
+ if (raster_buffer_provider_type_ == RASTER_BUFFER_PROVIDER_TYPE_BITMAP) {
+ // Bitmap produces a sharper (but equivalent sized) mask.
+ float percentage_pixels_large_error = 40.0f;
+ float percentage_pixels_small_error = 0.0f;
+ float average_error_allowed_in_bad_pixels = 65.0f;
+ int large_error_allowed = 120;
+ int small_error_allowed = 0;
+ pixel_comparator_.reset(new FuzzyPixelComparator(
+ true, // discard_alpha
+ percentage_pixels_large_error, percentage_pixels_small_error,
+ average_error_allowed_in_bad_pixels, large_error_allowed,
+ small_error_allowed));
+ }
+
+ RunPixelResourceTest(
+ background,
+ base::FilePath(FILE_PATH_LITERAL("mask_of_larger_layer.png")));
+}
+
+TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayerNonExactTextureSize) {
+ // This test only makes sense in single texture mode.
+ if (mask_type_ != Layer::LayerMaskType::SINGLE_TEXTURE_MASK)
+ return;
+
+ scoped_refptr<SolidColorLayer> background =
+ CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE);
+
+ scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
+ gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
+ background->AddChild(green);
+
+ gfx::Size mask_bounds(100, 100);
+ MaskContentLayerClient client(mask_bounds);
+ scoped_refptr<FakePictureLayer> mask = FakePictureLayer::Create(&client);
+ mask->SetBounds(mask_bounds);
+ mask->SetIsDrawable(true);
+ mask->SetLayerMaskType(Layer::LayerMaskType::SINGLE_TEXTURE_MASK);
sunxd 2017/05/04 19:43:49 Nit: Could you also change this to mask_type_? Tha
ericrk 2017/05/04 19:51:38 I don't think this test makes sense for tiled mask
ericrk 2017/05/04 19:55:06 I guess it can't hurt though... ok, added
+ mask->set_fixed_tile_size(gfx::Size(173, 135));
+ green->SetMaskLayer(mask.get());
+
+ RunPixelResourceTest(background,
+ base::FilePath(FILE_PATH_LITERAL(
+ "mask_with_non_exact_texture_size.png")));
+}
+
class CheckerContentLayerClient : public ContentLayerClient {
public:
CheckerContentLayerClient(const gfx::Size& bounds,
« no previous file with comments | « cc/test/fake_picture_layer.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698