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

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

Issue 1158553004: cc: Cull DrawingDisplayItems outside of the raster playback rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cull: . Created 5 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
« no previous file with comments | « cc/playback/display_item_list.h ('k') | cc/playback/display_list_raster_source.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 <string> 7 #include <string>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 gfx::Rect layer_rect, 87 gfx::Rect layer_rect,
88 const DisplayItemListSettings& settings) { 88 const DisplayItemListSettings& settings) {
89 return make_scoped_refptr(new DisplayItemList(layer_rect, settings)); 89 return make_scoped_refptr(new DisplayItemList(layer_rect, settings));
90 } 90 }
91 91
92 DisplayItemList::~DisplayItemList() { 92 DisplayItemList::~DisplayItemList() {
93 } 93 }
94 94
95 void DisplayItemList::Raster(SkCanvas* canvas, 95 void DisplayItemList::Raster(SkCanvas* canvas,
96 SkPicture::AbortCallback* callback, 96 SkPicture::AbortCallback* callback,
97 const gfx::Rect& canvas_target_playback_rect,
97 float contents_scale) const { 98 float contents_scale) const {
98 DCHECK(ProcessAppendedItemsCalled()); 99 DCHECK(ProcessAppendedItemsCalled());
99 if (!use_cached_picture_) { 100 if (!use_cached_picture_) {
100 canvas->save(); 101 canvas->save();
101 canvas->scale(contents_scale, contents_scale); 102 canvas->scale(contents_scale, contents_scale);
102 for (auto* item : items_) 103 for (auto* item : items_)
103 item->Raster(canvas, callback); 104 item->Raster(canvas, canvas_target_playback_rect, callback);
104 canvas->restore(); 105 canvas->restore();
105 } else { 106 } else {
106 DCHECK(picture_); 107 DCHECK(picture_);
107 108
108 canvas->save(); 109 canvas->save();
109 canvas->scale(contents_scale, contents_scale); 110 canvas->scale(contents_scale, contents_scale);
110 canvas->translate(layer_rect_.x(), layer_rect_.y()); 111 canvas->translate(layer_rect_.x(), layer_rect_.y());
111 if (callback) { 112 if (callback) {
112 // If we have a callback, we need to call |draw()|, |drawPicture()| 113 // If we have a callback, we need to call |draw()|, |drawPicture()|
113 // doesn't take a callback. This is used by |AnalysisCanvas| to early 114 // doesn't take a callback. This is used by |AnalysisCanvas| to early
(...skipping 24 matching lines...) Expand all
138 #if DCHECK_IS_ON() 139 #if DCHECK_IS_ON()
139 needs_process_ = false; 140 needs_process_ = false;
140 #endif 141 #endif
141 for (const DisplayItem* item : items_) { 142 for (const DisplayItem* item : items_) {
142 is_suitable_for_gpu_rasterization_ &= 143 is_suitable_for_gpu_rasterization_ &=
143 item->is_suitable_for_gpu_rasterization(); 144 item->is_suitable_for_gpu_rasterization();
144 approximate_op_count_ += item->approximate_op_count(); 145 approximate_op_count_ += item->approximate_op_count();
145 146
146 if (use_cached_picture_) { 147 if (use_cached_picture_) {
147 DCHECK(canvas_); 148 DCHECK(canvas_);
148 item->Raster(canvas_.get(), NULL); 149 item->Raster(canvas_.get(), gfx::Rect(), NULL);
149 } 150 }
150 151
151 if (retain_individual_display_items_) { 152 if (retain_individual_display_items_) {
152 // Warning: this double-counts SkPicture data if use_cached_picture_ is 153 // Warning: this double-counts SkPicture data if use_cached_picture_ is
153 // also true. 154 // also true.
154 picture_memory_usage_ += item->picture_memory_usage(); 155 picture_memory_usage_ += item->picture_memory_usage();
155 } 156 }
156 } 157 }
157 158
158 if (!retain_individual_display_items_) 159 if (!retain_individual_display_items_)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 212 }
212 state->EndArray(); 213 state->EndArray();
213 state->SetValue("params.layer_rect", MathUtil::AsValue(layer_rect_)); 214 state->SetValue("params.layer_rect", MathUtil::AsValue(layer_rect_));
214 215
215 if (!layer_rect_.IsEmpty()) { 216 if (!layer_rect_.IsEmpty()) {
216 SkPictureRecorder recorder; 217 SkPictureRecorder recorder;
217 SkCanvas* canvas = 218 SkCanvas* canvas =
218 recorder.beginRecording(layer_rect_.width(), layer_rect_.height()); 219 recorder.beginRecording(layer_rect_.width(), layer_rect_.height());
219 canvas->translate(-layer_rect_.x(), -layer_rect_.y()); 220 canvas->translate(-layer_rect_.x(), -layer_rect_.y());
220 canvas->clipRect(gfx::RectToSkRect(layer_rect_)); 221 canvas->clipRect(gfx::RectToSkRect(layer_rect_));
221 Raster(canvas, NULL, 1.f); 222 Raster(canvas, NULL, gfx::Rect(), 1.f);
222 skia::RefPtr<SkPicture> picture = 223 skia::RefPtr<SkPicture> picture =
223 skia::AdoptRef(recorder.endRecordingAsPicture()); 224 skia::AdoptRef(recorder.endRecordingAsPicture());
224 225
225 std::string b64_picture; 226 std::string b64_picture;
226 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); 227 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture);
227 state->SetString("skp64", b64_picture); 228 state->SetString("skp64", b64_picture);
228 } 229 }
229 230
230 return state; 231 return state;
231 } 232 }
(...skipping 16 matching lines...) Expand all
248 return; 249 return;
249 250
250 pixel_refs_->GatherPixelRefsFromPicture(picture_.get()); 251 pixel_refs_->GatherPixelRefsFromPicture(picture_.get());
251 } 252 }
252 253
253 void* DisplayItemList::GetSidecar(DisplayItem* display_item) { 254 void* DisplayItemList::GetSidecar(DisplayItem* display_item) {
254 return items_.GetSidecar(display_item); 255 return items_.GetSidecar(display_item);
255 } 256 }
256 257
257 } // namespace cc 258 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/display_item_list.h ('k') | cc/playback/display_list_raster_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698