Remove mask-filters and aa from SkPaint in SkCanvas for nine-patch/lattice.

Remove GPU fallback code which would have applied AA and mask filter
separately to each lattice cell.

Change-Id: I43d50f337d24bb34b94f3d0ea6cca686a2e11a50
Reviewed-on: https://skia-review.googlesource.com/129318
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
This commit is contained in:
Brian Salomon 2018-05-21 14:37:49 -04:00 committed by Skia Commit-Bot
parent 8e3bf09e8e
commit 969be1c98b
4 changed files with 29 additions and 32 deletions

View File

@ -4690,6 +4690,7 @@ Blend_Mode, and Draw_Looper. If #bitmap_or_image# is kAlpha_8_SkColorType, apply
If paint contains Mask_Filter, generate mask from #bitmap_or_image# bounds. If paint If paint contains Mask_Filter, generate mask from #bitmap_or_image# bounds. If paint
Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all
other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels. other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels.
Any SkMaskFilter on the paint is ignored as is the paint's antialiasing state.
## ##
#Method void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, #Method void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,

View File

@ -1734,7 +1734,8 @@ public:
SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
If paint contains SkMaskFilter, generate mask from bitmap bounds. If paint's If paint contains SkMaskFilter, generate mask from bitmap bounds. If paint's
SkFilterQuality is higher than kLow_SkFilterQuality, it will be treated as if it SkFilterQuality is higher than kLow_SkFilterQuality, it will be treated as if it
were kLow_SkFilterQuality. were kLow_SkFilterQuality. Any SkMaskFilter on the paint is ignored as is the paint's
antialiasing state.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as SkShader made from SkShader::MakeBitmapShader with just as SkShader made from SkShader::MakeBitmapShader with
@ -1836,7 +1837,8 @@ public:
SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
If paint contains SkMaskFilter, generate mask from bitmap bounds. If paint's If paint contains SkMaskFilter, generate mask from bitmap bounds. If paint's
SkFilterQuality is higher than kLow_SkFilterQuality, it will be treated as if it SkFilterQuality is higher than kLow_SkFilterQuality, it will be treated as if it
were kLow_SkFilterQuality. were kLow_SkFilterQuality. Any SkMaskFilter on the paint is ignored as is the paint's
antialiasing state.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as SkShader made from SkShader::MakeBitmapShader with just as SkShader made from SkShader::MakeBitmapShader with
@ -1866,7 +1868,8 @@ public:
SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
If paint contains SkMaskFilter, generate mask from bitmap bounds. If paint's If paint contains SkMaskFilter, generate mask from bitmap bounds. If paint's
SkFilterQuality is higher than kLow_SkFilterQuality, it will be treated as if it SkFilterQuality is higher than kLow_SkFilterQuality, it will be treated as if it
were kLow_SkFilterQuality. were kLow_SkFilterQuality. Any SkMaskFilter on the paint is ignored as is the paint's
antialiasing state.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as SkShader made from SkShader::MakeBitmapShader with just as SkShader made from SkShader::MakeBitmapShader with

View File

@ -1745,15 +1745,20 @@ void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPa
} }
namespace { namespace {
class NoneOrLowQualityFilterPaint : SkNoncopyable { class LatticePaint : SkNoncopyable {
public: public:
NoneOrLowQualityFilterPaint(const SkPaint* origPaint) { LatticePaint(const SkPaint* origPaint) : fPaint(origPaint) {
if (origPaint && origPaint->getFilterQuality() > kLow_SkFilterQuality) { if (!origPaint) {
fLazyPaint.set(*origPaint); return;
fLazyPaint.get()->setFilterQuality(kLow_SkFilterQuality); }
fPaint = fLazyPaint.get(); if (origPaint->getFilterQuality() > kLow_SkFilterQuality) {
} else { fPaint.writable()->setFilterQuality(kLow_SkFilterQuality);
fPaint = origPaint; }
if (origPaint->getMaskFilter()) {
fPaint.writable()->setMaskFilter(nullptr);
}
if (origPaint->isAntiAlias()) {
fPaint.writable()->setAntiAlias(false);
} }
} }
@ -1762,8 +1767,7 @@ public:
} }
private: private:
const SkPaint* fPaint; SkTCopyOnFirstWrite<SkPaint> fPaint;
SkLazyPaint fLazyPaint;
}; };
} // namespace } // namespace
@ -1775,8 +1779,8 @@ void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const
return; return;
} }
if (SkLatticeIter::Valid(image->width(), image->height(), center)) { if (SkLatticeIter::Valid(image->width(), image->height(), center)) {
NoneOrLowQualityFilterPaint lowPaint(paint); LatticePaint latticePaint(paint);
this->onDrawImageNine(image, center, dst, lowPaint.get()); this->onDrawImageNine(image, center, dst, latticePaint.get());
} else { } else {
this->drawImageRect(image, dst, paint); this->drawImageRect(image, dst, paint);
} }
@ -1798,8 +1802,8 @@ void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, co
} }
if (SkLatticeIter::Valid(image->width(), image->height(), latticePlusBounds)) { if (SkLatticeIter::Valid(image->width(), image->height(), latticePlusBounds)) {
NoneOrLowQualityFilterPaint lowPaint(paint); LatticePaint latticePaint(paint);
this->onDrawImageLattice(image, latticePlusBounds, dst, lowPaint.get()); this->onDrawImageLattice(image, latticePlusBounds, dst, latticePaint.get());
} else { } else {
this->drawImageRect(image, dst, paint); this->drawImageRect(image, dst, paint);
} }
@ -1840,8 +1844,8 @@ void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con
return; return;
} }
if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), center)) { if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), center)) {
NoneOrLowQualityFilterPaint lowPaint(paint); LatticePaint latticePaint(paint);
this->onDrawBitmapNine(bitmap, center, dst, lowPaint.get()); this->onDrawBitmapNine(bitmap, center, dst, latticePaint.get());
} else { } else {
this->drawBitmapRect(bitmap, dst, paint); this->drawBitmapRect(bitmap, dst, paint);
} }
@ -1862,8 +1866,8 @@ void SkCanvas::drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice,
} }
if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), latticePlusBounds)) { if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), latticePlusBounds)) {
NoneOrLowQualityFilterPaint lowPaint(paint); LatticePaint latticePaint(paint);
this->onDrawBitmapLattice(bitmap, latticePlusBounds, dst, lowPaint.get()); this->onDrawBitmapLattice(bitmap, latticePlusBounds, dst, latticePaint.get());
} else { } else {
this->drawBitmapRect(bitmap, dst, paint); this->drawBitmapRect(bitmap, dst, paint);
} }

View File

@ -1397,17 +1397,6 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerLattice", fContext.get()); GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerLattice", fContext.get());
SkTCopyOnFirstWrite<SkPaint> paint(&origPaint); SkTCopyOnFirstWrite<SkPaint> paint(&origPaint);
bool useFallback = paint->getMaskFilter() || paint->isAntiAlias() ||
GrFSAAType::kUnifiedMSAA == fRenderTargetContext->fsaaType();
if (useFallback) {
SkRect srcR, dstR;
while (iter->next(&srcR, &dstR)) {
this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_SrcRectConstraint,
this->ctm(), *paint);
}
return;
}
if (!producer->isAlphaOnly() && (paint->getColor() & 0x00FFFFFF) != 0x00FFFFFF) { if (!producer->isAlphaOnly() && (paint->getColor() & 0x00FFFFFF) != 0x00FFFFFF) {
paint.writable()->setColor(SkColorSetARGB(origPaint.getAlpha(), 0xFF, 0xFF, 0xFF)); paint.writable()->setColor(SkColorSetARGB(origPaint.getAlpha(), 0xFF, 0xFF, 0xFF));
} }