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; |