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

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

Issue 315393002: Record SkPicture with correct LCD text setting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better unittest Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
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 "build/build_config.h" 5 #include "build/build_config.h"
6 #include "cc/layers/content_layer.h" 6 #include "cc/layers/content_layer.h"
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/image_layer.h" 8 #include "cc/layers/image_layer.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/test/layer_tree_pixel_test.h" 10 #include "cc/test/layer_tree_pixel_test.h"
11 #include "cc/test/pixel_comparator.h" 11 #include "cc/test/pixel_comparator.h"
12 12
13 #if !defined(OS_ANDROID) 13 #if !defined(OS_ANDROID)
14 14
15 namespace cc { 15 namespace cc {
16 namespace { 16 namespace {
17 17
18 class LayerTreeHostMasksPixelTest : public LayerTreePixelTest {}; 18 class LayerTreeHostMasksPixelTest : public LayerTreePixelTest {};
19 19
20 class MaskContentLayerClient : public ContentLayerClient { 20 class MaskContentLayerClient : public ContentLayerClient {
21 public: 21 public:
22 MaskContentLayerClient() {} 22 MaskContentLayerClient() {}
23 virtual ~MaskContentLayerClient() {} 23 virtual ~MaskContentLayerClient() {}
24 24
25 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} 25 virtual bool PaintsLCDText() const OVERRIDE { return false; }
26 26
27 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } 27 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
28 28
29 virtual void PaintContents( 29 virtual void PaintContents(
30 SkCanvas* canvas, 30 SkCanvas* canvas,
31 const gfx::Rect& rect, 31 const gfx::Rect& rect,
32 bool can_paint_lcd_text,
32 gfx::RectF* opaque_rect, 33 gfx::RectF* opaque_rect,
33 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE { 34 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE {
34 SkPaint paint; 35 SkPaint paint;
35 paint.setStyle(SkPaint::kStroke_Style); 36 paint.setStyle(SkPaint::kStroke_Style);
36 paint.setStrokeWidth(SkIntToScalar(2)); 37 paint.setStrokeWidth(SkIntToScalar(2));
37 paint.setColor(SK_ColorWHITE); 38 paint.setColor(SK_ColorWHITE);
38 39
39 canvas->clear(SK_ColorTRANSPARENT); 40 canvas->clear(SK_ColorTRANSPARENT);
40 gfx::Rect inset_rect(rect); 41 gfx::Rect inset_rect(rect);
41 while (!inset_rect.IsEmpty()) { 42 while (!inset_rect.IsEmpty()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 mask->SetIsMask(true); 80 mask->SetIsMask(true);
80 mask->SetBounds(gfx::Size(100, 100)); 81 mask->SetBounds(gfx::Size(100, 100));
81 82
82 SkBitmap bitmap; 83 SkBitmap bitmap;
83 bitmap.allocN32Pixels(400, 400); 84 bitmap.allocN32Pixels(400, 400);
84 SkCanvas canvas(bitmap); 85 SkCanvas canvas(bitmap);
85 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); 86 canvas.scale(SkIntToScalar(4), SkIntToScalar(4));
86 MaskContentLayerClient client; 87 MaskContentLayerClient client;
87 client.PaintContents(&canvas, 88 client.PaintContents(&canvas,
88 gfx::Rect(100, 100), 89 gfx::Rect(100, 100),
90 false,
89 NULL, 91 NULL,
90 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); 92 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
91 mask->SetBitmap(bitmap); 93 mask->SetBitmap(bitmap);
92 94
93 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 95 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
94 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 96 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
95 green->SetMaskLayer(mask.get()); 97 green->SetMaskLayer(mask.get());
96 background->AddChild(green); 98 background->AddChild(green);
97 99
98 this->impl_side_painting_ = false; 100 this->impl_side_painting_ = false;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 RunPixelTest(GL_WITH_BITMAP, 275 RunPixelTest(GL_WITH_BITMAP,
274 background, 276 background,
275 base::FilePath(FILE_PATH_LITERAL( 277 base::FilePath(FILE_PATH_LITERAL(
276 "mask_of_replica_of_clipped_layer.png"))); 278 "mask_of_replica_of_clipped_layer.png")));
277 } 279 }
278 280
279 } // namespace 281 } // namespace
280 } // namespace cc 282 } // namespace cc
281 283
282 #endif // OS_ANDROID 284 #endif // OS_ANDROID
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698