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

Unified Diff: gm/pictureimagefilter.cpp

Issue 753073010: Adding a PictureResolution option to SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebased again Created 6 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 | « expectations/gm/ignored-tests.txt ('k') | include/core/SkPicture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/pictureimagefilter.cpp
diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp
index 4e169f77dae0e323c9bbe4b6c3522aac0f65c3d7..712e059a6dfc2b78fef1827524bc27b7bb9e5bac 100644
--- a/gm/pictureimagefilter.cpp
+++ b/gm/pictureimagefilter.cpp
@@ -36,7 +36,7 @@ protected:
fPicture.reset(recorder.endRecording());
}
- virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(500, 150); }
+ virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(400, 300); }
virtual void onOnceBeforeDraw() SK_OVERRIDE {
this->makePicture();
@@ -57,10 +57,16 @@ protected:
SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
SkRect emptyRect = SkRect::MakeXYWH(20, 20, 0, 0);
SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
- SkAutoTUnref<SkImageFilter> pictureSource(SkPictureImageFilter::Create(fPicture));
- SkAutoTUnref<SkImageFilter> pictureSourceSrcRect(SkPictureImageFilter::Create(fPicture, srcRect));
- SkAutoTUnref<SkImageFilter> pictureSourceEmptyRect(SkPictureImageFilter::Create(fPicture, emptyRect));
-
+ SkAutoTUnref<SkPictureImageFilter> pictureSource(
+ SkPictureImageFilter::Create(fPicture));
+ SkAutoTUnref<SkPictureImageFilter> pictureSourceSrcRect(
+ SkPictureImageFilter::Create(fPicture, srcRect));
+ SkAutoTUnref<SkPictureImageFilter> pictureSourceEmptyRect(
+ SkPictureImageFilter::Create(fPicture, emptyRect));
+ SkAutoTUnref<SkPictureImageFilter> pictureSourceResampled(
+ SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect()));
+
+ canvas->save();
// Draw the picture unscaled.
fillRectFiltered(canvas, bounds, pictureSource);
canvas->translate(SkIntToScalar(100), 0);
@@ -72,6 +78,18 @@ protected:
// Draw the picture to an empty rect (should draw nothing).
fillRectFiltered(canvas, bounds, pictureSourceEmptyRect);
canvas->translate(SkIntToScalar(100), 0);
+
+ canvas->restore();
+
+ // Draw the picture scaled
+ canvas->translate(0, SkIntToScalar(100));
+ canvas->scale(200 / srcRect.width(), 200 / srcRect.height());
+ canvas->translate(-srcRect.fLeft, -srcRect.fTop);
+ fillRectFiltered(canvas, srcRect, pictureSource);
+
+ // Draw the picture scaled, but rasterized at original resolution
+ canvas->translate(srcRect.width(), 0);
+ fillRectFiltered(canvas, srcRect, pictureSourceResampled);
}
}
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698