Remove mask-filters and aa from SkPaint in SkCanvas for nine-patch/lattice.
authorBrian Salomon <bsalomon@google.com>
Mon, 21 May 2018 18:37:49 +0000 (14:37 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 21 May 2018 19:10:08 +0000 (19:10 +0000)
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>
docs/SkCanvas_Reference.bmh
include/core/SkCanvas.h
src/core/SkCanvas.cpp
src/gpu/SkGpuDevice.cpp

index 6c12339ce37cd8a055571a52c49782de8f976126..2990a8c48cecc6820643c78f5bf609f7d758d82c 100644 (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
 Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all
 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,
index 12f192684423bab0ae50aa64a56d4574fa0805b2..8a46320ea90a5fbe591d384532afd84730518b82 100644 (file)
@@ -1734,7 +1734,8 @@ public:
         SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
         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
-        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,
         just as SkShader made from SkShader::MakeBitmapShader with
@@ -1836,7 +1837,8 @@ public:
         SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
         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
-        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,
         just as SkShader made from SkShader::MakeBitmapShader with
@@ -1866,7 +1868,8 @@ public:
         SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader.
         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
-        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,
         just as SkShader made from SkShader::MakeBitmapShader with
index 00bbdf418ee35a1ff34681060ffcafb744943b04..8230fb3928f6394dbe9ad48445a65378a38300d3 100644 (file)
@@ -1745,15 +1745,20 @@ void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPa
 }
 
 namespace {
-class NoneOrLowQualityFilterPaint : SkNoncopyable {
+class LatticePaint : SkNoncopyable {
 public:
-    NoneOrLowQualityFilterPaint(const SkPaint* origPaint) {
-        if (origPaint && origPaint->getFilterQuality() > kLow_SkFilterQuality) {
-            fLazyPaint.set(*origPaint);
-            fLazyPaint.get()->setFilterQuality(kLow_SkFilterQuality);
-            fPaint = fLazyPaint.get();
-        } else {
-            fPaint = origPaint;
+    LatticePaint(const SkPaint* origPaint) : fPaint(origPaint) {
+        if (!origPaint) {
+            return;
+        }
+        if (origPaint->getFilterQuality() > kLow_SkFilterQuality) {
+            fPaint.writable()->setFilterQuality(kLow_SkFilterQuality);
+        }
+        if (origPaint->getMaskFilter()) {
+            fPaint.writable()->setMaskFilter(nullptr);
+        }
+        if (origPaint->isAntiAlias()) {
+            fPaint.writable()->setAntiAlias(false);
         }
     }
 
@@ -1762,8 +1767,7 @@ public:
     }
 
 private:
-    const SkPaint* fPaint;
-    SkLazyPaint fLazyPaint;
+    SkTCopyOnFirstWrite<SkPaint> fPaint;
 };
 } // namespace
 
@@ -1775,8 +1779,8 @@ void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const
         return;
     }
     if (SkLatticeIter::Valid(image->width(), image->height(), center)) {
-        NoneOrLowQualityFilterPaint lowPaint(paint);
-        this->onDrawImageNine(image, center, dst, lowPaint.get());
+        LatticePaint latticePaint(paint);
+        this->onDrawImageNine(image, center, dst, latticePaint.get());
     } else {
         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)) {
-        NoneOrLowQualityFilterPaint lowPaint(paint);
-        this->onDrawImageLattice(image, latticePlusBounds, dst, lowPaint.get());
+        LatticePaint latticePaint(paint);
+        this->onDrawImageLattice(image, latticePlusBounds, dst, latticePaint.get());
     } else {
         this->drawImageRect(image, dst, paint);
     }
@@ -1840,8 +1844,8 @@ void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con
         return;
     }
     if (SkLatticeIter::Valid(bitmap.width(), bitmap.height(), center)) {
-        NoneOrLowQualityFilterPaint lowPaint(paint);
-        this->onDrawBitmapNine(bitmap, center, dst, lowPaint.get());
+        LatticePaint latticePaint(paint);
+        this->onDrawBitmapNine(bitmap, center, dst, latticePaint.get());
     } else {
         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)) {
-        NoneOrLowQualityFilterPaint lowPaint(paint);
-        this->onDrawBitmapLattice(bitmap, latticePlusBounds, dst, lowPaint.get());
+        LatticePaint latticePaint(paint);
+        this->onDrawBitmapLattice(bitmap, latticePlusBounds, dst, latticePaint.get());
     } else {
         this->drawBitmapRect(bitmap, dst, paint);
     }
index 27daab6479bdb5dac43bb54e26c7a621fb38c557..883f32605ae7c75dcfa7cbc5293c0a43c0a0ac86 100644 (file)
@@ -1397,17 +1397,6 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerLattice", fContext.get());
     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) {
         paint.writable()->setColor(SkColorSetARGB(origPaint.getAlpha(), 0xFF, 0xFF, 0xFF));
     }