aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/morphology.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-10 17:25:44 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-10 17:25:44 +0000
commit56dd630c41d662bcf2a3f08100f2c6accda05ba9 (patch)
tree94f1d1ea22e58dd214af8fb97d8ba6947e3ecc17 /gm/morphology.cpp
parent0e5104c1570de4709e04720e62d80a0ca8970260 (diff)
Clamp dilate and erode radius to image width and height.
NOTE: This will require new baselines for the morphology GM. git-svn-id: http://skia.googlecode.com/svn/trunk@3641 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/morphology.cpp')
-rw-r--r--gm/morphology.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/gm/morphology.cpp b/gm/morphology.cpp
index bfaa406336..29d29d0cb6 100644
--- a/gm/morphology.cpp
+++ b/gm/morphology.cpp
@@ -50,37 +50,37 @@ protected:
fOnce = true;
}
struct {
+ int fWidth, fHeight;
int fRadiusX, fRadiusY;
- bool erode;
- SkScalar fX, fY;
} samples[] = {
- { 0, 0, false, 0, 0 },
- { 0, 2, false, 140, 0 },
- { 2, 0, false, 280, 0 },
- { 2, 2, false, 420, 0 },
- { 0, 0, true, 0, 140 },
- { 0, 2, true, 140, 140 },
- { 2, 0, true, 280, 140 },
- { 2, 2, true, 420, 140 },
+ { 140, 140, 0, 0 },
+ { 140, 140, 0, 2 },
+ { 140, 140, 2, 0 },
+ { 140, 140, 2, 2 },
+ { 24, 24, 25, 25 },
};
- const char* str = "The quick brown fox jumped over the lazy dog.";
SkPaint paint;
- for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) {
- if (samples[i].erode) {
- paint.setImageFilter(new SkErodeImageFilter(
- samples[i].fRadiusX,
- samples[i].fRadiusY))->unref();
- } else {
- paint.setImageFilter(new SkDilateImageFilter(
- samples[i].fRadiusX,
- samples[i].fRadiusY))->unref();
+ for (unsigned j = 0; j < 2; ++j) {
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) {
+ SkScalar x = SkIntToScalar(i * 140), y = SkIntToScalar(j * 140);
+ if (j) {
+ paint.setImageFilter(new SkErodeImageFilter(
+ samples[i].fRadiusX,
+ samples[i].fRadiusY))->unref();
+ } else {
+ paint.setImageFilter(new SkDilateImageFilter(
+ samples[i].fRadiusX,
+ samples[i].fRadiusY))->unref();
+ }
+ SkRect bounds = SkRect::MakeXYWH(
+ x,
+ y,
+ SkIntToScalar(samples[i].fWidth),
+ SkIntToScalar(samples[i].fHeight));
+ canvas->saveLayer(&bounds, &paint);
+ canvas->drawBitmap(fBitmap, x, y);
+ canvas->restore();
}
- SkRect bounds = SkRect::MakeXYWH(samples[i].fX,
- samples[i].fY,
- 140, 140);
- canvas->saveLayer(&bounds, &paint);
- canvas->drawBitmap(fBitmap, samples[i].fX, samples[i].fY);
- canvas->restore();
}
}