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

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

Issue 126343003: Revert of cc: Combine analysis and raster (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | 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 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,
77 canvas_rect, 78 canvas_rect,
78 contents_scale, 79 contents_scale,
79 rendering_stats_instrumentation); 80 rendering_stats_instrumentation,
81 false);
82 }
83
84 void PicturePileImpl::RasterForAnalysis(
85 skia::AnalysisCanvas* canvas,
86 gfx::Rect canvas_rect,
87 float contents_scale,
88 RenderingStatsInstrumentation* stats_instrumentation) {
89 RasterCommon(
90 canvas, canvas, canvas_rect, contents_scale, stats_instrumentation, true);
80 } 91 }
81 92
82 void PicturePileImpl::RasterToBitmap( 93 void PicturePileImpl::RasterToBitmap(
83 SkCanvas* canvas, 94 SkCanvas* canvas,
84 gfx::Rect canvas_rect, 95 gfx::Rect canvas_rect,
85 float contents_scale, 96 float contents_scale,
86 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 97 RenderingStatsInstrumentation* rendering_stats_instrumentation) {
87 if (clear_canvas_with_debug_color_) { 98 if (clear_canvas_with_debug_color_) {
88 // Any non-painted areas will be left in this color. 99 // Any non-painted areas will be left in this color.
89 canvas->clear(DebugColors::NonPaintedFillColor()); 100 canvas->clear(DebugColors::NonPaintedFillColor());
(...skipping 30 matching lines...) Expand all
120 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), 131 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect),
121 SkRegion::kReplace_Op); 132 SkRegion::kReplace_Op);
122 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), 133 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
123 SkRegion::kDifference_Op); 134 SkRegion::kDifference_Op);
124 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); 135 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
125 canvas->restore(); 136 canvas->restore();
126 } 137 }
127 } 138 }
128 139
129 RasterCommon(canvas, 140 RasterCommon(canvas,
141 NULL,
130 canvas_rect, 142 canvas_rect,
131 contents_scale, 143 contents_scale,
132 rendering_stats_instrumentation); 144 rendering_stats_instrumentation,
145 false);
133 } 146 }
134 147
135 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect, 148 void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect,
136 gfx::Rect content_rect, 149 gfx::Rect content_rect,
137 float contents_scale, 150 float contents_scale,
138 PictureRegionMap* results) { 151 PictureRegionMap* results) {
139 DCHECK(results); 152 DCHECK(results);
140 // Rasterize the collection of relevant picture piles. 153 // Rasterize the collection of relevant picture piles.
141 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( 154 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
142 content_rect, 1.f / contents_scale); 155 content_rect, 1.f / contents_scale);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 continue; 199 continue;
187 } 200 }
188 201
189 Region& region = it->second; 202 Region& region = it->second;
190 region.Subtract(content_clip); 203 region.Subtract(content_clip);
191 } 204 }
192 } 205 }
193 206
194 void PicturePileImpl::RasterCommon( 207 void PicturePileImpl::RasterCommon(
195 SkCanvas* canvas, 208 SkCanvas* canvas,
209 SkDrawPictureCallback* callback,
196 gfx::Rect canvas_rect, 210 gfx::Rect canvas_rect,
197 float contents_scale, 211 float contents_scale,
198 RenderingStatsInstrumentation* rendering_stats_instrumentation) { 212 RenderingStatsInstrumentation* rendering_stats_instrumentation,
213 bool is_analysis) {
199 DCHECK(contents_scale >= min_contents_scale_); 214 DCHECK(contents_scale >= min_contents_scale_);
200 215
201 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); 216 canvas->translate(-canvas_rect.x(), -canvas_rect.y());
202 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), 217 gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
203 contents_scale); 218 contents_scale);
204 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); 219 gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size));
205 gfx::Rect content_rect = total_content_rect; 220 gfx::Rect content_rect = total_content_rect;
206 content_rect.Intersect(canvas_rect); 221 content_rect.Intersect(canvas_rect);
207 222
208 canvas->clipRect(gfx::RectToSkRect(content_rect), 223 canvas->clipRect(gfx::RectToSkRect(content_rect),
(...skipping 25 matching lines...) Expand all
234 base::TimeDelta::FromInternalValue(std::numeric_limits<int64>::max()); 249 base::TimeDelta::FromInternalValue(std::numeric_limits<int64>::max());
235 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); 250 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_);
236 int rasterized_pixel_count = 0; 251 int rasterized_pixel_count = 0;
237 252
238 for (int j = 0; j < repeat_count; ++j) { 253 for (int j = 0; j < repeat_count; ++j) {
239 base::TimeTicks start_time; 254 base::TimeTicks start_time;
240 if (rendering_stats_instrumentation) 255 if (rendering_stats_instrumentation)
241 start_time = rendering_stats_instrumentation->StartRecording(); 256 start_time = rendering_stats_instrumentation->StartRecording();
242 257
243 rasterized_pixel_count = picture->Raster( 258 rasterized_pixel_count = picture->Raster(
244 canvas, negated_clip_region, contents_scale); 259 canvas, callback, negated_clip_region, contents_scale);
245 260
246 if (rendering_stats_instrumentation) { 261 if (rendering_stats_instrumentation) {
247 base::TimeDelta duration = 262 base::TimeDelta duration =
248 rendering_stats_instrumentation->EndRecording(start_time); 263 rendering_stats_instrumentation->EndRecording(start_time);
249 best_duration = std::min(best_duration, duration); 264 best_duration = std::min(best_duration, duration);
250 } 265 }
251 } 266 }
252 267
253 if (rendering_stats_instrumentation) { 268 if (rendering_stats_instrumentation) {
254 rendering_stats_instrumentation->AddRaster(best_duration, 269 if (is_analysis) {
255 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 }
256 } 276 }
257 } 277 }
258 278
259 #ifndef NDEBUG 279 #ifndef NDEBUG
260 // Fill the clip with debug color. This allows us to 280 // Fill the clip with debug color. This allows us to
261 // distinguish between non painted areas and problems with missing 281 // distinguish between non painted areas and problems with missing
262 // pictures. 282 // pictures.
263 SkPaint paint; 283 SkPaint paint;
264 for (Region::Iterator it(total_clip); it.has_rect(); it.next()) 284 for (Region::Iterator it(total_clip); it.has_rect(); it.next())
265 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
281 layer_rect.width(), 301 layer_rect.width(),
282 layer_rect.height(), 302 layer_rect.height(),
283 SkPicture::kUsePathBoundsForClip_RecordingFlag); 303 SkPicture::kUsePathBoundsForClip_RecordingFlag);
284 304
285 RasterToBitmap(canvas, layer_rect, 1.0, NULL); 305 RasterToBitmap(canvas, layer_rect, 1.0, NULL);
286 picture->endRecording(); 306 picture->endRecording();
287 307
288 return picture; 308 return picture;
289 } 309 }
290 310
311 void PicturePileImpl::AnalyzeInRect(
312 gfx::Rect content_rect,
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) {
323 DCHECK(analysis);
324 TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect");
325
326 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
327 content_rect, 1.0f / contents_scale);
328
329 layer_rect.Intersect(gfx::Rect(tiling_.total_size()));
330
331 SkBitmap empty_bitmap;
332 empty_bitmap.setConfig(SkBitmap::kNo_Config,
333 layer_rect.width(),
334 layer_rect.height());
335 skia::AnalysisDevice device(empty_bitmap);
336 skia::AnalysisCanvas canvas(&device);
337
338 RasterForAnalysis(&canvas, layer_rect, 1.0f, stats_instrumentation);
339
340 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color);
341 analysis->has_text = canvas.HasText();
342 }
343
291 PicturePileImpl::Analysis::Analysis() 344 PicturePileImpl::Analysis::Analysis()
292 : is_solid_color(false), 345 : is_solid_color(false),
293 has_text(false) { 346 has_text(false) {
294 } 347 }
295 348
296 PicturePileImpl::Analysis::~Analysis() { 349 PicturePileImpl::Analysis::~Analysis() {
297 } 350 }
298 351
299 PicturePileImpl::PixelRefIterator::PixelRefIterator( 352 PicturePileImpl::PixelRefIterator::PixelRefIterator(
300 gfx::Rect content_rect, 353 gfx::Rect content_rect,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 !picture->WillPlayBackBitmaps()) 390 !picture->WillPlayBackBitmaps())
338 continue; 391 continue;
339 392
340 processed_pictures_.insert(picture); 393 processed_pictures_.insert(picture);
341 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture); 394 pixel_ref_iterator_ = Picture::PixelRefIterator(layer_rect_, picture);
342 if (pixel_ref_iterator_) 395 if (pixel_ref_iterator_)
343 break; 396 break;
344 } 397 }
345 } 398 }
346 399
347 gfx::Rect PicturePileImpl::AnalysisRectForRaster(gfx::Rect content_rect,
348 float contents_scale) const {
349 // Bound the analysis rect to just the pile content.
350 gfx::Rect content_bounds(
351 gfx::ScaleToEnclosingRect(gfx::Rect(size()), contents_scale));
352 gfx::Rect analysis_rect(content_rect);
353 analysis_rect.Intersect(content_bounds);
354 // Move to canvas space.
355 analysis_rect.set_origin(gfx::Point());
356
357 return analysis_rect;
358 }
359
360 void PicturePileImpl::DidBeginTracing() { 400 void PicturePileImpl::DidBeginTracing() {
361 gfx::Rect layer_rect(tiling_.total_size()); 401 gfx::Rect layer_rect(tiling_.total_size());
362 std::set<void*> processed_pictures; 402 std::set<void*> processed_pictures;
363 for (PictureMap::iterator it = picture_map_.begin(); 403 for (PictureMap::iterator it = picture_map_.begin();
364 it != picture_map_.end(); 404 it != picture_map_.end();
365 ++it) { 405 ++it) {
366 Picture* picture = it->second.GetPicture(); 406 Picture* picture = it->second.GetPicture();
367 if (picture && (processed_pictures.count(picture) == 0)) { 407 if (picture && (processed_pictures.count(picture) == 0)) {
368 picture->EmitTraceSnapshot(); 408 picture->EmitTraceSnapshot();
369 processed_pictures.insert(picture); 409 processed_pictures.insert(picture);
370 } 410 }
371 } 411 }
372 } 412 }
373 413
374 } // namespace cc 414 } // 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