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

Side by Side Diff: cc/playback/display_item_list.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 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/playback/display_item_list.h ('k') | cc/playback/display_item_list_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/playback/display_item_list.h" 5 #include "cc/playback/display_item_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 26 matching lines...) Expand all
37 // operations. 37 // operations.
38 const int kOpCountThatIsOkToAnalyze = 10; 38 const int kOpCountThatIsOkToAnalyze = 10;
39 39
40 bool DisplayItemsTracingEnabled() { 40 bool DisplayItemsTracingEnabled() {
41 bool tracing_enabled; 41 bool tracing_enabled;
42 TRACE_EVENT_CATEGORY_GROUP_ENABLED( 42 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
43 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled); 43 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled);
44 return tracing_enabled; 44 return tracing_enabled;
45 } 45 }
46 46
47 bool GetCanvasClipBounds(SkCanvas* canvas, gfx::Rect* clip_bounds) { 47 bool GetCanvasClipBounds(CdlCanvas* canvas, gfx::Rect* clip_bounds) {
48 SkRect canvas_clip_bounds; 48 SkRect canvas_clip_bounds;
49 if (!canvas->getClipBounds(&canvas_clip_bounds)) 49 if (!canvas->getClipBounds(&canvas_clip_bounds))
50 return false; 50 return false;
51 *clip_bounds = ToEnclosingRect(gfx::SkRectToRectF(canvas_clip_bounds)); 51 *clip_bounds = ToEnclosingRect(gfx::SkRectToRectF(canvas_clip_bounds));
52 return true; 52 return true;
53 } 53 }
54 54
55 const int kDefaultNumDisplayItemsToReserve = 100; 55 const int kDefaultNumDisplayItemsToReserve = 100;
56 56
57 } // namespace 57 } // namespace
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 DCHECK(inputs_.items.size() == inputs_.visual_rects.size()) 104 DCHECK(inputs_.items.size() == inputs_.visual_rects.size())
105 << "items.size() " << inputs_.items.size() << " visual_rects.size() " 105 << "items.size() " << inputs_.items.size() << " visual_rects.size() "
106 << inputs_.visual_rects.size(); 106 << inputs_.visual_rects.size();
107 int i = 0; 107 int i = 0;
108 for (const auto& item : inputs_.items) { 108 for (const auto& item : inputs_.items) {
109 RectToProto(inputs_.visual_rects[i++], proto->add_visual_rects()); 109 RectToProto(inputs_.visual_rects[i++], proto->add_visual_rects());
110 item.ToProtobuf(proto->add_items()); 110 item.ToProtobuf(proto->add_items());
111 } 111 }
112 } 112 }
113 113
114 void DisplayItemList::Raster(SkCanvas* canvas, 114 void DisplayItemList::Raster(CdlCanvas* canvas,
115 SkPicture::AbortCallback* callback, 115 SkPicture::AbortCallback* callback,
116 const gfx::Rect& canvas_target_playback_rect, 116 const gfx::Rect& canvas_target_playback_rect,
117 float contents_scale) const { 117 float contents_scale) const {
118 canvas->save(); 118 canvas->save();
119 if (!canvas_target_playback_rect.IsEmpty()) { 119 if (!canvas_target_playback_rect.IsEmpty()) {
120 // canvas_target_playback_rect is specified in device space. We can't 120 // canvas_target_playback_rect is specified in device space. We can't
121 // use clipRect because canvas CTM will be applied on it. Use clipRegion 121 // use clipRect because canvas CTM will be applied on it. Use clipRegion
122 // instead because it ignores canvas CTM. 122 // instead because it ignores canvas CTM.
123 SkRegion device_clip; 123 SkRegion device_clip;
124 device_clip.setRect(gfx::RectToSkIRect(canvas_target_playback_rect)); 124 device_clip.setRect(gfx::RectToSkIRect(canvas_target_playback_rect));
125 canvas->clipRegion(device_clip); 125 canvas->clipRegion(device_clip);
126 } 126 }
127 canvas->scale(contents_scale, contents_scale); 127 canvas->scale(contents_scale, contents_scale);
128 Raster(canvas, callback); 128 Raster(canvas, callback);
129 canvas->restore(); 129 canvas->restore();
130 } 130 }
131 131
132 DISABLE_CFI_PERF 132 DISABLE_CFI_PERF
133 void DisplayItemList::Raster(SkCanvas* canvas, 133 void DisplayItemList::Raster(CdlCanvas* canvas,
134 SkPicture::AbortCallback* callback) const { 134 SkPicture::AbortCallback* callback) const {
135 gfx::Rect canvas_playback_rect; 135 gfx::Rect canvas_playback_rect;
136 if (!GetCanvasClipBounds(canvas, &canvas_playback_rect)) 136 if (!GetCanvasClipBounds(canvas, &canvas_playback_rect))
137 return; 137 return;
138 138
139 std::vector<size_t> indices; 139 std::vector<size_t> indices;
140 rtree_.Search(canvas_playback_rect, &indices); 140 rtree_.Search(canvas_playback_rect, &indices);
141 for (size_t index : indices) { 141 for (size_t index : indices) {
142 inputs_.items[index].Raster(canvas, callback); 142 inputs_.items[index].Raster(canvas, callback);
143 // We use a callback during solid color analysis on the compositor thread to 143 // We use a callback during solid color analysis on the compositor thread to
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 state.get()); 224 state.get());
225 item_index++; 225 item_index++;
226 } 226 }
227 state->EndArray(); // "items". 227 state->EndArray(); // "items".
228 } 228 }
229 state->SetValue("layer_rect", MathUtil::AsValue(rtree_.GetBounds())); 229 state->SetValue("layer_rect", MathUtil::AsValue(rtree_.GetBounds()));
230 state->EndDictionary(); // "params". 230 state->EndDictionary(); // "params".
231 231
232 SkPictureRecorder recorder; 232 SkPictureRecorder recorder;
233 gfx::Rect bounds = rtree_.GetBounds(); 233 gfx::Rect bounds = rtree_.GetBounds();
234 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); 234 SkCanvas* sk_canvas =
235 canvas->translate(-bounds.x(), -bounds.y()); 235 recorder.beginRecording(bounds.width(), bounds.height());
236 canvas->clipRect(gfx::RectToSkRect(bounds)); 236 CdlPassThroughCanvas canvas(sk_canvas);
237 Raster(canvas, nullptr, gfx::Rect(), 1.f); 237 canvas.translate(-bounds.x(), -bounds.y());
238 canvas.clipRect(gfx::RectToSkRect(bounds));
239 Raster(&canvas, nullptr, gfx::Rect(), 1.f);
238 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); 240 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
239 241
240 std::string b64_picture; 242 std::string b64_picture;
241 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); 243 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture);
242 state->SetString("skp64", b64_picture); 244 state->SetString("skp64", b64_picture);
243 245
244 return std::move(state); 246 return std::move(state);
245 } 247 }
246 248
247 void DisplayItemList::EmitTraceSnapshot() const { 249 void DisplayItemList::EmitTraceSnapshot() const {
(...skipping 17 matching lines...) Expand all
265 } 267 }
266 268
267 void DisplayItemList::GetDiscardableImagesInRect( 269 void DisplayItemList::GetDiscardableImagesInRect(
268 const gfx::Rect& rect, 270 const gfx::Rect& rect,
269 const gfx::SizeF& raster_scales, 271 const gfx::SizeF& raster_scales,
270 std::vector<DrawImage>* images) { 272 std::vector<DrawImage>* images) {
271 image_map_.GetDiscardableImagesInRect(rect, raster_scales, images); 273 image_map_.GetDiscardableImagesInRect(rect, raster_scales, images);
272 } 274 }
273 275
274 } // namespace cc 276 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/display_item_list.h ('k') | cc/playback/display_item_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698