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

Side by Side Diff: cc/picture_pile_impl.cc

Issue 12095053: cc: Avoid expensive RenderingStats collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use WebSettings Created 7 years, 10 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
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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "cc/picture_pile_impl.h" 6 #include "cc/picture_pile_impl.h"
7 #include "cc/region.h" 7 #include "cc/region.h"
8 #include "cc/rendering_stats.h" 8 #include "cc/rendering_stats.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkSize.h" 10 #include "third_party/skia/include/core/SkSize.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void PicturePileImpl::Raster( 60 void PicturePileImpl::Raster(
61 SkCanvas* canvas, 61 SkCanvas* canvas,
62 gfx::Rect content_rect, 62 gfx::Rect content_rect,
63 float contents_scale, 63 float contents_scale,
64 RenderingStats* stats) { 64 RenderingStats* stats) {
65 65
66 DCHECK(contents_scale >= min_contents_scale_); 66 DCHECK(contents_scale >= min_contents_scale_);
67 67
68 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); 68 base::TimeTicks rasterize_begin_time;
69 if (stats)
70 rasterize_begin_time = base::TimeTicks::Now();
69 71
70 canvas->save(); 72 canvas->save();
71 canvas->translate(-content_rect.x(), -content_rect.y()); 73 canvas->translate(-content_rect.x(), -content_rect.y());
72 canvas->clipRect(gfx::RectToSkRect(content_rect)); 74 canvas->clipRect(gfx::RectToSkRect(content_rect));
73 75
74 gfx::Rect layer_rect = gfx::ToEnclosingRect( 76 gfx::Rect layer_rect = gfx::ToEnclosingRect(
75 gfx::ScaleRect(content_rect, 1.f / contents_scale)); 77 gfx::ScaleRect(content_rect, 1.f / contents_scale));
76 78
77 Region unclipped(content_rect); 79 Region unclipped(content_rect);
78 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); 80 for (TilingData::Iterator tile_iter(&tiling_, layer_rect);
(...skipping 26 matching lines...) Expand all
105 } else { 107 } else {
106 (*i)->Raster(canvas, content_clip, contents_scale); 108 (*i)->Raster(canvas, content_clip, contents_scale);
107 } 109 }
108 110
109 // Don't allow pictures underneath to draw where this picture did. 111 // Don't allow pictures underneath to draw where this picture did.
110 canvas->clipRect( 112 canvas->clipRect(
111 gfx::RectToSkRect(content_clip), 113 gfx::RectToSkRect(content_clip),
112 SkRegion::kDifference_Op); 114 SkRegion::kDifference_Op);
113 unclipped.Subtract(content_clip); 115 unclipped.Subtract(content_clip);
114 116
115 stats->totalPixelsRasterized += 117 stats->totalPixelsRasterized +=
vmpstr 2013/01/31 22:29:19 Should this be conditional as well?
danakj 2013/02/01 00:46:11 Branching is more expensive than adding. So I'd sa
nduca 2013/02/01 01:48:53 @danakj: stats could be null, right?
danakj 2013/02/01 01:51:22 Yaa, they pinged me offline about it too. Rebasin
116 content_clip.width() * content_clip.height(); 118 content_clip.width() * content_clip.height();
117 } 119 }
118 } 120 }
119 canvas->restore(); 121 canvas->restore();
120 122
121 stats->totalRasterizeTime += base::TimeTicks::Now() - rasterizeBeginTime; 123 if (stats)
124 stats->totalRasterizeTime += base::TimeTicks::Now() - rasterize_begin_time;
122 } 125 }
123 126
124 void PicturePileImpl::GatherPixelRefs( 127 void PicturePileImpl::GatherPixelRefs(
125 gfx::Rect content_rect, 128 gfx::Rect content_rect,
126 float contents_scale, 129 float contents_scale,
127 std::list<skia::LazyPixelRef*>& pixel_refs) { 130 std::list<skia::LazyPixelRef*>& pixel_refs) {
128 std::list<skia::LazyPixelRef*> result; 131 std::list<skia::LazyPixelRef*> result;
129 132
130 gfx::Rect layer_rect = gfx::ToEnclosingRect( 133 gfx::Rect layer_rect = gfx::ToEnclosingRect(
131 gfx::ScaleRect(content_rect, 1.f / contents_scale)); 134 gfx::ScaleRect(content_rect, 1.f / contents_scale));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 SkPicture::kUsePathBoundsForClip_RecordingFlag); 168 SkPicture::kUsePathBoundsForClip_RecordingFlag);
166 169
167 RenderingStats stats; 170 RenderingStats stats;
168 Raster(canvas, layer_rect, 1.0, &stats); 171 Raster(canvas, layer_rect, 1.0, &stats);
169 picture->endRecording(); 172 picture->endRecording();
170 173
171 return picture; 174 return picture;
172 } 175 }
173 176
174 } // namespace cc 177 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698