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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/SKPAnimationBench.h ('k') | bench/SKPBench.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SKPAnimationBench.cpp
diff --git a/bench/SKPAnimationBench.cpp b/bench/SKPAnimationBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..24506d814f4fd67c53ca6cbc59d187a351f98a72
--- /dev/null
+++ b/bench/SKPAnimationBench.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SKPAnimationBench.h"
+#include "SkCommandLineFlags.h"
+#include "SkMultiPictureDraw.h"
+#include "SkSurface.h"
+
+SKPAnimationBench::SKPAnimationBench(const char* name, const SkPicture* pic,
+ const SkIRect& clip, SkMatrix animationMatrix, int steps)
+ : INHERITED(name, pic, clip, 1.0, false)
+ , fSteps(steps)
+ , fAnimationMatrix(animationMatrix)
+ , fName(name) {
+ fUniqueName.printf("%s_animation", name);
+}
+
+const char* SKPAnimationBench::onGetName() {
+ return fName.c_str();
+}
+
+const char* SKPAnimationBench::onGetUniqueName() {
+ return fUniqueName.c_str();
+}
+
+void SKPAnimationBench::onPerCanvasPreDraw(SkCanvas* canvas) {
+ INHERITED::onPerCanvasPreDraw(canvas);
+ SkIRect bounds;
+ SkAssertResult(canvas->getClipDeviceBounds(&bounds));
+
+ fCenter.set((bounds.fRight - bounds.fLeft) / 2.0f,
+ (bounds.fBottom - bounds.fTop) / 2.0f);
+}
+
+void SKPAnimationBench::drawPicture() {
+ SkMatrix frameMatrix = SkMatrix::MakeTrans(-fCenter.fX, -fCenter.fY);
+ frameMatrix.postConcat(fAnimationMatrix);
+ SkMatrix reverseTranslate = SkMatrix::MakeTrans(fCenter.fX, fCenter.fY);
+ frameMatrix.postConcat(reverseTranslate);
+
+ SkMatrix currentMatrix = frameMatrix;
+ for (int i = 0; i < fSteps; i++) {
+ for (int j = 0; j < this->tileRects().count(); ++j) {
+ SkMatrix trans = SkMatrix::MakeTrans(-1.f * this->tileRects()[j].fLeft,
+ -1.f * this->tileRects()[j].fTop);
+ SkMatrix tileMatrix = currentMatrix;
+ tileMatrix.postConcat(trans);
+ this->surfaces()[j]->getCanvas()->drawPicture(this->picture(), &tileMatrix, NULL);
+ }
+
+ for (int j = 0; j < this->tileRects().count(); ++j) {
+ this->surfaces()[j]->getCanvas()->flush();
+ }
+ currentMatrix.postConcat(frameMatrix);
+ }
+}
« 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