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

Unified Diff: gm/tileimagefilter.cpp

Issue 258243005: Implement bounds traversals for tile and matrix convolution filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | « expectations/gm/ignored-tests.txt ('k') | include/effects/SkMatrixConvolutionImageFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/tileimagefilter.cpp
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index d6c8d4cbfc26bca9df18460b0410ff07fc60795c..c7842ee97cd611116614120037a69ca7aa3726e1 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -6,6 +6,8 @@
*/
#include "gm.h"
+#include "SkColorMatrixFilter.h"
+#include "SkColorFilterImageFilter.h"
#include "SkTileImageFilter.h"
#include "SkBitmapSource.h"
@@ -27,15 +29,15 @@ protected:
}
void make_bitmap() {
- fBitmap.allocN32Pixels(80, 80);
+ fBitmap.allocN32Pixels(50, 50);
SkCanvas canvas(fBitmap);
canvas.clear(0xFF000000);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0xD000D000);
- paint.setTextSize(SkIntToScalar(96));
+ paint.setTextSize(SkIntToScalar(50));
const char* str = "e";
- canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(65), paint);
+ canvas.drawText(str, strlen(str), SkIntToScalar(10), SkIntToScalar(45), paint);
}
void make_checkerboard() {
@@ -70,7 +72,6 @@ protected:
fInitialized = true;
}
canvas->clear(0x00000000);
- SkPaint paint;
int x = 0, y = 0;
for (size_t i = 0; i < 4; i++) {
@@ -88,6 +89,7 @@ protected:
SkTileImageFilter::Create(srcRect, dstRect, tileInput));
canvas->save();
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
+ SkPaint paint;
paint.setImageFilter(filter);
canvas->drawBitmap(fBitmap, 0, 0, &paint);
canvas->restore();
@@ -97,6 +99,29 @@ protected:
y += bitmap->height() + MARGIN;
}
}
+
+ SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
+ 0, SK_Scalar1, 0, 0, 0,
+ 0, 0, SK_Scalar1, 0, 0,
+ 0, 0, 0, SK_Scalar1, 0 };
+
+ SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width()),
+ SkIntToScalar(fBitmap.height()));
+ SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() * 2),
+ SkIntToScalar(fBitmap.height() * 2));
+ SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(srcRect, dstRect, NULL));
+ SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(matrix));
+
+ SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf, tile.get()));
+ SkPaint paint;
+ paint.setImageFilter(cfif);
+ canvas->save();
+ canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
+ canvas->clipRect(dstRect);
+ canvas->saveLayer(&dstRect, &paint);
+ canvas->drawBitmap(fBitmap, 0, 0);
+ canvas->restore();
+ canvas->restore();
}
private:
typedef GM INHERITED;
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/effects/SkMatrixConvolutionImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698