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

Unified Diff: gm/imagefilterscropped.cpp

Issue 781153002: Fix Morphology effects sourcing outside of the crop rect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix memory leak and shader compilation error on MacOSX 10.6 Created 5 years, 11 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 | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefilterscropped.cpp
diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp
index 49b0a97f97d0af7048841f3fbcf8c15a9e7a396e..86dfbcb2dfa03b9b59a7453e93b2f04aade80f1a 100644
--- a/gm/imagefilterscropped.cpp
+++ b/gm/imagefilterscropped.cpp
@@ -12,7 +12,9 @@
#include "SkShader.h"
#include "SkBlurImageFilter.h"
+#include "SkMorphologyImageFilter.h"
#include "SkColorFilterImageFilter.h"
+#include "SkBitmapSource.h"
#include "SkMergeImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkTestImageFilters.h"
@@ -98,7 +100,28 @@ protected:
return SkString("imagefilterscropped");
}
- virtual SkISize onISize() { return SkISize::Make(400, 640); }
+ virtual SkISize onISize() { return SkISize::Make(400, 880); }
+
+ void make_checkerboard() {
+ fCheckerboard.allocN32Pixels(80, 80);
+ SkCanvas canvas(fCheckerboard);
+ canvas.clear(SK_ColorTRANSPARENT);
+ SkPaint darkPaint;
+ darkPaint.setColor(0xFF404040);
+ SkPaint lightPaint;
+ lightPaint.setColor(0xFFA0A0A0);
+ for (int y = 0; y < 80; y += 16) {
+ for (int x = 0; x < 80; x += 16) {
+ canvas.save();
+ canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
+ canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
+ canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
+ canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
+ canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
+ canvas.restore();
+ }
+ }
+ }
void draw_frame(SkCanvas* canvas, const SkRect& r) {
SkPaint paint;
@@ -107,6 +130,10 @@ protected:
canvas->drawRect(r, paint);
}
+ virtual void onOnceBeforeDraw() SK_OVERRIDE{
+ make_checkerboard();
+ }
+
virtual void onDraw(SkCanvas* canvas) {
void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = {
draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text
@@ -122,6 +149,9 @@ protected:
SkAutoTUnref<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf.get(), offset.get()));
+ SkAutoTUnref<SkImageFilter> erodeX(SkErodeImageFilter::Create(8, 0, NULL, &cropRect));
+ SkAutoTUnref<SkImageFilter> erodeY(SkErodeImageFilter::Create(0, 8, NULL, &cropRect));
+
SkImageFilter* filters[] = {
NULL,
SkColorFilterImageFilter::Create(cf.get(), NULL, &cropRect),
@@ -129,6 +159,10 @@ protected:
SkBlurImageFilter::Create(8.0f, 0.0f, NULL, &cropRect),
SkBlurImageFilter::Create(0.0f, 8.0f, NULL, &cropRect),
SkBlurImageFilter::Create(8.0f, 8.0f, NULL, &cropRect),
+ SkErodeImageFilter::Create(1, 1, NULL, &cropRect),
+ SkErodeImageFilter::Create(8, 0, erodeY, &cropRect),
+ SkErodeImageFilter::Create(0, 8, erodeX, &cropRect),
+ SkErodeImageFilter::Create(8, 8, NULL, &cropRect),
SkMergeImageFilter::Create(NULL, cfOffset.get(), SkXfermode::kSrcOver_Mode, &cropRect),
SkBlurImageFilter::Create(8.0f, 8.0f, NULL, &bogusRect),
SkColorFilterImageFilter::Create(cf.get(), NULL, &bogusRect),
@@ -143,6 +177,8 @@ protected:
for (size_t j = 0; j < SK_ARRAY_COUNT(drawProc); ++j) {
canvas->save();
for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
+ SkPaint paint;
+ canvas->drawBitmap(fCheckerboard, 0, 0);
drawProc[j](canvas, r, filters[i]);
canvas->translate(0, DY);
}
@@ -156,6 +192,7 @@ protected:
}
private:
+ SkBitmap fCheckerboard;
typedef GM INHERITED;
};
« no previous file with comments | « no previous file | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698