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

Unified Diff: gm/downsamplebitmap.cpp

Issue 20317002: add all four filter levels to the downsample gm, for comparison across cpu/gpu (Closed) Base URL: https://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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/downsamplebitmap.cpp
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index 5cb971d77a3da37ab7370a3949e8d79d82797d94..7637e054b69ca22dfb56eb6c7df7f85b2db8b52c 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -11,6 +11,7 @@
#include "SkTypeface.h"
#include "SkImageDecoder.h"
#include "SkStream.h"
+#include "SkPaint.h"
static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style style) {
SkSafeUnref(paint->setTypeface(SkTypeface::CreateFromName(name, style)));
@@ -22,8 +23,10 @@ public:
SkBitmap fBM;
SkString fName;
bool fBitmapMade;
+ SkPaint::FilterLevel fFilterLevel;
- DownsampleBitmapGM()
+ DownsampleBitmapGM(SkPaint::FilterLevel filterLevel)
+ : fFilterLevel(filterLevel)
{
this->setBGColor(0xFFDDDDDD);
fBitmapMade = false;
@@ -32,6 +35,21 @@ public:
void setName(const char name[]) {
fName.set(name);
}
+
+ const char *filterLevelToString() {
+ switch(fFilterLevel) {
reed1 2013/07/25 17:35:48 could use a table here. there is a common way skia
+ case SkPaint::kNone_FilterLevel:
bsalomon 2013/07/25 14:31:11 nit indent within a case (the return statements)
+ return "none";
+ case SkPaint::kLow_FilterLevel:
+ return "low";
+ case SkPaint::kMedium_FilterLevel:
+ return "medium";
+ case SkPaint::kHigh_FilterLevel:
+ return "high";
+ default:
+ return "unknown";
+ }
+ }
protected:
virtual SkString onShortName() SK_OVERRIDE {
@@ -64,7 +82,7 @@ protected:
matrix.setScale( curScale, curScale );
SkPaint paint;
- paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
+ paint.setFilterLevel(fFilterLevel);
canvas->save();
canvas->translate( (SkScalar) curX, 0.f );
@@ -83,11 +101,11 @@ private:
class DownsampleBitmapTextGM: public DownsampleBitmapGM {
public:
- DownsampleBitmapTextGM(float textSize)
- : fTextSize(textSize)
+ DownsampleBitmapTextGM(float textSize, SkPaint::FilterLevel filterLevel)
+ : INHERITED(filterLevel), fTextSize(textSize)
{
char name[1024];
reed1 2013/07/25 17:35:48 SkString has printf, just for this sort of usage.
- sprintf(name, "downsamplebitmap_text_%.2fpt", fTextSize);
+ sprintf(name, "downsamplebitmap_text_%s_%.2fpt", this->filterLevelToString(), fTextSize);
setName(name);
}
@@ -120,11 +138,11 @@ class DownsampleBitmapTextGM: public DownsampleBitmapGM {
class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM {
public:
- DownsampleBitmapCheckerboardGM(int size, int numChecks)
- : fSize(size), fNumChecks(numChecks)
+ DownsampleBitmapCheckerboardGM(int size, int numChecks, SkPaint::FilterLevel filterLevel)
+ : INHERITED(filterLevel), fSize(size), fNumChecks(numChecks)
{
char name[1024];
- sprintf(name, "downsamplebitmap_checkerboard_%d_%d", fSize, fNumChecks);
+ sprintf(name, "downsamplebitmap_checkerboard_%s_%d_%d", this->filterLevelToString(), fSize, fNumChecks);
setName(name);
}
@@ -155,11 +173,11 @@ class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM {
class DownsampleBitmapImageGM: public DownsampleBitmapGM {
public:
- DownsampleBitmapImageGM(const char filename[])
- : fFilename(filename)
+ DownsampleBitmapImageGM(const char filename[], SkPaint::FilterLevel filterLevel)
+ : INHERITED(filterLevel), fFilename(filename)
{
char name[1024];
- sprintf(name, "downsamplebitmap_image_%s", filename);
+ sprintf(name, "downsamplebitmap_image_%s_%s", this->filterLevelToString(), filename);
setName(name);
}
@@ -195,6 +213,18 @@ class DownsampleBitmapImageGM: public DownsampleBitmapGM {
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return new DownsampleBitmapTextGM(72); )
-DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256); )
-DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png"); )
+DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kHigh_FilterLevel); )
+DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kHigh_FilterLevel); )
+DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kHigh_FilterLevel); )
+
+DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kMedium_FilterLevel); )
+DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kMedium_FilterLevel); )
+DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kMedium_FilterLevel); )
+
+DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kLow_FilterLevel); )
+DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterLevel); )
+DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_FilterLevel); )
+
+DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); )
+DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_FilterLevel); )
+DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_FilterLevel); )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698