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

Unified Diff: src/effects/SkPictureImageFilter.cpp

Issue 787073003: Adding an option for pixelated rendering in SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: filter level 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 | « src/core/SkReadBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkPictureImageFilter.cpp
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index e18600db6e24275b78b09fa4e4155c99cd02bc82..8075f365d0b400bca40db92688eb3a7001636c66 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -17,15 +17,18 @@ SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, uint32_t un
: INHERITED(0, 0, NULL, uniqueID)
, fPicture(SkSafeRef(picture))
, fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty())
- , fPictureResolution(kDeviceSpace_PictureResolution) {
+ , fPictureResolution(kDeviceSpace_PictureResolution)
+ , fFilterLevel(SkPaint::kLow_FilterLevel) {
}
SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
- uint32_t uniqueID, PictureResolution pictureResolution)
+ uint32_t uniqueID, PictureResolution pictureResolution,
+ SkPaint::FilterLevel filterLevel)
: INHERITED(0, 0, NULL, uniqueID)
, fPicture(SkSafeRef(picture))
, fCropRect(cropRect)
- , fPictureResolution(pictureResolution) {
+ , fPictureResolution(pictureResolution)
+ , fFilterLevel(filterLevel) {
}
SkPictureImageFilter::~SkPictureImageFilter() {
@@ -49,10 +52,17 @@ SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
pictureResolution = kDeviceSpace_PictureResolution;
} else {
pictureResolution = (PictureResolution)buffer.readInt();
- }
-
- if (pictureResolution == kLocalSpace_PictureResolution) {
- return CreateForLocalSpace(picture, cropRect);
+ }
+
+ if (kLocalSpace_PictureResolution == pictureResolution) {
+ //filterLevel is only serialized if pictureResolution is LocalSpace
Stephen White 2014/12/09 16:54:23 Nit: space between // and "filterLevel"
+ SkPaint::FilterLevel filterLevel;
+ if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) {
+ filterLevel = SkPaint::kLow_FilterLevel;
+ } else {
+ filterLevel = (SkPaint::FilterLevel)buffer.readInt();
+ }
+ return CreateForLocalSpace(picture, cropRect, filterLevel);
}
return Create(picture, cropRect);
}
@@ -69,6 +79,9 @@ void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
}
buffer.writeRect(fCropRect);
buffer.writeInt(fPictureResolution);
+ if (kLocalSpace_PictureResolution == fPictureResolution) {
+ buffer.writeInt(fFilterLevel);
+ }
}
bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
@@ -95,11 +108,11 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
return false;
}
- if (kLocalSpace_PictureResolution == fPictureResolution &&
- (ctx.ctm().getType() & ~SkMatrix::kTranslate_Mask)) {
- drawPictureAtLocalResolution(proxy, device.get(), bounds, ctx);
+ if (kDeviceSpace_PictureResolution == fPictureResolution ||
+ 0 == (ctx.ctm().getType() & ~SkMatrix::kTranslate_Mask)) {
+ drawPictureAtDeviceResolution(proxy, device.get(), bounds, ctx);
} else {
- drawPictureAtDeviceResolution(proxy, device.get(), bounds, ctx);
+ drawPictureAtLocalResolution(proxy, device.get(), bounds, ctx);
}
*result = device.get()->accessBitmap(false);
@@ -149,7 +162,8 @@ void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBounds.fTop));
canvas.concat(ctx.ctm());
SkPaint paint;
- paint.setFilterLevel(SkPaint::kLow_FilterLevel);
- canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(localIBounds.fLeft), SkIntToScalar(localIBounds.fTop), &paint);
+ paint.setFilterLevel(fFilterLevel);
+ canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(localIBounds.fLeft),
+ SkIntToScalar(localIBounds.fTop), &paint);
//canvas.drawPicture(fPicture);
}
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698