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

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

Issue 25353009: telemetry: Refactored rasterize_and_record measurement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made BenchmarkInstrumentation a class. Created 7 years, 2 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
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/picture_pile.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 "cc/resources/picture.h" 5 #include "cc/resources/picture.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
15 #include "cc/base/util.h" 15 #include "cc/base/util.h"
16 #include "cc/debug/benchmark_instrumentation.h"
17 #include "cc/debug/traced_picture.h" 16 #include "cc/debug/traced_picture.h"
18 #include "cc/debug/traced_value.h" 17 #include "cc/debug/traced_value.h"
19 #include "cc/layers/content_layer_client.h" 18 #include "cc/layers/content_layer_client.h"
20 #include "skia/ext/lazy_pixel_ref_utils.h" 19 #include "skia/ext/lazy_pixel_ref_utils.h"
21 #include "third_party/skia/include/core/SkCanvas.h" 20 #include "third_party/skia/include/core/SkCanvas.h"
22 #include "third_party/skia/include/core/SkData.h" 21 #include "third_party/skia/include/core/SkData.h"
23 #include "third_party/skia/include/core/SkDrawFilter.h" 22 #include "third_party/skia/include/core/SkDrawFilter.h"
24 #include "third_party/skia/include/core/SkPaint.h" 23 #include "third_party/skia/include/core/SkPaint.h"
25 #include "third_party/skia/include/core/SkStream.h" 24 #include "third_party/skia/include/core/SkStream.h"
26 #include "third_party/skia/include/utils/SkPictureUtils.h" 25 #include "third_party/skia/include/utils/SkPictureUtils.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 opaque_rect_, 196 opaque_rect_,
198 pixel_refs_)); 197 pixel_refs_));
199 clones_.push_back(clone); 198 clones_.push_back(clone);
200 199
201 clone->EmitTraceSnapshotAlias(this); 200 clone->EmitTraceSnapshotAlias(this);
202 } 201 }
203 } 202 }
204 203
205 void Picture::Record(ContentLayerClient* painter, 204 void Picture::Record(ContentLayerClient* painter,
206 const SkTileGridPicture::TileGridInfo& tile_grid_info) { 205 const SkTileGridPicture::TileGridInfo& tile_grid_info) {
207 TRACE_EVENT1(benchmark_instrumentation::kCategory, 206 TRACE_EVENT1("cc", "Picture::Record",
208 benchmark_instrumentation::kPictureRecord, 207 "data", AsTraceableRecordData());
209 benchmark_instrumentation::kData, AsTraceableRecordData());
210 208
211 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); 209 DCHECK(!tile_grid_info.fTileInterval.isEmpty());
212 picture_ = skia::AdoptRef(new SkTileGridPicture( 210 picture_ = skia::AdoptRef(new SkTileGridPicture(
213 layer_rect_.width(), layer_rect_.height(), tile_grid_info)); 211 layer_rect_.width(), layer_rect_.height(), tile_grid_info));
214 212
215 SkCanvas* canvas = picture_->beginRecording( 213 SkCanvas* canvas = picture_->beginRecording(
216 layer_rect_.width(), 214 layer_rect_.width(),
217 layer_rect_.height(), 215 layer_rect_.height(),
218 SkPicture::kUsePathBoundsForClip_RecordingFlag | 216 SkPicture::kUsePathBoundsForClip_RecordingFlag |
219 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); 217 SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 min_x = std::min(min_x, min.x()); 284 min_x = std::min(min_x, min.x());
287 min_y = std::min(min_y, min.y()); 285 min_y = std::min(min_y, min.y());
288 max_x = std::max(max_x, max.x()); 286 max_x = std::max(max_x, max.x());
289 max_y = std::max(max_y, max.y()); 287 max_y = std::max(max_y, max.y());
290 } 288 }
291 289
292 min_pixel_cell_ = gfx::Point(min_x, min_y); 290 min_pixel_cell_ = gfx::Point(min_x, min_y);
293 max_pixel_cell_ = gfx::Point(max_x, max_y); 291 max_pixel_cell_ = gfx::Point(max_x, max_y);
294 } 292 }
295 293
296 void Picture::Raster( 294 int Picture::Raster(
297 SkCanvas* canvas, 295 SkCanvas* canvas,
298 SkDrawPictureCallback* callback, 296 SkDrawPictureCallback* callback,
299 gfx::Rect content_rect, 297 gfx::Rect content_rect,
300 float contents_scale) { 298 float contents_scale) {
301 TRACE_EVENT_BEGIN1(benchmark_instrumentation::kCategory, 299 TRACE_EVENT_BEGIN1(
302 benchmark_instrumentation::kPictureRaster, 300 "cc", "Picture::Raster",
303 "data", 301 "data", AsTraceableRasterData(content_rect, contents_scale));
304 AsTraceableRasterData(content_rect, contents_scale));
305 302
306 DCHECK(picture_); 303 DCHECK(picture_);
307 304
308 canvas->save(); 305 canvas->save();
309 canvas->clipRect(gfx::RectToSkRect(content_rect)); 306 canvas->clipRect(gfx::RectToSkRect(content_rect));
310 canvas->scale(contents_scale, contents_scale); 307 canvas->scale(contents_scale, contents_scale);
311 canvas->translate(layer_rect_.x(), layer_rect_.y()); 308 canvas->translate(layer_rect_.x(), layer_rect_.y());
312 picture_->draw(canvas, callback); 309 picture_->draw(canvas, callback);
313 SkIRect bounds; 310 SkIRect bounds;
314 canvas->getClipDeviceBounds(&bounds); 311 canvas->getClipDeviceBounds(&bounds);
315 canvas->restore(); 312 canvas->restore();
316 TRACE_EVENT_END1(benchmark_instrumentation::kCategory, 313 TRACE_EVENT_END1(
317 benchmark_instrumentation::kPictureRaster, 314 "cc", "Picture::Raster",
318 benchmark_instrumentation::kNumPixelsRasterized, 315 "num_pixels_rasterized", bounds.width() * bounds.height());
319 bounds.width() * bounds.height()); 316 return bounds.width() * bounds.height();
320 } 317 }
321 318
322 void Picture::Replay(SkCanvas* canvas) { 319 void Picture::Replay(SkCanvas* canvas) {
323 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); 320 TRACE_EVENT_BEGIN0("cc", "Picture::Replay");
324 DCHECK(picture_); 321 DCHECK(picture_);
325 322
326 picture_->draw(canvas); 323 picture_->draw(canvas);
327 SkIRect bounds; 324 SkIRect bounds;
328 canvas->getClipDeviceBounds(&bounds); 325 canvas->getClipDeviceBounds(&bounds);
329 TRACE_EVENT_END1("cc", "Picture::Replay", 326 TRACE_EVENT_END1("cc", "Picture::Replay",
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 raster_data->SetDouble("rect_y", rect.y()); 468 raster_data->SetDouble("rect_y", rect.y());
472 raster_data->SetDouble("rect_width", rect.width()); 469 raster_data->SetDouble("rect_width", rect.width());
473 raster_data->SetDouble("rect_height", rect.height()); 470 raster_data->SetDouble("rect_height", rect.height());
474 return TracedValue::FromValue(raster_data.release()); 471 return TracedValue::FromValue(raster_data.release());
475 } 472 }
476 473
477 scoped_refptr<base::debug::ConvertableToTraceFormat> 474 scoped_refptr<base::debug::ConvertableToTraceFormat>
478 Picture::AsTraceableRecordData() const { 475 Picture::AsTraceableRecordData() const {
479 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); 476 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
480 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); 477 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release());
481 record_data->SetInteger(benchmark_instrumentation::kWidth, 478 record_data->SetInteger("width", layer_rect_.width());
482 layer_rect_.width()); 479 record_data->SetInteger("height", layer_rect_.height());
483 record_data->SetInteger(benchmark_instrumentation::kHeight,
484 layer_rect_.height());
485 return TracedValue::FromValue(record_data.release()); 480 return TracedValue::FromValue(record_data.release());
486 } 481 }
487 482
488 } // namespace cc 483 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/picture_pile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698