Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
| 9 #include "cc/layers/picture_image_layer.h" | 9 #include "cc/layers/picture_image_layer.h" |
| 10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 mask->SetBounds(mask_bounds); | 141 mask->SetBounds(mask_bounds); |
| 142 mask->SetIsDrawable(true); | 142 mask->SetIsDrawable(true); |
| 143 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); | 143 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); |
| 144 green->SetMaskLayer(mask.get()); | 144 green->SetMaskLayer(mask.get()); |
| 145 | 145 |
| 146 RunPixelResourceTest( | 146 RunPixelResourceTest( |
| 147 background, | 147 background, |
| 148 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); | 148 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLargerLayer) { | |
| 152 scoped_refptr<SolidColorLayer> background = | |
| 153 CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE); | |
| 154 | |
| 155 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | |
| 156 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | |
| 157 background->AddChild(green); | |
| 158 | |
| 159 gfx::Size mask_bounds(40, 40); | |
|
enne (OOO)
2017/05/02 21:31:37
Feel free to take or leave this suggestion, but if
ericrk
2017/05/04 19:23:53
Per discussion, doesn't quite work. Added fuzzy co
| |
| 160 MaskContentLayerClient client(mask_bounds); | |
| 161 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | |
| 162 mask->SetBounds(mask_bounds); | |
| 163 mask->SetIsDrawable(true); | |
| 164 mask->SetLayerMaskType(Layer::LayerMaskType::SINGLE_TEXTURE_MASK); | |
|
sunxd
2017/05/03 15:14:13
I made a recent change that makes pixeltest tests
ericrk
2017/05/04 19:23:53
done. Thanks!
| |
| 165 green->SetMaskLayer(mask.get()); | |
| 166 | |
| 167 if (raster_buffer_provider_type_ == RASTER_BUFFER_PROVIDER_TYPE_BITMAP) { | |
| 168 // Bitmap produces a sharper (but equivalent sized) mask. | |
| 169 RunPixelResourceTest( | |
| 170 background, | |
| 171 base::FilePath(FILE_PATH_LITERAL("mask_of_larger_layer_bitmap.png"))); | |
| 172 } else { | |
| 173 RunPixelResourceTest( | |
| 174 background, | |
| 175 base::FilePath(FILE_PATH_LITERAL("mask_of_larger_layer.png"))); | |
| 176 } | |
| 177 } | |
| 178 | |
| 151 class CheckerContentLayerClient : public ContentLayerClient { | 179 class CheckerContentLayerClient : public ContentLayerClient { |
| 152 public: | 180 public: |
| 153 CheckerContentLayerClient(const gfx::Size& bounds, | 181 CheckerContentLayerClient(const gfx::Size& bounds, |
| 154 SkColor color, | 182 SkColor color, |
| 155 bool vertical) | 183 bool vertical) |
| 156 : bounds_(bounds), color_(color), vertical_(vertical) {} | 184 : bounds_(bounds), color_(color), vertical_(vertical) {} |
| 157 ~CheckerContentLayerClient() override {} | 185 ~CheckerContentLayerClient() override {} |
| 158 bool FillsBoundsCompletely() const override { return false; } | 186 bool FillsBoundsCompletely() const override { return false; } |
| 159 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 187 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 160 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 188 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 | 362 |
| 335 RunPixelResourceTest(background, | 363 RunPixelResourceTest(background, |
| 336 base::FilePath( | 364 base::FilePath( |
| 337 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 365 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
| 338 } | 366 } |
| 339 | 367 |
| 340 } // namespace | 368 } // namespace |
| 341 } // namespace cc | 369 } // namespace cc |
| 342 | 370 |
| 343 #endif // !defined(OS_ANDROID) | 371 #endif // !defined(OS_ANDROID) |
| OLD | NEW |