diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-01-06 14:43:09 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-01-06 14:43:09 +0000 |
commit | b55deeb1c7c692023603639a9b29c0e3de124eac (patch) | |
tree | 700cd48c2047c233ab2a8ed27331b48eff2e517f /src | |
parent | 3c10a0871b1a664441ff53df9a8c57005e247116 (diff) |
add allowImageFilter() so a device can allow/disallow filters
(esp. for printing)
git-svn-id: http://skia.googlecode.com/svn/trunk@2981 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 21 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 4 | ||||
-rw-r--r-- | src/device/xps/SkXPSDevice.cpp | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 5 |
4 files changed, 31 insertions, 5 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index e9fcb57f01..87da90ad9f 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -732,6 +732,16 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, return count; } + // Kill the imagefilter if our device doesn't allow it + SkLazyPaint lazyP; + if (paint && paint->getImageFilter()) { + if (!this->getTopDevice()->allowImageFilter(paint->getImageFilter())) { + SkPaint* p = lazyP.set(*paint); + p->setImageFilter(NULL); + paint = p; + } + } + bool isOpaque; SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque); @@ -889,7 +899,7 @@ bool DeviceImageFilterProxy::filterImage(SkImageFilter* filter, return fDevice->filterImage(filter, src, ctm, result, offset); } -void SkCanvas::drawDevice(SkDevice* device, int x, int y, +void SkCanvas::drawDevice(SkDevice* srcDev, int x, int y, const SkPaint* paint) { SkPaint tmp; if (NULL == paint) { @@ -899,20 +909,21 @@ void SkCanvas::drawDevice(SkDevice* device, int x, int y, LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type) while (iter.next()) { + SkDevice* dstDev = iter.fDevice; paint = &looper.paint(); SkImageFilter* filter = paint->getImageFilter(); SkIPoint pos = { x - iter.getX(), y - iter.getY() }; if (filter) { - DeviceImageFilterProxy proxy(device); + DeviceImageFilterProxy proxy(dstDev); SkBitmap dst; - const SkBitmap& src = device->accessBitmap(false); + const SkBitmap& src = srcDev->accessBitmap(false); if (filter->filterImage(&proxy, src, *iter.fMatrix, &dst, &pos)) { SkPaint tmp(*paint); tmp.setImageFilter(NULL); - iter.fDevice->drawSprite(iter, dst, pos.x(), pos.y(), tmp); + dstDev->drawSprite(iter, dst, pos.x(), pos.y(), tmp); } } else { - iter.fDevice->drawDevice(iter, device, pos.x(), pos.y(), *paint); + dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); } } LOOPER_END diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 578d0c88eb..aaafb14fd1 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -107,6 +107,10 @@ bool SkDevice::filterImage(SkImageFilter*, const SkBitmap& src, return false; } +bool SkDevice::allowImageFilter(SkImageFilter*) { + return true; +} + /////////////////////////////////////////////////////////////////////////////// bool SkDevice::readPixels(SkBitmap* bitmap, int x, int y, diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp index a32eb26adc..e2e23fa1ab 100644 --- a/src/device/xps/SkXPSDevice.cpp +++ b/src/device/xps/SkXPSDevice.cpp @@ -2384,6 +2384,7 @@ SkDevice* SkXPSDevice::onCreateCompatibleDevice(SkBitmap::Config config, bool isOpaque, Usage usage) { if (SkDevice::kGeneral_Usage == usage) { + return NULL; SK_CRASH(); //To what stream do we write? //SkXPSDevice* dev = new SkXPSDevice(this); @@ -2409,3 +2410,8 @@ SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory) HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), "Could not create canvas for layer."); } + +bool SkXPSDevice::allowImageFilter(SkImageFilter*) { + return false; +} + diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index ced3107363..ba889567bb 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -1535,3 +1535,8 @@ bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888) { return false; } + +bool SkPDFDevice::allowImageFilter(SkImageFilter*) { + return false; +} + |