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

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: windows warning 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
« no previous file with comments | « bench/SKPAnimationBench.h ('k') | bench/SKPBench.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 animationMatr ix, int steps)
15 : INHERITED(name, pic, clip, 1.0, false)
16 , fSteps(steps)
17 , fAnimationMatrix(animationMatrix)
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 frameMatrix = SkMatrix::MakeTrans(-fCenter.fX, -fCenter.fY);
41 frameMatrix.postConcat(fAnimationMatrix);
42 SkMatrix reverseTranslate = SkMatrix::MakeTrans(fCenter.fX, fCenter.fY);
43 frameMatrix.postConcat(reverseTranslate);
44
45 SkMatrix currentMatrix = frameMatrix;
46 for (int i = 0; i < fSteps; i++) {
47 for (int j = 0; j < this->tileRects().count(); ++j) {
48 SkMatrix trans = SkMatrix::MakeTrans(-1.f * this->tileRects()[j].fLe ft,
49 -1.f * this->tileRects()[j].fTo p);
50 SkMatrix tileMatrix = currentMatrix;
51 tileMatrix.postConcat(trans);
52 this->surfaces()[j]->getCanvas()->drawPicture(this->picture(), &tile Matrix, NULL);
53 }
54
55 for (int j = 0; j < this->tileRects().count(); ++j) {
56 this->surfaces()[j]->getCanvas()->flush();
57 }
58 currentMatrix.postConcat(frameMatrix);
59 }
60 }
OLDNEW
« no previous file with comments | « bench/SKPAnimationBench.h ('k') | bench/SKPBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698