aboutsummaryrefslogtreecommitdiffstats
path: root/bench
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2012-03-06 09:06:43 -0500
committerDerek Sollenberger <derek@android.com>2012-03-06 09:44:47 -0500
commit4f1dae40e24d57d647db01443b8bf2410514b8b5 (patch)
tree594df3f3fc6c1d90a76691a75763ae1beacfdf98 /bench
parent1cab2921ab279367f8206cdadc9259d12e603548 (diff)
downloadexternal_skia-4f1dae40e24d57d647db01443b8bf2410514b8b5.zip
external_skia-4f1dae40e24d57d647db01443b8bf2410514b8b5.tar.gz
external_skia-4f1dae40e24d57d647db01443b8bf2410514b8b5.tar.bz2
Skia Merge (revision 3312)
This CL also includes changes made to Android's copy of Skia in their J release branch. Change-Id: Ib2baecf48004951a3ad4a1574cdc38790c814cbc
Diffstat (limited to 'bench')
-rw-r--r--bench/Android.mk1
-rw-r--r--bench/BenchGpuTimer_gl.cpp2
-rw-r--r--bench/MutexBench.cpp2
-rw-r--r--bench/PathBench.cpp31
-rw-r--r--bench/PicturePlaybackBench.cpp147
-rw-r--r--bench/TextBench.cpp4
-rw-r--r--bench/benchmain.cpp4
7 files changed, 185 insertions, 6 deletions
diff --git a/bench/Android.mk b/bench/Android.mk
index ab2e588..71a44b9 100644
--- a/bench/Android.mk
+++ b/bench/Android.mk
@@ -21,6 +21,7 @@ LOCAL_SRC_FILES += \
MatrixBench.cpp \
MutexBench.cpp \
PathBench.cpp \
+ PicturePlaybackBench.cpp \
RectBench.cpp \
RepeatTileBench.cpp \
ScalarBench.cpp \
diff --git a/bench/BenchGpuTimer_gl.cpp b/bench/BenchGpuTimer_gl.cpp
index 885f7b2..b7bd88b 100644
--- a/bench/BenchGpuTimer_gl.cpp
+++ b/bench/BenchGpuTimer_gl.cpp
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
#include "BenchGpuTimer_gl.h"
-#include "SkGLContext.h"
+#include "gl/SkGLContext.h"
BenchGpuTimer::BenchGpuTimer(const SkGLContext* glctx) {
fContext = glctx;
diff --git a/bench/MutexBench.cpp b/bench/MutexBench.cpp
index d9b427b..af8a840 100644
--- a/bench/MutexBench.cpp
+++ b/bench/MutexBench.cpp
@@ -23,7 +23,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
for (int i = 0; i < N; i++) {
- SkMutex mu;
+ SK_DECLARE_STATIC_MUTEX(mu);
for (int j = 0; j < M; j++) {
mu.acquire();
mu.release();
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index d3e01b7..f9de53c 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -182,6 +182,26 @@ private:
typedef PathBench INHERITED;
};
+class LongLinePathBench : public PathBench {
+public:
+ LongLinePathBench(void * param, Flags flags)
+ : INHERITED(param, flags) {
+ }
+
+ virtual void appendName(SkString* name) {
+ name->append("long_line");
+ }
+ virtual void makePath(SkPath* path) {
+ SkRandom rand;
+ path->moveTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
+ for (size_t i = 1; i < 100; i++) {
+ path->lineTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
+ }
+ }
+ virtual int complexity() { return 2; }
+private:
+ typedef PathBench INHERITED;
+};
static SkBenchmark* FactT00(void* p) { return new TrianglePathBench(p, FLAGS00); }
@@ -209,6 +229,14 @@ static SkBenchmark* FactLC01(void* p) {
return new LongCurvedPathBench(p, FLAGS01);
}
+static SkBenchmark* FactLL00(void* p) {
+ return new LongLinePathBench(p, FLAGS00);
+}
+
+static SkBenchmark* FactLL01(void* p) {
+ return new LongLinePathBench(p, FLAGS01);
+}
+
static BenchRegistry gRegT00(FactT00);
static BenchRegistry gRegT01(FactT01);
static BenchRegistry gRegT10(FactT10);
@@ -230,3 +258,6 @@ static BenchRegistry gRegS01(FactS01);
static BenchRegistry gRegLC00(FactLC00);
static BenchRegistry gRegLC01(FactLC01);
+static BenchRegistry gRegLL00(FactLL00);
+static BenchRegistry gRegLL01(FactLL01);
+
diff --git a/bench/PicturePlaybackBench.cpp b/bench/PicturePlaybackBench.cpp
new file mode 100644
index 0000000..6a07fb5
--- /dev/null
+++ b/bench/PicturePlaybackBench.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2011 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 "SkColor.h"
+#include "SkPaint.h"
+#include "SkPicture.h"
+#include "SkPoint.h"
+#include "SkRect.h"
+#include "SkString.h"
+
+// This is designed to emulate about 4 screens of textual content
+
+
+class PicturePlaybackBench : public SkBenchmark {
+public:
+ PicturePlaybackBench(void* param, const char name[]) : INHERITED(param) {
+ fName.printf("picture_playback_%s", name);
+ fPictureWidth = SkIntToScalar(PICTURE_WIDTH);
+ fPictureHeight = SkIntToScalar(PICTURE_HEIGHT);
+ fTextSize = SkIntToScalar(TEXT_SIZE);
+ }
+
+ enum {
+ N = SkBENCHLOOP(1000), // number of times to playback the picture
+ PICTURE_WIDTH = 1000,
+ PICTURE_HEIGHT = 4000,
+ TEXT_SIZE = 10
+ };
+protected:
+ virtual const char* onGetName() {
+ return fName.c_str();
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+
+ SkPicture picture;
+
+ SkCanvas* pCanvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
+ recordCanvas(pCanvas);
+ picture.endRecording();
+
+ const SkPoint translateDelta = getTranslateDelta();
+
+ for (int i = 0; i < N; i++) {
+ picture.draw(canvas);
+ canvas->translate(translateDelta.fX, translateDelta.fY);
+ }
+ }
+
+ virtual void recordCanvas(SkCanvas* canvas) = 0;
+ virtual SkPoint getTranslateDelta() {
+ SkIPoint canvasSize = onGetSize();
+ return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N),
+ SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N));
+ }
+
+ SkString fName;
+ SkScalar fPictureWidth;
+ SkScalar fPictureHeight;
+ SkScalar fTextSize;
+private:
+ typedef SkBenchmark INHERITED;
+};
+
+
+class TextPlaybackBench : public PicturePlaybackBench {
+public:
+ TextPlaybackBench(void* param) : INHERITED(param, "drawText") { }
+protected:
+ virtual void recordCanvas(SkCanvas* canvas) {
+ SkPaint paint;
+ paint.setTextSize(fTextSize);
+ paint.setColor(SK_ColorBLACK);
+
+ const char* text = "Hamburgefons";
+ size_t len = strlen(text);
+ const SkScalar textWidth = paint.measureText(text, len);
+
+ for (SkScalar x = 0; x < fPictureWidth; x += textWidth) {
+ for (SkScalar y = 0; y < fPictureHeight; y += fTextSize) {
+ canvas->drawText(text, len, x, y, paint);
+ }
+ }
+ }
+private:
+ typedef PicturePlaybackBench INHERITED;
+};
+
+class PosTextPlaybackBench : public PicturePlaybackBench {
+public:
+ PosTextPlaybackBench(void* param, bool drawPosH)
+ : INHERITED(param, drawPosH ? "drawPosTextH" : "drawPosText")
+ , fDrawPosH(drawPosH) { }
+protected:
+ virtual void recordCanvas(SkCanvas* canvas) {
+ SkPaint paint;
+ paint.setTextSize(fTextSize);
+ paint.setColor(SK_ColorBLACK);
+
+ const char* text = "Hamburgefons";
+ size_t len = strlen(text);
+ const SkScalar textWidth = paint.measureText(text, len);
+
+ SkScalar* adv = new SkScalar[len];
+ paint.getTextWidths(text, len, adv);
+
+ for (SkScalar x = 0; x < fPictureWidth; x += textWidth) {
+ for (SkScalar y = 0; y < fPictureHeight; y += fTextSize) {
+
+ SkPoint* pos = new SkPoint[len];
+ SkScalar advX = 0;
+
+ for (size_t i = 0; i < len; i++) {
+ if (fDrawPosH)
+ pos[i].set(x + advX, y);
+ else
+ pos[i].set(x + advX, y + SkIntToScalar(i));
+ advX += adv[i];
+ }
+
+ canvas->drawPosText(text, len, pos, paint);
+ delete[] pos;
+ }
+ }
+ delete[] adv;
+ }
+private:
+ bool fDrawPosH;
+ typedef PicturePlaybackBench INHERITED;
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+
+static SkBenchmark* Fact0(void* p) { return new TextPlaybackBench(p); }
+static SkBenchmark* Fact1(void* p) { return new PosTextPlaybackBench(p, true); }
+static SkBenchmark* Fact2(void* p) { return new PosTextPlaybackBench(p, false); }
+
+static BenchRegistry gReg0(Fact0);
+static BenchRegistry gReg1(Fact1);
+static BenchRegistry gReg2(Fact2);
+
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index 63a7167..ed8fb0e 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -81,13 +81,13 @@ protected:
virtual const char* onGetName() {
fName.printf("text_%g", SkScalarToFloat(fPaint.getTextSize()));
if (fDoPos) {
- fName.appendf("_pos");
+ fName.append("_pos");
}
fName.appendf("_%s", fontQualityName(fPaint));
if (SK_ColorBLACK != fPaint.getColor()) {
fName.appendf("_%02X", fPaint.getAlpha());
} else {
- fName.appendf("_BK");
+ fName.append("_BK");
}
return fName.c_str();
}
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 024ad0f..7732268 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -18,8 +18,8 @@
#include "SkGpuDevice.h"
#include "SkGraphics.h"
#include "SkImageEncoder.h"
-#include "SkNativeGLContext.h"
-#include "SkNullGLContext.h"
+#include "gl/SkNativeGLContext.h"
+#include "gl/SkNullGLContext.h"
#include "SkNWayCanvas.h"
#include "SkPicture.h"
#include "SkString.h"