| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 mask->SetBounds(mask_bounds); | 142 mask->SetBounds(mask_bounds); |
| 143 mask->SetIsDrawable(true); | 143 mask->SetIsDrawable(true); |
| 144 mask->SetLayerMaskType(mask_type_); | 144 mask->SetLayerMaskType(mask_type_); |
| 145 green->SetMaskLayer(mask.get()); | 145 green->SetMaskLayer(mask.get()); |
| 146 | 146 |
| 147 RunPixelResourceTest( | 147 RunPixelResourceTest( |
| 148 background, | 148 background, |
| 149 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); | 149 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLargerLayer) { | |
| 153 scoped_refptr<SolidColorLayer> background = | |
| 154 CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE); | |
| 155 | |
| 156 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | |
| 157 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | |
| 158 background->AddChild(green); | |
| 159 | |
| 160 gfx::Size mask_bounds(50, 50); | |
| 161 MaskContentLayerClient client(mask_bounds); | |
| 162 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | |
| 163 mask->SetBounds(mask_bounds); | |
| 164 mask->SetIsDrawable(true); | |
| 165 mask->SetLayerMaskType(mask_type_); | |
| 166 green->SetMaskLayer(mask.get()); | |
| 167 | |
| 168 if (raster_buffer_provider_type_ == RASTER_BUFFER_PROVIDER_TYPE_BITMAP) { | |
| 169 // Bitmap produces a sharper (but equivalent sized) mask. | |
| 170 float percentage_pixels_large_error = 40.0f; | |
| 171 float percentage_pixels_small_error = 0.0f; | |
| 172 float average_error_allowed_in_bad_pixels = 65.0f; | |
| 173 int large_error_allowed = 120; | |
| 174 int small_error_allowed = 0; | |
| 175 pixel_comparator_.reset(new FuzzyPixelComparator( | |
| 176 true, // discard_alpha | |
| 177 percentage_pixels_large_error, percentage_pixels_small_error, | |
| 178 average_error_allowed_in_bad_pixels, large_error_allowed, | |
| 179 small_error_allowed)); | |
| 180 } | |
| 181 | |
| 182 RunPixelResourceTest( | |
| 183 background, | |
| 184 base::FilePath(FILE_PATH_LITERAL("mask_of_larger_layer.png"))); | |
| 185 } | |
| 186 | |
| 187 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayerNonExactTextureSize) { | 152 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayerNonExactTextureSize) { |
| 188 scoped_refptr<SolidColorLayer> background = | 153 scoped_refptr<SolidColorLayer> background = |
| 189 CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE); | 154 CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE); |
| 190 | 155 |
| 191 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 156 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
| 192 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 157 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
| 193 background->AddChild(green); | 158 background->AddChild(green); |
| 194 | 159 |
| 195 gfx::Size mask_bounds(100, 100); | 160 gfx::Size mask_bounds(100, 100); |
| 196 MaskContentLayerClient client(mask_bounds); | 161 MaskContentLayerClient client(mask_bounds); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 369 |
| 405 RunPixelResourceTest(background, | 370 RunPixelResourceTest(background, |
| 406 base::FilePath( | 371 base::FilePath( |
| 407 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 372 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
| 408 } | 373 } |
| 409 | 374 |
| 410 } // namespace | 375 } // namespace |
| 411 } // namespace cc | 376 } // namespace cc |
| 412 | 377 |
| 413 #endif // !defined(OS_ANDROID) | 378 #endif // !defined(OS_ANDROID) |
| OLD | NEW |