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

Unified Diff: gm/filterbitmap.cpp

Issue 103913012: Tweaks in how to apply bitmap filter levels in GPU. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: upload again, rietveld diff failed. Created 7 years 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 | src/core/SkBitmapProcShader.cpp » ('j') | src/core/SkBitmapProcShader.cpp » ('J')
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 1ec6c8f378b8331195ef6869af61abf2e3c8dfc4..efe4d4aa2b5cabd5144538742e05262a84c628f8 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -23,8 +23,7 @@ static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
return SkSize::Make(bounds.width(), bounds.height());
}
-static void draw_col(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
- SkScalar dx) {
+static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
SkPaint paint;
SkAutoCanvasRestore acr(canvas, true);
@@ -35,6 +34,10 @@ static void draw_col(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
+ paint.setFilterLevel(SkPaint::kMedium_FilterLevel);
+ canvas->translate(dx, 0);
+ canvas->drawBitmapMatrix(bm, mat, &paint);
+
paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
@@ -43,20 +46,23 @@ static void draw_col(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
class FilterBitmapGM : public skiagm::GM {
void onOnceBeforeDraw() {
- make_bitmap();
+ this->makeBitmap();
SkScalar cx = SkScalarHalf(fBM.width());
SkScalar cy = SkScalarHalf(fBM.height());
- SkScalar scale = get_scale();
-
+ SkScalar scale = this->getScale();
+ // these two matrices use a scale factor configured by the subclass
fMatrix[0].setScale(scale, scale);
fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(scale, scale);
+
+ // up/down scaling mix
+ fMatrix[2].setScale(0.7f, 1.05f);
}
public:
SkBitmap fBM;
- SkMatrix fMatrix[2];
+ SkMatrix fMatrix[3];
SkString fName;
FilterBitmapGM()
@@ -70,11 +76,11 @@ protected:
}
virtual SkISize onISize() SK_OVERRIDE {
- return SkISize::Make(920, 480);
+ return SkISize::Make(1024, 768);
}
- virtual void make_bitmap() = 0;
- virtual SkScalar get_scale() = 0;
+ virtual void makeBitmap() = 0;
+ virtual SkScalar getScale() = 0;
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
@@ -84,7 +90,7 @@ protected:
size.fWidth += 20;
size.fHeight += 20;
- draw_col(canvas, fBM, fMatrix[i], size.fWidth);
+ draw_row(canvas, fBM, fMatrix[i], size.fWidth);
canvas->translate(0, size.fHeight);
}
}
@@ -104,11 +110,11 @@ class FilterBitmapTextGM: public FilterBitmapGM {
protected:
float fTextSize;
- SkScalar get_scale() SK_OVERRIDE {
+ SkScalar getScale() SK_OVERRIDE {
return 32.f/fTextSize;
}
- void make_bitmap() SK_OVERRIDE {
+ void makeBitmap() SK_OVERRIDE {
fBM.setConfig(SkBitmap::kARGB_8888_Config, int(fTextSize * 8), int(fTextSize * 6));
fBM.allocPixels();
SkCanvas canvas(fBM);
@@ -144,11 +150,11 @@ class FilterBitmapCheckerboardGM: public FilterBitmapGM {
int fSize;
int fNumChecks;
- SkScalar get_scale() SK_OVERRIDE {
+ SkScalar getScale() SK_OVERRIDE {
return 192.f/fSize;
}
- void make_bitmap() SK_OVERRIDE {
+ void makeBitmap() SK_OVERRIDE {
fBM.setConfig(SkBitmap::kARGB_8888_Config, fSize, fSize);
fBM.allocPixels();
SkAutoLockPixels lock(fBM);
@@ -181,11 +187,11 @@ class FilterBitmapImageGM: public FilterBitmapGM {
SkString fFilename;
int fSize;
- SkScalar get_scale() SK_OVERRIDE {
+ SkScalar getScale() SK_OVERRIDE {
return 192.f/fSize;
}
- void make_bitmap() SK_OVERRIDE {
+ void makeBitmap() SK_OVERRIDE {
SkString path(skiagm::GM::gResourcePath);
path.append("/");
path.append(fFilename);
« no previous file with comments | « no previous file | src/core/SkBitmapProcShader.cpp » ('j') | src/core/SkBitmapProcShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698