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

Side by Side Diff: cc/test/fake_content_layer_client.cc

Issue 1489713004: Remove the clip parameter from ContentLayerClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clipremoval
Patch Set: Created 5 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/test/fake_content_layer_client.h ('k') | cc/test/solid_color_content_layer_client.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/test/fake_content_layer_client.h" 5 #include "cc/test/fake_content_layer_client.h"
6 6
7 #include "cc/playback/clip_display_item.h" 7 #include "cc/playback/clip_display_item.h"
8 #include "cc/playback/display_item_list_settings.h" 8 #include "cc/playback/display_item_list_settings.h"
9 #include "cc/playback/drawing_display_item.h" 9 #include "cc/playback/drawing_display_item.h"
10 #include "cc/playback/transform_display_item.h" 10 #include "cc/playback/transform_display_item.h"
(...skipping 25 matching lines...) Expand all
36 FakeContentLayerClient::~FakeContentLayerClient() { 36 FakeContentLayerClient::~FakeContentLayerClient() {
37 } 37 }
38 38
39 gfx::Rect FakeContentLayerClient::PaintableRegion() { 39 gfx::Rect FakeContentLayerClient::PaintableRegion() {
40 CHECK(bounds_set_); 40 CHECK(bounds_set_);
41 return gfx::Rect(bounds_); 41 return gfx::Rect(bounds_);
42 } 42 }
43 43
44 scoped_refptr<DisplayItemList> 44 scoped_refptr<DisplayItemList>
45 FakeContentLayerClient::PaintContentsToDisplayList( 45 FakeContentLayerClient::PaintContentsToDisplayList(
46 const gfx::Rect& clip,
47 PaintingControlSetting painting_control) { 46 PaintingControlSetting painting_control) {
48 // Cached picture is used because unit tests expect to be able to 47 // Cached picture is used because unit tests expect to be able to
49 // use GatherPixelRefs. 48 // use GatherPixelRefs.
50 DisplayItemListSettings settings; 49 DisplayItemListSettings settings;
51 settings.use_cached_picture = true; 50 settings.use_cached_picture = true;
52 scoped_refptr<DisplayItemList> display_list = 51 scoped_refptr<DisplayItemList> display_list =
53 DisplayItemList::Create(clip, settings); 52 DisplayItemList::Create(PaintableRegion(), settings);
54 SkPictureRecorder recorder; 53 SkPictureRecorder recorder;
55 skia::RefPtr<SkCanvas> canvas; 54 skia::RefPtr<SkCanvas> canvas;
56 skia::RefPtr<SkPicture> picture; 55 skia::RefPtr<SkPicture> picture;
57 auto* item = display_list->CreateAndAppendItem<ClipDisplayItem>(clip);
58 item->SetNew(clip, std::vector<SkRRect>());
59 56
60 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 57 for (RectPaintVector::const_iterator it = draw_rects_.begin();
61 it != draw_rects_.end(); ++it) { 58 it != draw_rects_.end(); ++it) {
62 const gfx::RectF& draw_rect = it->first; 59 const gfx::RectF& draw_rect = it->first;
63 const SkPaint& paint = it->second; 60 const SkPaint& paint = it->second;
64 canvas = 61 canvas =
65 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); 62 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
66 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 63 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
67 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 64 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
68 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( 65 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(
69 ToEnclosingRect(draw_rect)); 66 ToEnclosingRect(draw_rect));
70 item->SetNew(std::move(picture)); 67 item->SetNew(std::move(picture));
71 } 68 }
72 69
73 for (ImageVector::const_iterator it = draw_images_.begin(); 70 for (ImageVector::const_iterator it = draw_images_.begin();
74 it != draw_images_.end(); ++it) { 71 it != draw_images_.end(); ++it) {
75 if (!it->transform.IsIdentity()) { 72 if (!it->transform.IsIdentity()) {
76 auto* item = 73 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>(
77 display_list->CreateAndAppendItem<TransformDisplayItem>(clip); 74 PaintableRegion());
78 item->SetNew(it->transform); 75 item->SetNew(it->transform);
79 } 76 }
80 canvas = skia::SharePtr( 77 canvas = skia::SharePtr(
81 recorder.beginRecording(it->image->width(), it->image->height())); 78 recorder.beginRecording(it->image->width(), it->image->height()));
82 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), 79 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(),
83 &it->paint); 80 &it->paint);
84 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 81 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
85 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(clip); 82 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(
83 PaintableRegion());
86 item->SetNew(std::move(picture)); 84 item->SetNew(std::move(picture));
87 if (!it->transform.IsIdentity()) { 85 if (!it->transform.IsIdentity()) {
88 display_list->CreateAndAppendItem<EndTransformDisplayItem>(clip); 86 display_list->CreateAndAppendItem<EndTransformDisplayItem>(
87 PaintableRegion());
89 } 88 }
90 } 89 }
91 90
92 if (fill_with_nonsolid_color_) { 91 if (fill_with_nonsolid_color_) {
93 gfx::Rect draw_rect = clip; 92 gfx::Rect draw_rect = PaintableRegion();
94 bool red = true; 93 bool red = true;
95 while (!draw_rect.IsEmpty()) { 94 while (!draw_rect.IsEmpty()) {
96 SkPaint paint; 95 SkPaint paint;
97 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); 96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
98 canvas = 97 canvas =
99 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); 98 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect)));
100 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); 99 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint);
101 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 100 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
102 auto* item = 101 auto* item =
103 display_list->CreateAndAppendItem<DrawingDisplayItem>(draw_rect); 102 display_list->CreateAndAppendItem<DrawingDisplayItem>(draw_rect);
104 item->SetNew(std::move(picture)); 103 item->SetNew(std::move(picture));
105 draw_rect.Inset(1, 1); 104 draw_rect.Inset(1, 1);
106 } 105 }
107 } 106 }
108 107
109 display_list->CreateAndAppendItem<EndClipDisplayItem>(clip);
110 108
111 display_list->Finalize(); 109 display_list->Finalize();
112 return display_list; 110 return display_list;
113 } 111 }
114 112
115 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 113 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
116 114
117 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { 115 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const {
118 return reported_memory_usage_; 116 return reported_memory_usage_;
119 } 117 }
120 118
121 } // namespace cc 119 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_content_layer_client.h ('k') | cc/test/solid_color_content_layer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698