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

Side by Side Diff: cc/resources/picture_pile_impl.cc

Issue 63443003: cc: Combine analysis and raster (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 7 years, 1 month 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 | Annotate | Revision Log
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 <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 7
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/base/region.h" 9 #include "cc/base/region.h"
10 #include "cc/debug/debug_colors.h" 10 #include "cc/debug/debug_colors.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 CHECK_GT(clones_for_drawing_.clones_.size(), thread_index); 67 CHECK_GT(clones_for_drawing_.clones_.size(), thread_index);
68 return clones_for_drawing_.clones_[thread_index].get(); 68 return clones_for_drawing_.clones_[thread_index].get();
69 } 69 }
70 70
71 void PicturePileImpl::RasterDirect( 71 void PicturePileImpl::RasterDirect(
72 SkCanvas* canvas, 72 SkCanvas* canvas,
73 gfx::Rect canvas_rect, 73 gfx::Rect canvas_rect,
74 float contents_scale, 74 float contents_scale,
75 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 75 RenderingStatsInstrumentation* rendering_stats_instrumentation) {
76 RasterCommon(canvas, 76 RasterCommon(canvas,
77 NULL,
78 canvas_rect, 77 canvas_rect,
79 contents_scale, 78 contents_scale,
80 rendering_stats_instrumentation); 79 rendering_stats_instrumentation);
81 } 80 }
82 81
83 void PicturePileImpl::RasterForAnalysis(
84 skia::AnalysisCanvas* canvas,
85 gfx::Rect canvas_rect,
86 float contents_scale) {
87 RasterCommon(canvas, canvas, canvas_rect, contents_scale, NULL);
88 }
89
90 void PicturePileImpl::RasterToBitmap( 82 void PicturePileImpl::RasterToBitmap(
91 SkCanvas* canvas, 83 SkCanvas* canvas,
92 gfx::Rect canvas_rect, 84 gfx::Rect canvas_rect,
93 float contents_scale, 85 float contents_scale,
94 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 86 RenderingStatsInstrumentation* rendering_stats_instrumentation) {
95 if (clear_canvas_with_debug_color_) { 87 if (clear_canvas_with_debug_color_) {
96 // Any non-painted areas will be left in this color. 88 // Any non-painted areas will be left in this color.
97 canvas->clear(DebugColors::NonPaintedFillColor()); 89 canvas->clear(DebugColors::NonPaintedFillColor());
98 } 90 }
99 91
(...skipping 28 matching lines...) Expand all
128 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), 120 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect),
129 SkRegion::kReplace_Op); 121 SkRegion::kReplace_Op);
130 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), 122 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
131 SkRegion::kDifference_Op); 123 SkRegion::kDifference_Op);
132 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); 124 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
133 canvas->restore(); 125 canvas->restore();
134 } 126 }
135 } 127 }
136 128
137 RasterCommon(canvas, 129 RasterCommon(canvas,
138 NULL,
139 canvas_rect, 130 canvas_rect,
140 contents_scale, 131 contents_scale,
141 rendering_stats_instrumentation); 132 rendering_stats_instrumentation);
142 } 133 }
143 134
144 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect, 135 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect,
145 gfx::Rect content_rect, 136 gfx::Rect content_rect,
146 float contents_scale, 137 float contents_scale,
147 PictureRegionMap* results) { 138 PictureRegionMap* results) {
148 DCHECK(results); 139 DCHECK(results);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 continue; 185 continue;
195 } 186 }
196 187
197 Region& region = it->second; 188 Region& region = it->second;
198 region.Subtract(content_clip); 189 region.Subtract(content_clip);
199 } 190 }
200 } 191 }
201 192
202 void PicturePileImpl::RasterCommon( 193 void PicturePileImpl::RasterCommon(
203 SkCanvas* canvas, 194 SkCanvas* canvas,
204 SkDrawPictureCallback* callback,
205 gfx::Rect canvas_rect, 195 gfx::Rect canvas_rect,
206 float contents_scale, 196 float contents_scale,
207 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 197 RenderingStatsInstrumentation* rendering_stats_instrumentation) {
208 DCHECK(contents_scale >= min_contents_scale_); 198 DCHECK(contents_scale >= min_contents_scale_);
209 199
210 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); 200 canvas->translate(-canvas_rect.x(), -canvas_rect.y());
211 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), 201 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
212 contents_scale); 202 contents_scale);
213 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); 203 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size));
214 gfx::Rect content_rect = total_content_rect; 204 gfx::Rect content_rect = total_content_rect;
(...skipping 28 matching lines...) Expand all
243 base::TimeDelta::FromInternalValue(std::numeric_limits<int64>::max()); 233 base::TimeDelta::FromInternalValue(std::numeric_limits<int64>::max());
244 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); 234 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_);
245 int rasterized_pixel_count = 0; 235 int rasterized_pixel_count = 0;
246 236
247 for (int j = 0; j < repeat_count; ++j) { 237 for (int j = 0; j < repeat_count; ++j) {
248 base::TimeTicks start_time; 238 base::TimeTicks start_time;
249 if (rendering_stats_instrumentation) 239 if (rendering_stats_instrumentation)
250 start_time = rendering_stats_instrumentation->StartRecording(); 240 start_time = rendering_stats_instrumentation->StartRecording();
251 241
252 rasterized_pixel_count = picture->Raster( 242 rasterized_pixel_count = picture->Raster(
253 canvas, callback, negated_clip_region, contents_scale); 243 canvas, negated_clip_region, contents_scale);
254 244
255 if (rendering_stats_instrumentation) { 245 if (rendering_stats_instrumentation) {
256 base::TimeDelta duration = 246 base::TimeDelta duration =
257 rendering_stats_instrumentation->EndRecording(start_time); 247 rendering_stats_instrumentation->EndRecording(start_time);
258 best_duration = std::min(best_duration, duration); 248 best_duration = std::min(best_duration, duration);
259 } 249 }
260 } 250 }
261 251
262 if (rendering_stats_instrumentation) { 252 if (rendering_stats_instrumentation) {
263 rendering_stats_instrumentation->AddRaster(best_duration, 253 rendering_stats_instrumentation->AddRaster(best_duration,
(...skipping 26 matching lines...) Expand all
290 layer_rect.width(), 280 layer_rect.width(),
291 layer_rect.height(), 281 layer_rect.height(),
292 SkPicture::kUsePathBoundsForClip_RecordingFlag); 282 SkPicture::kUsePathBoundsForClip_RecordingFlag);
293 283
294 RasterToBitmap(canvas, layer_rect, 1.0, NULL); 284 RasterToBitmap(canvas, layer_rect, 1.0, NULL);
295 picture->endRecording(); 285 picture->endRecording();
296 286
297 return picture; 287 return picture;
298 } 288 }
299 289
300 void PicturePileImpl::AnalyzeInRect(gfx::Rect content_rect,
301 float contents_scale,
302 PicturePileImpl::Analysis* analysis) {
303 DCHECK(analysis);
304 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect");
305
306 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
307 content_rect, 1.0f / contents_scale);
308
309 layer_rect.Intersect(gfx::Rect(tiling_.total_size()));
310
311 SkBitmap empty_bitmap;
312 empty_bitmap.setConfig(SkBitmap::kNo_Config,
313 layer_rect.width(),
314 layer_rect.height());
315 skia::AnalysisDevice device(empty_bitmap);
316 skia::AnalysisCanvas canvas(&device);
317
318 RasterForAnalysis(&canvas, layer_rect, 1.0f);
319
320 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color);
321 analysis->has_text = canvas.HasText();
322 }
323
324 PicturePileImpl::Analysis::Analysis() 290 PicturePileImpl::Analysis::Analysis()
325 : is_solid_color(false), 291 : is_solid_color(false),
326 has_text(false) { 292 has_text(false) {
327 } 293 }
328 294
329 PicturePileImpl::Analysis::~Analysis() { 295 PicturePileImpl::Analysis::~Analysis() {
330 } 296 }
331 297
332 PicturePileImpl::PixelRefIterator::PixelRefIterator( 298 PicturePileImpl::PixelRefIterator::PixelRefIterator(
333 gfx::Rect content_rect, 299 gfx::Rect content_rect,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (!picture || (processed_pictures_.count(picture) != 0)) 335 if (!picture || (processed_pictures_.count(picture) != 0))
370 continue; 336 continue;
371 337
372 processed_pictures_.insert(picture); 338 processed_pictures_.insert(picture);
373 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); 339 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture);
374 if (pixel_ref_iterator_) 340 if (pixel_ref_iterator_)
375 break; 341 break;
376 } 342 }
377 } 343 }
378 344
345 gfx::Rect PicturePileImpl::AnalysisRectForRaster(gfx::Rect content_rect,
346 float contents_scale) const {
347 // Bound the analysis rect to just the pile content.
348 gfx::Rect content_bounds(
349 gfx::ScaleToEnclosingRect(gfx::Rect(size()), contents_scale));
350 gfx::Rect analysis_rect(content_rect);
351 analysis_rect.Intersect(content_bounds);
352 // Move to canvas space.
353 analysis_rect.set_origin(gfx::Point());
354
355 return analysis_rect;
356 }
357
379 void PicturePileImpl::DidBeginTracing() { 358 void PicturePileImpl::DidBeginTracing() {
380 gfx::Rect layer_rect(tiling_.total_size()); 359 gfx::Rect layer_rect(tiling_.total_size());
381 std::set<void*> processed_pictures; 360 std::set<void*> processed_pictures;
382 for (PictureMap::iterator it = picture_map_.begin(); 361 for (PictureMap::iterator it = picture_map_.begin();
383 it != picture_map_.end(); 362 it != picture_map_.end();
384 ++it) { 363 ++it) {
385 Picture* picture = it->second.picture.get(); 364 Picture* picture = it->second.picture.get();
386 if (picture && (processed_pictures.count(picture) == 0)) { 365 if (picture && (processed_pictures.count(picture) == 0)) {
387 picture->EmitTraceSnapshot(); 366 picture->EmitTraceSnapshot();
388 processed_pictures.insert(picture); 367 processed_pictures.insert(picture);
389 } 368 }
390 } 369 }
391 } 370 }
392 371
393 } // namespace cc 372 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698