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

Side by Side Diff: bench/SKPAnimationBench.cpp

Issue 1061323003: Change to add zoom animations to nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 8 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
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SKPAnimationBench.h"
9 #include "SkCommandLineFlags.h"
10 #include "SkMultiPictureDraw.h"
11 #include "SkSurface.h"
12
13 SKPAnimationBench::SKPAnimationBench(const char* name, const SkPicture* pic,
14 const SkIRect& clip, SkMatrix viewMatrix, i nt steps)
15 : INHERITED(name, pic, clip, 1.0, false)
16 , fSteps(steps)
17 , fViewMatrix(viewMatrix)
18 , fName(name) {
19 fUniqueName.printf("%s_animation", name);
20 }
21
22 const char* SKPAnimationBench::onGetName() {
23 return fName.c_str();
24 }
25
26 const char* SKPAnimationBench::onGetUniqueName() {
27 return fUniqueName.c_str();
28 }
29
30 void SKPAnimationBench::onPerCanvasPreDraw(SkCanvas* canvas) {
31 INHERITED::onPerCanvasPreDraw(canvas);
32 SkIRect bounds;
33 SkAssertResult(canvas->getClipDeviceBounds(&bounds));
34
35 fCenter.set((bounds.fRight - bounds.fLeft) / 2.0f,
36 (bounds.fBottom - bounds.fTop) / 2.0f);
37 }
38
39 void SKPAnimationBench::drawPicture() {
40 SkMatrix workingMatrix = SkMatrix::MakeTrans(fCenter.fX, fCenter.fY);
41 workingMatrix.postConcat(fViewMatrix);
42 SkMatrix reverseTranslate = SkMatrix::MakeTrans(-fCenter.fX, -fCenter.fY);
43 workingMatrix.postConcat(reverseTranslate);
44
45 for (int i = 0; i < fSteps; i++) {
46 workingMatrix.postConcat(fViewMatrix);
47 for (int j = 0; j < this->tileRects().count(); ++j) {
48 SkMatrix trans = SkMatrix::MakeTrans(-this->tileRects()[j].fLeft,
49 -this->tileRects()[j].fTop);
50 workingMatrix.postConcat(trans);
51 this->surfaces()[j]->getCanvas()->drawPicture(this->picture(), &work ingMatrix, NULL);
52 }
53
54 for (int j = 0; j < this->tileRects().count(); ++j) {
55 this->surfaces()[j]->getCanvas()->flush();
56 }
57 }
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698