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

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_blending.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/layers/image_layer.h" 5 #include "cc/layers/picture_image_layer.h"
6 #include "cc/layers/solid_color_layer.h" 6 #include "cc/layers/solid_color_layer.h"
7 #include "cc/test/layer_tree_pixel_resource_test.h" 7 #include "cc/test/layer_tree_pixel_resource_test.h"
8 #include "cc/test/pixel_comparator.h" 8 #include "cc/test/pixel_comparator.h"
9 9
10 #if !defined(OS_ANDROID) 10 #if !defined(OS_ANDROID)
11 11
12 namespace cc { 12 namespace cc {
13 namespace { 13 namespace {
14 14
15 SkXfermode::Mode const kBlendModes[] = { 15 SkXfermode::Mode const kBlendModes[] = {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 SkBitmap backing_store; 130 SkBitmap backing_store;
131 backing_store.allocN32Pixels(width, height); 131 backing_store.allocN32Pixels(width, height);
132 SkCanvas canvas(backing_store); 132 SkCanvas canvas(backing_store);
133 canvas.clear(SK_ColorTRANSPARENT); 133 canvas.clear(SK_ColorTRANSPARENT);
134 for (int i = 0; i < kCSSTestColorsCount; ++i) { 134 for (int i = 0; i < kCSSTestColorsCount; ++i) {
135 SkPaint paint; 135 SkPaint paint;
136 paint.setColor(kCSSTestColors[i]); 136 paint.setColor(kCSSTestColors[i]);
137 canvas.drawRect( 137 canvas.drawRect(
138 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); 138 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint);
139 } 139 }
140 scoped_refptr<ImageLayer> layer = ImageLayer::Create(); 140 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create();
141 layer->SetIsDrawable(true); 141 layer->SetIsDrawable(true);
142 layer->SetBounds(gfx::Size(width, height)); 142 layer->SetBounds(gfx::Size(width, height));
143 layer->SetBitmap(backing_store); 143 layer->SetBitmap(backing_store);
144 return layer; 144 return layer;
145 } 145 }
146 146
147 void SetupMaskLayer(scoped_refptr<Layer> layer) { 147 void SetupMaskLayer(scoped_refptr<Layer> layer) {
148 const int kMaskOffset = 2; 148 const int kMaskOffset = 2;
149 gfx::Size bounds = layer->bounds(); 149 gfx::Size bounds = layer->bounds();
150 scoped_refptr<ImageLayer> mask = ImageLayer::Create(); 150 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
151 mask->SetIsDrawable(true); 151 mask->SetIsDrawable(true);
152 mask->SetIsMask(true); 152 mask->SetIsMask(true);
153 mask->SetBounds(bounds); 153 mask->SetBounds(bounds);
154 154
155 SkBitmap bitmap; 155 SkBitmap bitmap;
156 bitmap.allocN32Pixels(bounds.width(), bounds.height()); 156 bitmap.allocN32Pixels(bounds.width(), bounds.height());
157 SkCanvas canvas(bitmap); 157 SkCanvas canvas(bitmap);
158 SkPaint paint; 158 SkPaint paint;
159 paint.setColor(SK_ColorWHITE); 159 paint.setColor(SK_ColorWHITE);
160 canvas.clear(SK_ColorTRANSPARENT); 160 canvas.clear(SK_ColorTRANSPARENT);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 scoped_refptr<SolidColorLayer> root = 230 scoped_refptr<SolidColorLayer> root =
231 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), SK_ColorWHITE); 231 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), SK_ColorWHITE);
232 scoped_refptr<Layer> background = 232 scoped_refptr<Layer> background =
233 CreateColorfulBackdropLayer(kRootSize, kRootSize); 233 CreateColorfulBackdropLayer(kRootSize, kRootSize);
234 234
235 background->SetIsRootForIsolatedGroup(true); 235 background->SetIsRootForIsolatedGroup(true);
236 root->AddChild(background); 236 root->AddChild(background);
237 237
238 CreateBlendingColorLayers(kLaneWidth, kLaneHeight, background.get(), flags); 238 CreateBlendingColorLayers(kLaneWidth, kLaneHeight, background.get(), flags);
239 239
240 this->impl_side_painting_ = false;
241 this->force_antialiasing_ = (flags & kUseAntialiasing); 240 this->force_antialiasing_ = (flags & kUseAntialiasing);
242 this->force_blending_with_shaders_ = (flags & kForceShaders); 241 this->force_blending_with_shaders_ = (flags & kForceShaders);
243 242
244 if ((flags & kUseAntialiasing) && (test_type_ == PIXEL_TEST_GL)) { 243 if ((flags & kUseAntialiasing) && (test_type_ == PIXEL_TEST_GL)) {
245 // Anti aliasing causes differences up to 8 pixels at the edges. 244 // Anti aliasing causes differences up to 8 pixels at the edges.
246 int large_error_allowed = 8; 245 int large_error_allowed = 8;
247 // Blending results might differ with one pixel. 246 // Blending results might differ with one pixel.
248 int small_error_allowed = 1; 247 int small_error_allowed = 1;
249 // Most of the errors are one pixel errors. 248 // Most of the errors are one pixel errors.
250 float percentage_pixels_small_error = 13.1f; 249 float percentage_pixels_small_error = 13.1f;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 429 }
431 430
432 TEST_F(LayerTreeHostBlendingPixelTest, 431 TEST_F(LayerTreeHostBlendingPixelTest,
433 BlendingWithRenderPassShadersWithMask_GL) { 432 BlendingWithRenderPassShadersWithMask_GL) {
434 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW, 433 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW,
435 FILE_PATH_LITERAL("blending_render_pass_mask.png"), 434 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
436 kUseMasks | kForceShaders); 435 kUseMasks | kForceShaders);
437 } 436 }
438 437
439 TEST_F(LayerTreeHostBlendingPixelTest, 438 TEST_F(LayerTreeHostBlendingPixelTest,
439 BlendingWithRenderPassShadersWithMask_GL_TextureRect) {
440 RunBlendingWithRenderPass(GL_ZERO_COPY_RECT_DRAW,
441 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
442 kUseMasks | kForceShaders);
443 }
444
445 TEST_F(LayerTreeHostBlendingPixelTest,
440 BlendingWithRenderPassShadersWithMaskAA_GL) { 446 BlendingWithRenderPassShadersWithMaskAA_GL) {
441 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW, 447 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW,
442 FILE_PATH_LITERAL("blending_render_pass_mask.png"), 448 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
443 kUseMasks | kUseAntialiasing | kForceShaders); 449 kUseMasks | kUseAntialiasing | kForceShaders);
444 } 450 }
445 451
446 TEST_F(LayerTreeHostBlendingPixelTest, 452 TEST_F(LayerTreeHostBlendingPixelTest,
453 BlendingWithRenderPassShadersWithMaskAA_GL_TextureRect) {
454 RunBlendingWithRenderPass(GL_ZERO_COPY_RECT_DRAW,
455 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
456 kUseMasks | kUseAntialiasing | kForceShaders);
457 }
458
459 TEST_F(LayerTreeHostBlendingPixelTest,
447 BlendingWithRenderPassShadersColorMatrix_GL) { 460 BlendingWithRenderPassShadersColorMatrix_GL) {
448 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW, 461 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW,
449 FILE_PATH_LITERAL("blending_render_pass.png"), 462 FILE_PATH_LITERAL("blending_render_pass.png"),
450 kUseColorMatrix | kForceShaders); 463 kUseColorMatrix | kForceShaders);
451 } 464 }
452 465
453 TEST_F(LayerTreeHostBlendingPixelTest, 466 TEST_F(LayerTreeHostBlendingPixelTest,
454 BlendingWithRenderPassShadersColorMatrixAA_GL) { 467 BlendingWithRenderPassShadersColorMatrixAA_GL) {
455 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW, 468 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW,
456 FILE_PATH_LITERAL("blending_render_pass.png"), 469 FILE_PATH_LITERAL("blending_render_pass.png"),
457 kUseAntialiasing | kUseColorMatrix | kForceShaders); 470 kUseAntialiasing | kUseColorMatrix | kForceShaders);
458 } 471 }
459 472
460 TEST_F(LayerTreeHostBlendingPixelTest, 473 TEST_F(LayerTreeHostBlendingPixelTest,
461 BlendingWithRenderPassShadersWithMaskColorMatrix_GL) { 474 BlendingWithRenderPassShadersWithMaskColorMatrix_GL) {
462 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW, 475 RunBlendingWithRenderPass(GL_ASYNC_UPLOAD_2D_DRAW,
463 FILE_PATH_LITERAL("blending_render_pass_mask.png"), 476 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
464 kUseMasks | kUseColorMatrix | kForceShaders); 477 kUseMasks | kUseColorMatrix | kForceShaders);
465 } 478 }
466 479
467 TEST_F(LayerTreeHostBlendingPixelTest, 480 TEST_F(LayerTreeHostBlendingPixelTest,
481 BlendingWithRenderPassShadersWithMaskColorMatrix_GL_TextureRect) {
482 RunBlendingWithRenderPass(GL_ZERO_COPY_RECT_DRAW,
483 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
484 kUseMasks | kUseColorMatrix | kForceShaders);
485 }
486
487 TEST_F(LayerTreeHostBlendingPixelTest,
468 BlendingWithRenderPassShadersWithMaskColorMatrixAA_GL) { 488 BlendingWithRenderPassShadersWithMaskColorMatrixAA_GL) {
469 RunBlendingWithRenderPass( 489 RunBlendingWithRenderPass(
470 GL_ASYNC_UPLOAD_2D_DRAW, 490 GL_ASYNC_UPLOAD_2D_DRAW,
471 FILE_PATH_LITERAL("blending_render_pass_mask.png"), 491 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
472 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); 492 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders);
473 } 493 }
474 494
475 } // namespace 495 } // namespace
476 } // namespace cc 496 } // namespace cc
477 497
478 #endif // OS_ANDROID 498 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698