Chromium Code Reviews| Index: src/core/SkCanvas.cpp |
| diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
| index 60bda8d36a8786c0db64a45aa966f05d37db3c6c..6bc6a0f9a7dac71602c66813f018d1b24d9da9a8 100644 |
| --- a/src/core/SkCanvas.cpp |
| +++ b/src/core/SkCanvas.cpp |
| @@ -1453,18 +1453,19 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, const SkPa |
| } |
| LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) |
| + |
| while (iter.next()) { |
| SkBaseDevice* dstDev = iter.fDevice; |
| paint = &looper.paint(); |
| SkImageFilter* filter = paint->getImageFilter(); |
| SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
|
robertphillips
2016/07/18 17:01:58
Why not just call drawSpecial in both cases ?
reed1
2016/07/18 22:06:07
PDFDevice doesn't return a special (he will have r
|
| if (filter) { |
| - const SkBitmap& srcBM = srcDev->accessBitmap(false); |
| - dstDev->drawSpriteWithFilter(iter, srcBM, pos.x(), pos.y(), *paint); |
| + dstDev->drawSpecial(iter, srcDev->asSpecial().get(), pos.x(), pos.y(), *paint); |
| } else { |
| dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); |
| } |
| } |
| + |
| LOOPER_END |
| } |
| @@ -2312,15 +2313,16 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S |
| paint = lazy.init(); |
| } |
| + sk_sp<SkSpecialImage> special; |
| bool drawAsSprite = this->canDrawBitmapAsSprite(x, y, image->width(), image->height(), |
| *paint); |
| if (drawAsSprite && paint->getImageFilter()) { |
| - SkBitmap bitmap; |
| - if (!as_IB(image)->asBitmapForImageFilters(&bitmap)) { |
| + // Until imagefilters are updated, they cannot handle any src type but N32... |
| + if (!as_IB(image)->canBeImageFiltered()) { |
| drawAsSprite = false; |
| - } else{ |
| - // Until imagefilters are updated, they cannot handle any src type but N32... |
| - if (bitmap.info().colorType() != kN32_SkColorType || bitmap.info().gammaCloseToSRGB()) { |
| + } else { |
| + special = this->getDevice()->makeSpecial(image); |
| + if (!special) { |
| drawAsSprite = false; |
| } |
| } |
| @@ -2331,14 +2333,11 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S |
| while (iter.next()) { |
| const SkPaint& pnt = looper.paint(); |
|
robertphillips
2016/07/18 17:01:58
ditch drawAsSprite and just use special here ?
reed1
2016/07/19 15:07:41
Done.
|
| if (drawAsSprite && pnt.getImageFilter()) { |
| - SkBitmap bitmap; |
| - if (as_IB(image)->asBitmapForImageFilters(&bitmap)) { |
| - SkPoint pt; |
| - iter.fMatrix->mapXY(x, y, &pt); |
| - iter.fDevice->drawSpriteWithFilter(iter, bitmap, |
| - SkScalarRoundToInt(pt.fX), |
| - SkScalarRoundToInt(pt.fY), pnt); |
| - } |
| + SkPoint pt; |
| + iter.fMatrix->mapXY(x, y, &pt); |
| + iter.fDevice->drawSpecial(iter, special.get(), |
| + SkScalarRoundToInt(pt.fX), |
| + SkScalarRoundToInt(pt.fY), pnt); |
| } else { |
| iter.fDevice->drawImage(iter, image, x, y, pnt); |
| } |
| @@ -2401,12 +2400,18 @@ void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons |
| bounds = &storage; |
| } |
| + sk_sp<SkSpecialImage> special; |
| bool drawAsSprite = bounds && this->canDrawBitmapAsSprite(x, y, bitmap.width(), bitmap.height(), |
| *paint); |
| if (drawAsSprite && paint->getImageFilter()) { |
| // Until imagefilters are updated, they cannot handle any src type but N32... |
| if (bitmap.info().colorType() != kN32_SkColorType || bitmap.info().gammaCloseToSRGB()) { |
| drawAsSprite = false; |
| + } else { |
| + special = this->getDevice()->makeSpecial(bitmap); |
|
robertphillips
2016/07/18 17:01:58
I think we don't need the following if block
|
| + if (!special) { |
| + drawAsSprite = false; |
| + } |
| } |
| } |
| @@ -2414,17 +2419,17 @@ void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons |
| while (iter.next()) { |
| const SkPaint& pnt = looper.paint(); |
| - if (drawAsSprite && pnt.getImageFilter()) { |
| + if (special) { |
| SkPoint pt; |
| iter.fMatrix->mapXY(x, y, &pt); |
| - iter.fDevice->drawSpriteWithFilter(iter, bitmap, |
| - SkScalarRoundToInt(pt.fX), |
| - SkScalarRoundToInt(pt.fY), pnt); |
| + iter.fDevice->drawSpecial(iter, special.get(), |
| + SkScalarRoundToInt(pt.fX), |
| + SkScalarRoundToInt(pt.fY), pnt); |
| } else { |
| iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint()); |
| } |
| } |
| - |
| + |
| LOOPER_END |
| } |