diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 19:43:22 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 19:43:22 +0000 |
commit | d043ccee3788ea4192806bd8c94484ed003fa828 (patch) | |
tree | 68ce7206cd22f64fd6152346b30a18a59489ca29 /src/gpu/SkGpuDevice.cpp | |
parent | 2e87ba0c7c0dfe57e39e6e030db59b69275966cd (diff) |
Allow single-pass filters (which use asNewEffect()) to participate in the image filter DAG. This was done by introducing the SkSinglePassImageFilter abstract base class, which implements canFilterImageGPU() and filterImageGPU() on behalf of the derived class. The derived class still only needs to asNewEffect(). This allows us to recurse on the filter input in SkSinglePassImageFilter::onFilterImageGPU(). It also allows us to remove any knowledge of single-pass image filters from SkGpuDevice and from the SkImageFilter base class as well.
BUG=
Review URL: https://codereview.chromium.org/13602013
git-svn-id: http://skia.googlecode.com/svn/trunk@8563 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 45176cf8c9..c1364afe02 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1404,26 +1404,6 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, fContext->drawRectToRect(*grPaint, dstRect, paintRect, &m); } -namespace { - -void apply_effect(GrContext* context, - GrTexture* srcTexture, - GrTexture* dstTexture, - const GrRect& rect, - GrEffectRef* effect) { - SkASSERT(srcTexture && srcTexture->getContext() == context); - GrContext::AutoMatrix am; - am.setIdentity(context); - GrContext::AutoRenderTarget art(context, dstTexture->asRenderTarget()); - GrContext::AutoClip acs(context, rect); - - GrPaint paint; - paint.colorStage(0)->setEffect(effect); - context->drawRect(paint, rect); -} - -}; - static SkBitmap wrap_texture(GrTexture* texture) { SkBitmap result; bool dummy; @@ -1439,26 +1419,11 @@ static bool filter_texture(SkDevice* device, GrContext* context, GrAssert(filter); SkDeviceImageFilterProxy proxy(device); - GrTextureDesc desc; - desc.fFlags = kRenderTarget_GrTextureFlagBit, - desc.fWidth = w; - desc.fHeight = h; - desc.fConfig = kRGBA_8888_GrPixelConfig; - GrEffectRef* effect; - if (filter->canFilterImageGPU()) { // Save the render target and set it to NULL, so we don't accidentally draw to it in the // filter. Also set the clip wide open and the matrix to identity. GrContext::AutoWideOpenIdentityDraw awo(context, NULL); return filter->filterImageGPU(&proxy, wrap_texture(texture), result); - } else if (filter->asNewEffect(&effect, texture)) { - GrAutoScratchTexture dst(context, desc); - SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); - apply_effect(context, texture, dst.texture(), r, effect); - SkAutoTUnref<GrTexture> resultTex(dst.detach()); - effect->unref(); - *result = wrap_texture(resultTex.get()); - return true; } else { return false; } @@ -1594,11 +1559,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device, } bool SkGpuDevice::canHandleImageFilter(SkImageFilter* filter) { - if (!filter->asNewEffect(NULL, NULL) && - !filter->canFilterImageGPU()) { - return false; - } - return true; + return filter->canFilterImageGPU(); } bool SkGpuDevice::filterImage(SkImageFilter* filter, const SkBitmap& src, |