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

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

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
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_client.h" 6 #include "cc/layers/content_layer_client.h"
7 #include "cc/layers/picture_image_layer.h" 7 #include "cc/layers/picture_image_layer.h"
8 #include "cc/layers/picture_layer.h" 8 #include "cc/layers/picture_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_resource_test.h" 10 #include "cc/test/layer_tree_pixel_resource_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 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest; 18 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest;
19 19
20 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest); 20 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest);
21 21
22 class MaskContentLayerClient : public ContentLayerClient { 22 class MaskContentLayerClient : public ContentLayerClient {
23 public: 23 public:
24 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} 24 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {}
25 ~MaskContentLayerClient() override {} 25 ~MaskContentLayerClient() override {}
26 26
27 bool FillsBoundsCompletely() const override { return false; } 27 bool FillsBoundsCompletely() const override { return false; }
28 28
29 void PaintContents( 29 void PaintContents(SkCanvas* canvas,
30 SkCanvas* canvas, 30 const gfx::Rect& rect,
31 const gfx::Rect& rect, 31 PaintingControlSetting picture_control) override {
32 ContentLayerClient::GraphicsContextStatus gc_status) override {
33 SkPaint paint; 32 SkPaint paint;
34 paint.setStyle(SkPaint::kStroke_Style); 33 paint.setStyle(SkPaint::kStroke_Style);
35 paint.setStrokeWidth(SkIntToScalar(2)); 34 paint.setStrokeWidth(SkIntToScalar(2));
36 paint.setColor(SK_ColorWHITE); 35 paint.setColor(SK_ColorWHITE);
37 36
38 canvas->clear(SK_ColorTRANSPARENT); 37 canvas->clear(SK_ColorTRANSPARENT);
39 gfx::Rect inset_rect(bounds_); 38 gfx::Rect inset_rect(bounds_);
40 while (!inset_rect.IsEmpty()) { 39 while (!inset_rect.IsEmpty()) {
41 inset_rect.Inset(3, 3, 2, 2); 40 inset_rect.Inset(3, 3, 2, 2);
42 canvas->drawRect( 41 canvas->drawRect(
43 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), 42 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(),
44 inset_rect.width(), inset_rect.height()), 43 inset_rect.width(), inset_rect.height()),
45 paint); 44 paint);
46 inset_rect.Inset(3, 3, 2, 2); 45 inset_rect.Inset(3, 3, 2, 2);
47 } 46 }
48 } 47 }
49 48
50 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 49 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
51 const gfx::Rect& clip, 50 const gfx::Rect& clip,
52 GraphicsContextStatus gc_status) override { 51 PaintingControlSetting picture_control) override {
53 NOTIMPLEMENTED(); 52 NOTIMPLEMENTED();
54 return DisplayItemList::Create(); 53 return DisplayItemList::Create();
55 } 54 }
56 55
57 private: 56 private:
58 gfx::Size bounds_; 57 gfx::Size bounds_;
59 }; 58 };
60 59
61 // TODO(enne): these time out on Windows. http://crbug.com/435632 60 // TODO(enne): these time out on Windows. http://crbug.com/435632
62 #if !defined(OS_WIN) 61 #if !defined(OS_WIN)
(...skipping 27 matching lines...) Expand all
90 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); 89 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
91 mask->SetIsDrawable(true); 90 mask->SetIsDrawable(true);
92 mask->SetIsMask(true); 91 mask->SetIsMask(true);
93 mask->SetBounds(mask_bounds); 92 mask->SetBounds(mask_bounds);
94 93
95 SkBitmap bitmap; 94 SkBitmap bitmap;
96 bitmap.allocN32Pixels(400, 400); 95 bitmap.allocN32Pixels(400, 400);
97 SkCanvas canvas(bitmap); 96 SkCanvas canvas(bitmap);
98 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); 97 canvas.scale(SkIntToScalar(4), SkIntToScalar(4));
99 MaskContentLayerClient client(mask_bounds); 98 MaskContentLayerClient client(mask_bounds);
100 client.PaintContents(&canvas, 99 client.PaintContents(&canvas, gfx::Rect(mask_bounds),
101 gfx::Rect(mask_bounds), 100 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
102 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
103 mask->SetBitmap(bitmap); 101 mask->SetBitmap(bitmap);
104 102
105 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 103 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
106 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 104 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
107 green->SetMaskLayer(mask.get()); 105 green->SetMaskLayer(mask.get());
108 background->AddChild(green); 106 background->AddChild(green);
109 107
110 RunPixelResourceTest( 108 RunPixelResourceTest(
111 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); 109 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png")));
112 } 110 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 base::FilePath(FILE_PATH_LITERAL( 279 base::FilePath(FILE_PATH_LITERAL(
282 "mask_of_replica_of_clipped_layer.png"))); 280 "mask_of_replica_of_clipped_layer.png")));
283 } 281 }
284 282
285 #endif // !defined(OS_WIN) 283 #endif // !defined(OS_WIN)
286 284
287 } // namespace 285 } // namespace
288 } // namespace cc 286 } // namespace cc
289 287
290 #endif // OS_ANDROID 288 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698