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

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

Issue 74713006: cc: Include analysis in raster benchmark costs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix presubmit warning Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | cc/resources/raster_worker_pool.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 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 77 NULL,
78 canvas_rect, 78 canvas_rect,
79 contents_scale, 79 contents_scale,
80 rendering_stats_instrumentation); 80 rendering_stats_instrumentation,
81 false);
81 } 82 }
82 83
83 void PicturePileImpl::RasterForAnalysis( 84 void PicturePileImpl::RasterForAnalysis(
84 skia::AnalysisCanvas* canvas, 85 skia::AnalysisCanvas* canvas,
85 gfx::Rect canvas_rect, 86 gfx::Rect canvas_rect,
86 float contents_scale) { 87 float contents_scale,
87 RasterCommon(canvas, canvas, canvas_rect, contents_scale, NULL); 88 RenderingStatsInstrumentation* stats_instrumentation) {
89 RasterCommon(
90 canvas, canvas, canvas_rect, contents_scale, stats_instrumentation, true);
88 } 91 }
89 92
90 void PicturePileImpl::RasterToBitmap( 93 void PicturePileImpl::RasterToBitmap(
91 SkCanvas* canvas, 94 SkCanvas* canvas,
92 gfx::Rect canvas_rect, 95 gfx::Rect canvas_rect,
93 float contents_scale, 96 float contents_scale,
94 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 97 RenderingStatsInstrumentation* rendering_stats_instrumentation) {
95 if (clear_canvas_with_debug_color_) { 98 if (clear_canvas_with_debug_color_) {
96 // Any non-painted areas will be left in this color. 99 // Any non-painted areas will be left in this color.
97 canvas->clear(DebugColors::NonPaintedFillColor()); 100 canvas->clear(DebugColors::NonPaintedFillColor());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 SkRegion::kDifference_Op); 134 SkRegion::kDifference_Op);
132 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); 135 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
133 canvas->restore(); 136 canvas->restore();
134 } 137 }
135 } 138 }
136 139
137 RasterCommon(canvas, 140 RasterCommon(canvas,
138 NULL, 141 NULL,
139 canvas_rect, 142 canvas_rect,
140 contents_scale, 143 contents_scale,
141 rendering_stats_instrumentation); 144 rendering_stats_instrumentation,
145 false);
142 } 146 }
143 147
144 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect, 148 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect,
145 gfx::Rect content_rect, 149 gfx::Rect content_rect,
146 float contents_scale, 150 float contents_scale,
147 PictureRegionMap* results) { 151 PictureRegionMap* results) {
148 DCHECK(results); 152 DCHECK(results);
149 // Rasterize the collection of relevant picture piles. 153 // Rasterize the collection of relevant picture piles.
150 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( 154 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
151 content_rect, 1.f / contents_scale); 155 content_rect, 1.f / contents_scale);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 Region& region = it->second; 202 Region& region = it->second;
199 region.Subtract(content_clip); 203 region.Subtract(content_clip);
200 } 204 }
201 } 205 }
202 206
203 void PicturePileImpl::RasterCommon( 207 void PicturePileImpl::RasterCommon(
204 SkCanvas* canvas, 208 SkCanvas* canvas,
205 SkDrawPictureCallback* callback, 209 SkDrawPictureCallback* callback,
206 gfx::Rect canvas_rect, 210 gfx::Rect canvas_rect,
207 float contents_scale, 211 float contents_scale,
208 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 212 RenderingStatsInstrumentation* rendering_stats_instrumentation,
213 bool is_analysis) {
209 DCHECK(contents_scale >= min_contents_scale_); 214 DCHECK(contents_scale >= min_contents_scale_);
210 215
211 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); 216 canvas->translate(-canvas_rect.x(), -canvas_rect.y());
212 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), 217 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
213 contents_scale); 218 contents_scale);
214 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); 219 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size));
215 gfx::Rect content_rect = total_content_rect; 220 gfx::Rect content_rect = total_content_rect;
216 content_rect.Intersect(canvas_rect); 221 content_rect.Intersect(canvas_rect);
217 222
218 canvas->clipRect(gfx::RectToSkRect(content_rect), 223 canvas->clipRect(gfx::RectToSkRect(content_rect),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 canvas, callback, negated_clip_region, contents_scale); 259 canvas, callback, negated_clip_region, contents_scale);
255 260
256 if (rendering_stats_instrumentation) { 261 if (rendering_stats_instrumentation) {
257 base::TimeDelta duration = 262 base::TimeDelta duration =
258 rendering_stats_instrumentation->EndRecording(start_time); 263 rendering_stats_instrumentation->EndRecording(start_time);
259 best_duration = std::min(best_duration, duration); 264 best_duration = std::min(best_duration, duration);
260 } 265 }
261 } 266 }
262 267
263 if (rendering_stats_instrumentation) { 268 if (rendering_stats_instrumentation) {
264 rendering_stats_instrumentation->AddRaster(best_duration, 269 if (is_analysis) {
265 rasterized_pixel_count); 270 rendering_stats_instrumentation->AddAnalysis(best_duration,
271 rasterized_pixel_count);
272 } else {
273 rendering_stats_instrumentation->AddRaster(best_duration,
274 rasterized_pixel_count);
275 }
266 } 276 }
267 } 277 }
268 278
269 #ifndef NDEBUG 279 #ifndef NDEBUG
270 // Fill the clip with debug color. This allows us to 280 // Fill the clip with debug color. This allows us to
271 // distinguish between non painted areas and problems with missing 281 // distinguish between non painted areas and problems with missing
272 // pictures. 282 // pictures.
273 SkPaint paint; 283 SkPaint paint;
274 for (Region::Iterator it(total_clip); it.has_rect(); it.next()) 284 for (Region::Iterator it(total_clip); it.has_rect(); it.next())
275 canvas->clipRect(gfx::RectToSkRect(it.rect()), SkRegion::kDifference_Op); 285 canvas->clipRect(gfx::RectToSkRect(it.rect()), SkRegion::kDifference_Op);
(...skipping 15 matching lines...) Expand all
291 layer_rect.width(), 301 layer_rect.width(),
292 layer_rect.height(), 302 layer_rect.height(),
293 SkPicture::kUsePathBoundsForClip_RecordingFlag); 303 SkPicture::kUsePathBoundsForClip_RecordingFlag);
294 304
295 RasterToBitmap(canvas, layer_rect, 1.0, NULL); 305 RasterToBitmap(canvas, layer_rect, 1.0, NULL);
296 picture->endRecording(); 306 picture->endRecording();
297 307
298 return picture; 308 return picture;
299 } 309 }
300 310
301 void PicturePileImpl::AnalyzeInRect(gfx::Rect content_rect, 311 void PicturePileImpl::AnalyzeInRect(
302 float contents_scale, 312 gfx::Rect content_rect,
303 PicturePileImpl::Analysis* analysis) { 313 float contents_scale,
314 PicturePileImpl::Analysis* analysis) {
315 AnalyzeInRect(content_rect, contents_scale, analysis, NULL);
316 }
317
318 void PicturePileImpl::AnalyzeInRect(
319 gfx::Rect content_rect,
320 float contents_scale,
321 PicturePileImpl::Analysis* analysis,
322 RenderingStatsInstrumentation* stats_instrumentation) {
304 DCHECK(analysis); 323 DCHECK(analysis);
305 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect"); 324 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect");
306 325
307 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( 326 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
308 content_rect, 1.0f / contents_scale); 327 content_rect, 1.0f / contents_scale);
309 328
310 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); 329 layer_rect.Intersect(gfx::Rect(tiling_.total_size()));
311 330
312 SkBitmap empty_bitmap; 331 SkBitmap empty_bitmap;
313 empty_bitmap.setConfig(SkBitmap::kNo_Config, 332 empty_bitmap.setConfig(SkBitmap::kNo_Config,
314 layer_rect.width(), 333 layer_rect.width(),
315 layer_rect.height()); 334 layer_rect.height());
316 skia::AnalysisDevice device(empty_bitmap); 335 skia::AnalysisDevice device(empty_bitmap);
317 skia::AnalysisCanvas canvas(&device); 336 skia::AnalysisCanvas canvas(&device);
318 337
319 RasterForAnalysis(&canvas, layer_rect, 1.0f); 338 RasterForAnalysis(&canvas, layer_rect, 1.0f, stats_instrumentation);
320 339
321 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); 340 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color);
322 analysis->has_text = canvas.HasText(); 341 analysis->has_text = canvas.HasText();
323 } 342 }
324 343
325 PicturePileImpl::Analysis::Analysis() 344 PicturePileImpl::Analysis::Analysis()
326 : is_solid_color(false), 345 : is_solid_color(false),
327 has_text(false) { 346 has_text(false) {
328 } 347 }
329 348
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 ++it) { 404 ++it) {
386 Picture* picture = it->second.GetPicture(); 405 Picture* picture = it->second.GetPicture();
387 if (picture && (processed_pictures.count(picture) == 0)) { 406 if (picture && (processed_pictures.count(picture) == 0)) {
388 picture->EmitTraceSnapshot(); 407 picture->EmitTraceSnapshot();
389 processed_pictures.insert(picture); 408 processed_pictures.insert(picture);
390 } 409 }
391 } 410 }
392 } 411 }
393 412
394 } // namespace cc 413 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | cc/resources/raster_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698