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

Unified Diff: bench/BitmapScaleBench.cpp

Issue 18942002: fix compile warnings (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: virtual destructor Created 7 years, 5 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/BitmapBench.cpp ('k') | gm/filterbitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/BitmapScaleBench.cpp
diff --git a/bench/BitmapScaleBench.cpp b/bench/BitmapScaleBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..45ea1b46ef19f68da9bb894bfc70363fa1986e6f
--- /dev/null
+++ b/bench/BitmapScaleBench.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBenchmark.h"
+#include "SkCanvas.h"
+#include "SkPaint.h"
+#include "SkRandom.h"
+#include "SkShader.h"
+#include "SkString.h"
+#include "SkBlurMask.h"
+
+class BitmapScaleBench: public SkBenchmark {
+ int fLoopCount;
+ int fInputSize;
+ int fOutputSize;
+ SkString fName;
+
+public:
+ BitmapScaleBench(void *param, int is, int os) : INHERITED(param) {
+ fInputSize = is;
+ fOutputSize = os;
+
+ fLoopCount = 100;
+ }
+
+protected:
+
+ SkBitmap fInputBitmap, fOutputBitmap;
+ SkMatrix fMatrix;
+
+ virtual const char* onGetName() {
+ return fName.c_str();
+ }
+
+ int inputSize() const {
+ return fInputSize;
+ }
+
+ int outputSize() const {
+ return fOutputSize;
+ }
+
+ float scale() const {
+ return float(outputSize())/inputSize();
+ }
+
+ SkIPoint onGetSize() SK_OVERRIDE {
+ return SkIPoint::Make( fOutputSize, fOutputSize );
+ }
+
+ void setName(const char * name) {
+ fName.printf( "bitmap_scale_%s_%d_%d", name, fInputSize, fOutputSize );
+ }
+
+ virtual void onPreDraw() {
+ fInputBitmap.setConfig(SkBitmap::kARGB_8888_Config, fInputSize, fInputSize);
+ fInputBitmap.allocPixels();
+ fInputBitmap.eraseColor(SK_ColorWHITE);
+ fInputBitmap.setIsOpaque(true);
+
+ fOutputBitmap.setConfig(SkBitmap::kARGB_8888_Config, fOutputSize, fOutputSize);
+ fOutputBitmap.allocPixels();
+ fOutputBitmap.setIsOpaque(true);
+
+ fMatrix.setScale( scale(), scale() );
+ }
+
+ virtual void onDraw(SkCanvas*) {
+ SkPaint paint;
+ this->setupPaint(&paint);
+
+ preBenchSetup();
+
+ for (int i = 0; i < SkBENCHLOOP(fLoopCount); i++) {
+ doScaleImage();
+ }
+ }
+
+ virtual void doScaleImage() = 0;
+ virtual void preBenchSetup() {}
+private:
+ typedef SkBenchmark INHERITED;
+};
+
+class BitmapFilterScaleBench: public BitmapScaleBench {
+ public:
+ BitmapFilterScaleBench(void *param, int is, int os) : INHERITED(param, is, os) {
+ setName( "filter" );
+ }
+protected:
+ virtual void doScaleImage() SK_OVERRIDE {
+ SkCanvas canvas( fOutputBitmap );
+ SkPaint paint;
+
+ paint.setFlags( SkPaint::kHighQualityFilterBitmap_Flag | SkPaint::kFilterBitmap_Flag );
+
+ canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint );
+ }
+private:
+ typedef BitmapScaleBench INHERITED;
+};
+
+class BitmapDirectScaleBench: public BitmapScaleBench {
+ public:
+ BitmapDirectScaleBench(void *param, int is, int os) : INHERITED(param, is, os) {
+ setName( "direct" );
+ }
+protected:
+ virtual void doScaleImage() SK_OVERRIDE {
+ fInputBitmap.scale( &fOutputBitmap );
+ }
+private:
+ typedef BitmapScaleBench INHERITED;
+};
+
+
+DEF_BENCH(return new BitmapFilterScaleBench(p, 10, 90);)
+DEF_BENCH(return new BitmapFilterScaleBench(p, 30, 90);)
+DEF_BENCH(return new BitmapFilterScaleBench(p, 80, 90);)
+// DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 90);)
+// DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 80);)
+// DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 30);)
+// DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 10);)
+
+DEF_BENCH(return new BitmapDirectScaleBench(p, 10, 90);)
+DEF_BENCH(return new BitmapDirectScaleBench(p, 30, 90);)
+DEF_BENCH(return new BitmapDirectScaleBench(p, 80, 90);)
+// DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 90);)
+// DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 80);)
+// DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 30);)
+// DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 10);)
« no previous file with comments | « bench/BitmapBench.cpp ('k') | gm/filterbitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698