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

Unified Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 920513003: Make filters use SkImage instead of SkBitmap Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMagnifierImageFilter.cpp
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index eaac30cac3981d7a9eac72bf6c7773463e6ef2a0..99ca87db6636fbb0c0ec40ac0b52e6ef31c881e1 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -6,11 +6,12 @@
*/
#include "SkBitmap.h"
-#include "SkMagnifierImageFilter.h"
#include "SkColorPriv.h"
+#include "SkImagePriv.h"
+#include "SkMagnifierImageFilter.h"
#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
#include "SkValidationUtils.h"
+#include "SkWriteBuffer.h"
////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
@@ -288,33 +289,32 @@ void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalar(fInset);
}
-bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
- const Context&, SkBitmap* dst,
+bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkImage* src,
+ const Context&, SkAutoTUnref<const SkImage>& dst,
SkIPoint* offset) const {
- if ((src.colorType() != kN32_SkColorType) ||
- (fSrcRect.width() >= src.width()) ||
- (fSrcRect.height() >= src.height())) {
+ if ((fSrcRect.width() >= src->width()) ||
+ (fSrcRect.height() >= src->height())) {
return false;
}
-
- SkAutoLockPixels alp(src);
- SkASSERT(src.getPixels());
- if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) {
+ SkBitmap srcBitmap;
+ SkAutoImageAsN32Bitmap aai(src, &srcBitmap);
+ if (!srcBitmap.getPixels() || srcBitmap.width() <= 0 || srcBitmap.height() <= 0) {
return false;
}
- if (!dst->tryAllocPixels(src.info())) {
+ SkBitmap dstBitmap;
+ if (!dstBitmap.tryAllocPixels(srcBitmap.info())) {
return false;
}
SkScalar inv_inset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1;
- SkScalar inv_x_zoom = fSrcRect.width() / src.width();
- SkScalar inv_y_zoom = fSrcRect.height() / src.height();
+ SkScalar inv_x_zoom = fSrcRect.width() / srcBitmap.width();
+ SkScalar inv_y_zoom = fSrcRect.height() / srcBitmap.height();
- SkColor* sptr = src.getAddr32(0, 0);
- SkColor* dptr = dst->getAddr32(0, 0);
- int width = src.width(), height = src.height();
+ SkColor* sptr = srcBitmap.getAddr32(0, 0);
+ SkColor* dptr = dstBitmap.getAddr32(0, 0);
+ int width = srcBitmap.width(), height = srcBitmap.height();
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
SkScalar x_dist = SkMin32(x, width - x - 1) * inv_inset;
@@ -351,6 +351,14 @@ bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
dptr++;
}
}
+ srcBitmap = SkBitmap();
+ SkImage* image = SkNewImageFromBitmap(dstBitmap, NULL);
+ if (NULL == image) {
+ return false;
+ }
+ dst.reset(image);
+ offset->fX = 0;
+ offset->fY = 0;
return true;
}
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698