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

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

Issue 12426024: cc: Switch RenderingStats collection in Layer::Update() to RenderingStatsInstrumentation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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
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/debug/rendering_stats.h" 6 #include "cc/debug/rendering_stats_instrumentation.h"
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/resources/picture.h" 8 #include "cc/resources/picture.h"
9 #include "skia/ext/analysis_canvas.h" 9 #include "skia/ext/analysis_canvas.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkData.h" 11 #include "third_party/skia/include/core/SkData.h"
12 #include "third_party/skia/include/utils/SkPictureUtils.h" 12 #include "third_party/skia/include/utils/SkPictureUtils.h"
13 #include "ui/gfx/rect_conversions.h" 13 #include "ui/gfx/rect_conversions.h"
14 #include "ui/gfx/skia_util.h" 14 #include "ui/gfx/skia_util.h"
15 15
16 namespace { 16 namespace {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 for (int i = 0; i < num_threads; i++) { 58 for (int i = 0; i < num_threads; i++) {
59 scoped_refptr<Picture> clone = make_scoped_refptr( 59 scoped_refptr<Picture> clone = make_scoped_refptr(
60 new Picture(skia::AdoptRef(new SkPicture(clones[i])), 60 new Picture(skia::AdoptRef(new SkPicture(clones[i])),
61 layer_rect_, 61 layer_rect_,
62 opaque_rect_)); 62 opaque_rect_));
63 clones_.push_back(clone); 63 clones_.push_back(clone);
64 } 64 }
65 } 65 }
66 66
67 void Picture::Record(ContentLayerClient* painter, 67 void Picture::Record(ContentLayerClient* painter,
68 RenderingStats* stats, 68 RenderingStatsInstrumentation* stats_instrumentation,
69 const SkTileGridPicture::TileGridInfo& tileGridInfo) { 69 const SkTileGridPicture::TileGridInfo& tileGridInfo) {
70 TRACE_EVENT2("cc", "Picture::Record", 70 TRACE_EVENT2("cc", "Picture::Record",
71 "width", layer_rect_.width(), "height", layer_rect_.height()); 71 "width", layer_rect_.width(), "height", layer_rect_.height());
72 72
73 // Record() should only be called once. 73 // Record() should only be called once.
74 DCHECK(!picture_); 74 DCHECK(!picture_);
75 DCHECK(!tileGridInfo.fTileInterval.isEmpty()); 75 DCHECK(!tileGridInfo.fTileInterval.isEmpty());
76 picture_ = skia::AdoptRef(new SkTileGridPicture( 76 picture_ = skia::AdoptRef(new SkTileGridPicture(
77 layer_rect_.width(), layer_rect_.height(), tileGridInfo)); 77 layer_rect_.width(), layer_rect_.height(), tileGridInfo));
78 78
(...skipping 11 matching lines...) Expand all
90 paint.setAntiAlias(false); 90 paint.setAntiAlias(false);
91 paint.setXfermodeMode(SkXfermode::kClear_Mode); 91 paint.setXfermodeMode(SkXfermode::kClear_Mode);
92 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), 92 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(),
93 layer_rect_.y(), 93 layer_rect_.y(),
94 layer_rect_.width(), 94 layer_rect_.width(),
95 layer_rect_.height()); 95 layer_rect_.height());
96 canvas->clipRect(layer_skrect); 96 canvas->clipRect(layer_skrect);
97 canvas->drawRect(layer_skrect, paint); 97 canvas->drawRect(layer_skrect, paint);
98 98
99 gfx::RectF opaque_layer_rect; 99 gfx::RectF opaque_layer_rect;
100 base::TimeTicks begin_paint_time; 100 base::TimeTicks start_time = stats_instrumentation->StartRecording();
101 if (stats) 101
102 begin_paint_time = base::TimeTicks::Now();
103 painter->PaintContents(canvas, layer_rect_, &opaque_layer_rect); 102 painter->PaintContents(canvas, layer_rect_, &opaque_layer_rect);
104 if (stats) { 103
105 stats->totalPaintTime += base::TimeTicks::Now() - begin_paint_time; 104 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time);
106 stats->totalPixelsPainted += 105 stats_instrumentation->AddPaint(duration,
107 layer_rect_.width() * layer_rect_.height(); 106 layer_rect_.width() * layer_rect_.height());
108 }
109 107
110 canvas->restore(); 108 canvas->restore();
111 picture_->endRecording(); 109 picture_->endRecording();
112 110
113 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); 111 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect);
114 } 112 }
115 113
116 void Picture::Raster( 114 void Picture::Raster(
117 SkCanvas* canvas, 115 SkCanvas* canvas,
118 gfx::Rect content_rect, 116 gfx::Rect content_rect,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (*refs && (*refs)->getURI() && !strncmp( 150 if (*refs && (*refs)->getURI() && !strncmp(
153 (*refs)->getURI(), labelLazyDecoded, 4)) { 151 (*refs)->getURI(), labelLazyDecoded, 4)) {
154 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); 152 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs));
155 } 153 }
156 refs++; 154 refs++;
157 } 155 }
158 pixel_refs->unref(); 156 pixel_refs->unref();
159 } 157 }
160 158
161 } // namespace cc 159 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698