Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index 6f718e62064e5d5c59a7b00a9d121b1b793be262..70c0562c11db586ed2b3d5669f70ec4d677e05d3 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -1578,7 +1578,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
const SkImageFilter* filter, |
const SkImageFilter::Context& ctx, |
- SkBitmap* result, SkIPoint* offset) { |
+ SkAutoTUnref<const SkImage>& result, SkIPoint* offset) { |
SkASSERT(filter); |
// FIXME: plumb actual surface props such that we don't have to lie about the flags here |
@@ -1588,7 +1588,10 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
if (filter->canFilterImageGPU()) { |
SkBitmap filterInput; |
wrap_surface(texture, &filterInput); |
- return filter->filterImageGPU(&proxy, filterInput, ctx, result, offset); |
+ SkAutoTUnref<const SkImage> src(SkNewImageFromBitmapTexture(filterInput, |
+ texture->desc().fSampleCnt, |
+ SkSurface::kYes_Budgeted)); |
+ return filter->filterImageGPU(&proxy, src, ctx, result, offset); |
} else { |
return false; |
} |
@@ -1633,7 +1636,7 @@ void SkGpuDevice::internalDrawSprite(const SkDraw& draw, GrTexture* texture, |
SkAutoTUnref<GrTexture> src(SkRef(texture)); |
if (SkImageFilter* filter = paint.getImageFilter()) { |
// This bitmap will own the filtered result as a texture. |
- SkBitmap filteredBitmap; |
+ SkAutoTUnref<const SkImage> filteredImage; |
SkIPoint offset = SkIPoint::Make(0, 0); |
SkMatrix matrix(*draw.fMatrix); |
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
@@ -1642,11 +1645,11 @@ void SkGpuDevice::internalDrawSprite(const SkDraw& draw, GrTexture* texture, |
// This cache is transient, and is freed (along with all its contained |
// textures) when it goes out of scope. |
SkImageFilter::Context ctx(matrix, clipBounds, cache); |
- if (this->filterTexture(fContext, texture, filter, ctx, &filteredBitmap, |
+ if (this->filterTexture(fContext, texture, filter, ctx, filteredImage, |
&offset)) { |
- src.reset(SkRef(filteredBitmap.getTexture())); |
- width = filteredBitmap.width(); |
- height = filteredBitmap.height(); |
+ src.reset(SkRef(filteredImage->getTexture())); |
+ width = filteredImage->width(); |
+ height = filteredImage->height(); |
left += offset.x(); |
top += offset.y(); |
} else { |
@@ -1742,8 +1745,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
int h = devImage->height(); |
SkImageFilter* filter = paint.getImageFilter(); |
- // This bitmap will own the filtered result as a texture. |
- SkBitmap filteredBitmap; |
+ SkAutoTUnref<const SkImage> filteredImage; |
if (filter) { |
SkIPoint offset = SkIPoint::Make(0, 0); |
@@ -1754,11 +1756,11 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
// textures) when it goes out of scope. |
SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
SkImageFilter::Context ctx(matrix, clipBounds, cache); |
- if (this->filterTexture(fContext, devTex, filter, ctx, &filteredBitmap, |
+ if (this->filterTexture(fContext, devTex, filter, ctx, filteredImage, |
&offset)) { |
- devTex = filteredBitmap.getTexture(); |
- w = filteredBitmap.width(); |
- h = filteredBitmap.height(); |
+ devTex = filteredImage->getTexture(); |
+ w = filteredImage->width(); |
+ h = filteredImage->height(); |
x += offset.fX; |
y += offset.fY; |
} else { |
@@ -1792,23 +1794,24 @@ bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { |
return filter->canFilterImageGPU(); |
} |
-bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, |
+bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkImage* src, |
const SkImageFilter::Context& ctx, |
- SkBitmap* result, SkIPoint* offset) { |
+ SkAutoTUnref<const SkImage>& result, SkIPoint* offset) { |
// want explicitly our impl, so guard against a subclass of us overriding it |
if (!this->SkGpuDevice::canHandleImageFilter(filter)) { |
return false; |
} |
- SkAutoLockPixels alp(src, !src.getTexture()); |
- if (!src.getTexture() && !src.readyToDraw()) { |
- return false; |
- } |
+ //TODO: SkAutoLockPixels alp(src, !src.getTexture()); |
+ //TODO: if !src->readyToDraw() |
GrTexture* texture; |
// We assume here that the filter will not attempt to tile the src. Otherwise, this cache lookup |
// must be pushed upstack. |
AutoBitmapTexture abt(fContext, src, NULL, &texture); |
+ if (!texture) { |
+ return false; |
+ } |
return this->filterTexture(fContext, texture, filter, ctx, result, offset); |
} |