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

Side by Side Diff: bench/PicturePlaybackBench.cpp

Issue 540963002: Change SkPicture::draw to playback (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | bench/SKPBench.cpp » ('j') | include/core/SkPicture.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "Benchmark.h" 7 #include "Benchmark.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 28 matching lines...) Expand all
39 virtual void onDraw(const int loops, SkCanvas* canvas) { 39 virtual void onDraw(const int loops, SkCanvas* canvas) {
40 40
41 SkPictureRecorder recorder; 41 SkPictureRecorder recorder;
42 SkCanvas* pCanvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGH T, NULL, 0); 42 SkCanvas* pCanvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGH T, NULL, 0);
43 this->recordCanvas(pCanvas); 43 this->recordCanvas(pCanvas);
44 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 44 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
45 45
46 const SkPoint translateDelta = getTranslateDelta(loops); 46 const SkPoint translateDelta = getTranslateDelta(loops);
47 47
48 for (int i = 0; i < loops; i++) { 48 for (int i = 0; i < loops; i++) {
49 picture->draw(canvas); 49 picture->playback(canvas);
50 canvas->translate(translateDelta.fX, translateDelta.fY); 50 canvas->translate(translateDelta.fX, translateDelta.fY);
51 } 51 }
52 } 52 }
53 53
54 virtual void recordCanvas(SkCanvas* canvas) = 0; 54 virtual void recordCanvas(SkCanvas* canvas) = 0;
55 virtual SkPoint getTranslateDelta(int N) { 55 virtual SkPoint getTranslateDelta(int N) {
56 SkIPoint canvasSize = onGetSize(); 56 SkIPoint canvasSize = onGetSize();
57 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N), 57 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N),
58 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N)); 58 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N));
59 } 59 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 bool fDrawPosH; 132 bool fDrawPosH;
133 typedef PicturePlaybackBench INHERITED; 133 typedef PicturePlaybackBench INHERITED;
134 }; 134 };
135 135
136 136
137 /////////////////////////////////////////////////////////////////////////////// 137 ///////////////////////////////////////////////////////////////////////////////
138 138
139 DEF_BENCH( return new TextPlaybackBench(); ) 139 DEF_BENCH( return new TextPlaybackBench(); )
140 DEF_BENCH( return new PosTextPlaybackBench(true); ) 140 DEF_BENCH( return new PosTextPlaybackBench(true); )
141 DEF_BENCH( return new PosTextPlaybackBench(false); ) 141 DEF_BENCH( return new PosTextPlaybackBench(false); )
OLDNEW
« no previous file with comments | « no previous file | bench/SKPBench.cpp » ('j') | include/core/SkPicture.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698