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

Unified Diff: bench/WritePixelsBench.cpp

Issue 180113010: Add SkCanvas::writePixels that takes info+pixels directly (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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/PremulAndUnpremulAlphaOpsBench.cpp ('k') | gyp/bench.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/WritePixelsBench.cpp
diff --git a/bench/WritePixelsBench.cpp b/bench/WritePixelsBench.cpp
index 0313846a3bc503f9429a4b76c242954551e77763..27c3f5a45b3f3710b79e7fadf2ef651b526abe21 100644
--- a/bench/WritePixelsBench.cpp
+++ b/bench/WritePixelsBench.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2013 Google Inc.
*
@@ -8,35 +7,35 @@
#include "SkBenchmark.h"
#include "SkCanvas.h"
-#include "SkConfig8888.h"
#include "SkString.h"
class WritePixelsBench : public SkBenchmark {
public:
- WritePixelsBench(SkCanvas::Config8888 config)
- : fConfig(config)
- , fName("writepix") {
- switch (config) {
- case SkCanvas::kNative_Premul_Config8888:
- fName.append("_native_PM");
- break;
- case SkCanvas::kNative_Unpremul_Config8888:
- fName.append("_native_UPM");
+ WritePixelsBench(SkColorType ct, SkAlphaType at)
+ : fColorType(ct)
+ , fAlphaType(at)
+ , fName("writepix")
+ {
+ switch (ct) {
+ case kRGBA_8888_SkColorType:
+ fName.append("_RGBA");
break;
- case SkCanvas::kBGRA_Premul_Config8888:
- fName.append("_bgra_PM");
+ case kBGRA_8888_SkColorType:
+ fName.append("_BGRA");
break;
- case SkCanvas::kBGRA_Unpremul_Config8888:
- fName.append("_bgra_UPM");
+ default:
+ SkASSERT(0);
break;
- case SkCanvas::kRGBA_Premul_Config8888:
- fName.append("_rgba_PM");
+ }
+ switch (at) {
+ case kPremul_SkAlphaType:
+ fName.append("_PM");
break;
- case SkCanvas::kRGBA_Unpremul_Config8888:
- fName.append("_rgba_UPM");
+ case kUnpremul_SkAlphaType:
+ fName.append("_UPM");
break;
default:
- SK_CRASH();
+ SkASSERT(0);
break;
}
}
@@ -52,22 +51,27 @@ protected:
canvas->clear(0xFFFF0000);
SkBitmap bmp;
- bmp.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
+ bmp.allocN32Pixels(size.width(), size.height());
canvas->readPixels(&bmp, 0, 0);
+ SkImageInfo info = bmp.info();
+ info.fColorType = fColorType;
+ info.fAlphaType = fAlphaType;
+
for (int loop = 0; loop < loops; ++loop) {
- canvas->writePixels(bmp, 0, 0, fConfig);
+ canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0);
}
}
private:
- SkCanvas::Config8888 fConfig;
- SkString fName;
+ SkColorType fColorType;
+ SkAlphaType fAlphaType;
+ SkString fName;
typedef SkBenchmark INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
-DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (SkCanvas::kRGBA_Premul_Config8888)); )
-DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (SkCanvas::kRGBA_Unpremul_Config8888)); )
+DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kPremul_SkAlphaType)); )
+DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kUnpremul_SkAlphaType)); )
« no previous file with comments | « bench/PremulAndUnpremulAlphaOpsBench.cpp ('k') | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698