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

Unified Diff: gm/filterbitmap.cpp

Issue 1010343002: add kGray_8_SkColorType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | include/core/SkImageInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/filterbitmap.cpp
diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp
index 7028012f45508911d3cf643024e8491aff9b46e7..c76a70a8eaac064bf2a4d25a3fabadad2b89ec6d 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -138,12 +138,13 @@ class FilterBitmapTextGM: public FilterBitmapGM {
};
class FilterBitmapCheckerboardGM: public FilterBitmapGM {
- public:
- FilterBitmapCheckerboardGM(int size, int num_checks)
- : fSize(size), fNumChecks(num_checks)
- {
- fName.printf("filterbitmap_checkerboard_%d_%d", fSize, fNumChecks);
- }
+public:
+ FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = false)
+ : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8)
+ {
+ fName.printf("filterbitmap_checkerboard_%d_%d%s",
+ fSize, fNumChecks, convertToG8 ? "_g8" : "");
+ }
protected:
int fSize;
@@ -167,20 +168,26 @@ class FilterBitmapCheckerboardGM: public FilterBitmapGM {
}
}
}
+ if (fConvertToG8) {
+ SkBitmap tmp;
+ fBM.copyTo(&tmp, kGray_8_SkColorType);
+ fBM = tmp;
+ }
}
- private:
- typedef FilterBitmapGM INHERITED;
+private:
+ const bool fConvertToG8;
+ typedef FilterBitmapGM INHERITED;
};
class FilterBitmapImageGM: public FilterBitmapGM {
- public:
- FilterBitmapImageGM(const char filename[])
- : fFilename(filename)
- {
- fName.printf("filterbitmap_image_%s", filename);
- }
+public:
+ FilterBitmapImageGM(const char filename[], bool convertToG8 = false)
+ : fFilename(filename), fConvertToG8(convertToG8)
+ {
+ fName.printf("filterbitmap_image_%s%s", filename, convertToG8 ? "_g8" : "");
+ }
- protected:
+protected:
SkString fFilename;
int fSize;
@@ -204,9 +211,15 @@ class FilterBitmapImageGM: public FilterBitmapGM {
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
}
fSize = fBM.height();
+ if (fConvertToG8) {
+ SkBitmap tmp;
+ fBM.copyTo(&tmp, kGray_8_SkColorType);
+ fBM = tmp;
+ }
}
- private:
- typedef FilterBitmapGM INHERITED;
+private:
+ const bool fConvertToG8;
+ typedef FilterBitmapGM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
@@ -216,12 +229,14 @@ DEF_GM( return new FilterBitmapTextGM(7); )
DEF_GM( return new FilterBitmapTextGM(10); )
DEF_GM( return new FilterBitmapCheckerboardGM(4,4); )
DEF_GM( return new FilterBitmapCheckerboardGM(32,32); )
+DEF_GM( return new FilterBitmapCheckerboardGM(32,32, true); )
DEF_GM( return new FilterBitmapCheckerboardGM(32,8); )
DEF_GM( return new FilterBitmapCheckerboardGM(32,2); )
DEF_GM( return new FilterBitmapCheckerboardGM(192,192); )
DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); )
DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); )
DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); )
+DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); )
DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); )
DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); )
DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); )
« no previous file with comments | « no previous file | include/core/SkImageInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698