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

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

Issue 2889653002: Remove cullRect() from PaintOpBuffer. (Closed)
Patch Set: movecullrect2 rebase-once-and-for-all Created 3 years, 7 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 <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 24 matching lines...) Expand all
35 35
36 bool FillsBoundsCompletely() const override { return false; } 36 bool FillsBoundsCompletely() const override { return false; }
37 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } 37 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
38 38
39 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } 39 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); }
40 40
41 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 41 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
42 PaintingControlSetting picture_control) override { 42 PaintingControlSetting picture_control) override {
43 PaintRecorder recorder; 43 PaintRecorder recorder;
44 PaintCanvas* canvas = 44 PaintCanvas* canvas =
45 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); 45 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion()));
46 46
47 PaintFlags flags; 47 PaintFlags flags;
48 flags.setStyle(PaintFlags::kStroke_Style); 48 flags.setStyle(PaintFlags::kStroke_Style);
49 flags.setStrokeWidth(SkIntToScalar(2)); 49 flags.setStrokeWidth(SkIntToScalar(2));
50 flags.setColor(SK_ColorWHITE); 50 flags.setColor(SK_ColorWHITE);
51 51
52 canvas->clear(SK_ColorTRANSPARENT); 52 canvas->clear(SK_ColorTRANSPARENT);
53 gfx::Rect inset_rect(bounds_); 53 gfx::Rect inset_rect(bounds_);
54 while (!inset_rect.IsEmpty()) { 54 while (!inset_rect.IsEmpty()) {
55 inset_rect.Inset(3, 3, 2, 2); 55 inset_rect.Inset(3, 3, 2, 2);
56 canvas->drawRect( 56 canvas->drawRect(
57 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), inset_rect.width(), 57 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), inset_rect.width(),
58 inset_rect.height()), 58 inset_rect.height()),
59 flags); 59 flags);
60 inset_rect.Inset(3, 3, 2, 2); 60 inset_rect.Inset(3, 3, 2, 2);
61 } 61 }
62 62
63 auto display_list = make_scoped_refptr(new DisplayItemList); 63 auto display_list = make_scoped_refptr(new DisplayItemList);
64 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 64 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
65 PaintableRegion(), recorder.finishRecordingAsPicture()); 65 PaintableRegion(), recorder.finishRecordingAsPicture(),
66 gfx::RectToSkRect(PaintableRegion()));
66 67
67 display_list->Finalize(); 68 display_list->Finalize();
68 return display_list; 69 return display_list;
69 } 70 }
70 71
71 private: 72 private:
72 gfx::Size bounds_; 73 gfx::Size bounds_;
73 }; 74 };
74 75
75 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { 76 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool vertical) 216 bool vertical)
216 : bounds_(bounds), color_(color), vertical_(vertical) {} 217 : bounds_(bounds), color_(color), vertical_(vertical) {}
217 ~CheckerContentLayerClient() override {} 218 ~CheckerContentLayerClient() override {}
218 bool FillsBoundsCompletely() const override { return false; } 219 bool FillsBoundsCompletely() const override { return false; }
219 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } 220 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
220 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } 221 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); }
221 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 222 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
222 PaintingControlSetting picture_control) override { 223 PaintingControlSetting picture_control) override {
223 PaintRecorder recorder; 224 PaintRecorder recorder;
224 PaintCanvas* canvas = 225 PaintCanvas* canvas =
225 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); 226 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion()));
226 227
227 PaintFlags flags; 228 PaintFlags flags;
228 flags.setStyle(PaintFlags::kStroke_Style); 229 flags.setStyle(PaintFlags::kStroke_Style);
229 flags.setStrokeWidth(SkIntToScalar(4)); 230 flags.setStrokeWidth(SkIntToScalar(4));
230 flags.setColor(color_); 231 flags.setColor(color_);
231 canvas->clear(SK_ColorTRANSPARENT); 232 canvas->clear(SK_ColorTRANSPARENT);
232 if (vertical_) { 233 if (vertical_) {
233 for (int i = 4; i < bounds_.width(); i += 16) { 234 for (int i = 4; i < bounds_.width(); i += 16) {
234 canvas->drawLine(i, 0, i, bounds_.height(), flags); 235 canvas->drawLine(i, 0, i, bounds_.height(), flags);
235 } 236 }
236 } else { 237 } else {
237 for (int i = 4; i < bounds_.height(); i += 16) { 238 for (int i = 4; i < bounds_.height(); i += 16) {
238 canvas->drawLine(0, i, bounds_.width(), i, flags); 239 canvas->drawLine(0, i, bounds_.width(), i, flags);
239 } 240 }
240 } 241 }
241 242
242 auto display_list = make_scoped_refptr(new DisplayItemList); 243 auto display_list = make_scoped_refptr(new DisplayItemList);
243 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 244 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
244 PaintableRegion(), recorder.finishRecordingAsPicture()); 245 PaintableRegion(), recorder.finishRecordingAsPicture(),
246 gfx::RectToSkRect(PaintableRegion()));
245 247
246 display_list->Finalize(); 248 display_list->Finalize();
247 return display_list; 249 return display_list;
248 } 250 }
249 251
250 private: 252 private:
251 gfx::Size bounds_; 253 gfx::Size bounds_;
252 SkColor color_; 254 SkColor color_;
253 bool vertical_; 255 bool vertical_;
254 }; 256 };
255 257
256 class CircleContentLayerClient : public ContentLayerClient { 258 class CircleContentLayerClient : public ContentLayerClient {
257 public: 259 public:
258 explicit CircleContentLayerClient(const gfx::Size& bounds) 260 explicit CircleContentLayerClient(const gfx::Size& bounds)
259 : bounds_(bounds) {} 261 : bounds_(bounds) {}
260 ~CircleContentLayerClient() override {} 262 ~CircleContentLayerClient() override {}
261 bool FillsBoundsCompletely() const override { return false; } 263 bool FillsBoundsCompletely() const override { return false; }
262 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } 264 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
263 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } 265 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); }
264 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 266 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
265 PaintingControlSetting picture_control) override { 267 PaintingControlSetting picture_control) override {
266 PaintRecorder recorder; 268 PaintRecorder recorder;
267 PaintCanvas* canvas = 269 PaintCanvas* canvas =
268 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); 270 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion()));
269 271
270 PaintFlags flags; 272 PaintFlags flags;
271 flags.setStyle(PaintFlags::kFill_Style); 273 flags.setStyle(PaintFlags::kFill_Style);
272 flags.setColor(SK_ColorWHITE); 274 flags.setColor(SK_ColorWHITE);
273 canvas->clear(SK_ColorTRANSPARENT); 275 canvas->clear(SK_ColorTRANSPARENT);
274 canvas->drawCircle(bounds_.width() / 2, bounds_.height() / 2, 276 canvas->drawCircle(bounds_.width() / 2, bounds_.height() / 2,
275 bounds_.width() / 4, flags); 277 bounds_.width() / 4, flags);
276 278
277 auto display_list = make_scoped_refptr(new DisplayItemList); 279 auto display_list = make_scoped_refptr(new DisplayItemList);
278 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 280 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
279 PaintableRegion(), recorder.finishRecordingAsPicture()); 281 PaintableRegion(), recorder.finishRecordingAsPicture(),
282 gfx::RectToSkRect(PaintableRegion()));
280 283
281 display_list->Finalize(); 284 display_list->Finalize();
282 return display_list; 285 return display_list;
283 } 286 }
284 287
285 private: 288 private:
286 gfx::Size bounds_; 289 gfx::Size bounds_;
287 }; 290 };
288 291
289 using LayerTreeHostMasksForBackgroundFiltersPixelTest = 292 using LayerTreeHostMasksForBackgroundFiltersPixelTest =
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 401
399 RunPixelResourceTest(background, 402 RunPixelResourceTest(background,
400 base::FilePath( 403 base::FilePath(
401 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); 404 FILE_PATH_LITERAL("mask_of_layer_with_blend.png")));
402 } 405 }
403 406
404 } // namespace 407 } // namespace
405 } // namespace cc 408 } // namespace cc
406 409
407 #endif // !defined(OS_ANDROID) 410 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « cc/test/solid_color_content_layer_client.cc ('k') | cc/trees/layer_tree_host_pixeltest_tiles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698