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

Unified Diff: bench/BitmapRectBench.cpp

Issue 20997003: move intensive computing/rendering from bench constructor to onPreDraw. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: 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 | « no previous file | bench/RTreeBench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/BitmapRectBench.cpp
===================================================================
--- bench/BitmapRectBench.cpp (revision 10404)
+++ bench/BitmapRectBench.cpp (working copy)
@@ -13,7 +13,7 @@
#include "SkRandom.h"
#include "SkString.h"
-static void drawIntoBitmap(const SkBitmap& bm) {
+static void draw_into_bitmap(const SkBitmap& bm) {
const int w = bm.width();
const int h = bm.height();
@@ -45,6 +45,8 @@
uint8_t fAlpha;
SkString fName;
SkRect fSrcR, fDstR;
+ static const int kWidth = 128;
+ static const int kHeight = 128;
enum { N = SkBENCHLOOP(300) };
public:
BitmapRectBench(void* param, U8CPU alpha, bool doFilter, bool slightMatrix) : INHERITED(param) {
@@ -52,37 +54,38 @@
fDoFilter = doFilter;
fSlightMatrix = slightMatrix;
- const int w = 128;
- const int h = 128;
+ fBitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight);
+ }
- fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h);
+protected:
+ virtual const char* onGetName() SK_OVERRIDE {
+ fName.printf("bitmaprect_%02X_%sfilter_%s",
+ fAlpha, fDoFilter ? "" : "no",
+ fSlightMatrix ? "trans" : "identity");
+ return fName.c_str();
+ }
+
+ virtual void onPreDraw() SK_OVERRIDE {
fBitmap.allocPixels();
fBitmap.setIsOpaque(true);
fBitmap.eraseColor(SK_ColorBLACK);
- drawIntoBitmap(fBitmap);
+ draw_into_bitmap(fBitmap);
- fSrcR.iset(0, 0, w, h);
- fDstR.iset(0, 0, w, h);
+ fSrcR.iset(0, 0, kWidth, kHeight);
+ fDstR.iset(0, 0, kWidth, kHeight);
- if (slightMatrix) {
+ if (fSlightMatrix) {
// want fractional translate
fDstR.offset(SK_Scalar1 / 3, SK_Scalar1 * 5 / 7);
// want enough to create a scale matrix, but not enough to scare
// off our sniffer which tries to see if the matrix is "effectively"
// translate-only.
- fDstR.fRight += SK_Scalar1 / (w * 60);
+ fDstR.fRight += SK_Scalar1 / (kWidth * 60);
}
}
-protected:
- virtual const char* onGetName() {
- fName.printf("bitmaprect_%02X_%sfilter_%s",
- fAlpha, fDoFilter ? "" : "no",
- fSlightMatrix ? "trans" : "identity");
- return fName.c_str();
- }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkRandom rand;
SkPaint paint;
« no previous file with comments | « no previous file | bench/RTreeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698