Index: src/image/SkImage_Gpu.cpp |
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp |
index b1f78513ecfe394e1f1a1d6ba5e241add7426836..e1834be97f55ac638d3db365a56465919466ce0e 100644 |
--- a/src/image/SkImage_Gpu.cpp |
+++ b/src/image/SkImage_Gpu.cpp |
@@ -24,7 +24,13 @@ SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText |
, fAlphaType(at) |
, fBudgeted(budgeted) |
, fAddedRasterVersionToCache(false) |
- {} |
+{ |
+ // At the moment, we can't handle general transformations on textures (e.g. tiling, |
+ // mip/filtering) unless they are exactly sized to match the "logical" size (image size). |
+ // Hence these asserts. |
+ SkASSERT(tex->width() == w); |
+ SkASSERT(tex->height() == h); |
+} |
SkImage_Gpu::~SkImage_Gpu() { |
if (fAddedRasterVersionToCache.load()) { |
@@ -187,10 +193,10 @@ SkImage* SkImage_Gpu::onNewSubset(const SkIRect& subset) const { |
#include "SkImageFilter.h" |
class SkGpuImageFilterProxy : public SkImageFilter::Proxy { |
- GrContext* fCtx; |
- |
public: |
- SkGpuImageFilterProxy(GrContext* ctx) : fCtx(ctx) {} |
+ SkGpuImageFilterProxy(GrContext* ctx, bool requireExactTexSize) |
+ : INHERITED(requireExactTexSize), fCtx(ctx) |
+ {} |
SkBaseDevice* createDevice(int width, int height) override { |
GrSurfaceDesc desc; |
@@ -216,6 +222,11 @@ public: |
return filter->canFilterImageGPU() && |
filter->filterImageGPU(this, src, ctx, dst, offset); |
} |
+ |
+private: |
+ GrContext* fCtx; |
+ |
+ typedef Proxy INHERITED; |
}; |
static SkIRect compute_fast_ibounds(SkImageFilter* filter, const SkIRect& srcBounds) { |
@@ -233,10 +244,14 @@ SkImage* SkImage_Gpu::onApplyFilter(SkImageFilter* filter, SkIPoint* offsetResul |
SkBitmap src; |
GrWrapTextureInBitmap(fTexture, this->width(), this->height(), this->isOpaque(), &src); |
- const SkIRect clipBounds = srcBounds; |
- SkGpuImageFilterProxy proxy(fTexture->getContext()); |
+ // Since we want to return an image that wraps the filter's texture, and our clients |
+ // assume (at the moment) that the image can be scaled/tiled etc., we must have an exact |
+ // sized texture (matching the image's logical size). Hence we pass true to the Proxy's |
+ // constructor. |
robertphillips
2015/10/21 15:29:41
kRequireExactTexSize ?
reed1
2015/10/21 17:05:51
Done.
|
+ const bool requireExactTexSize = true; |
+ SkGpuImageFilterProxy proxy(fTexture->getContext(), requireExactTexSize); |
SkAutoTUnref<SkImageFilter::Cache> cache(SkGpuDevice::NewImageFilterCache()); |
- SkImageFilter::Context ctx(SkMatrix::I(), clipBounds, cache); |
+ SkImageFilter::Context ctx(SkMatrix::I(), srcBounds, cache); |
SkBitmap dst; |
if (!filter->filterImage(&proxy, src, ctx, &dst, offsetResult)) { |