diff options
author | 2018-04-13 15:50:01 -0400 | |
---|---|---|
committer | 2018-04-16 21:11:10 +0000 | |
commit | d234afdc2e562d395925ca3ac8294398608271a6 (patch) | |
tree | df395701b78e38fc3ddbab5c308cab8af79ea27e /src | |
parent | f7621cb5bb4ee181d557aeb6fa557819daba5fd2 (diff) |
Remove SkPaint::kGenA8FromLCD_Flag.
The original intent of this flag is now handled by SkPixelGeomety on
SkSurfaceProps on SkSurface.
BUG=skia:7515
Change-Id: I54bb1be072b5b5b2164a59196bfeacac254823c7
Reviewed-on: https://skia-review.googlesource.com/121346
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 46 | ||||
-rw-r--r-- | src/core/SkBitmapDevice.h | 1 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 37 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 19 | ||||
-rw-r--r-- | src/core/SkDevice.h | 8 | ||||
-rw-r--r-- | src/core/SkFont.cpp | 3 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 5 | ||||
-rw-r--r-- | src/core/SkRemoteGlyphCache.cpp | 13 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 3 | ||||
-rw-r--r-- | src/core/SkTextBlob.cpp | 3 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 6 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 1 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.cpp | 5 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/text/GrTextUtils.cpp | 21 | ||||
-rw-r--r-- | src/gpu/text/GrTextUtils.h | 9 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 1 |
17 files changed, 42 insertions, 141 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index f50ce9e582..f6433afb7e 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -540,15 +540,41 @@ void SkBitmapDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPa BDDraw(this).drawSprite(bitmap, x, y, paint); } +class SkBitmapDeviceFilteredSurfaceProps { +public: + SkBitmapDeviceFilteredSurfaceProps(const SkBitmap& bitmap, const SkPaint& paint, + const SkSurfaceProps& surfaceProps) { + if (kN32_SkColorType != bitmap.colorType() || + paint.getPathEffect() || + paint.isFakeBoldText() || + paint.getStyle() != SkPaint::kFill_Style || + !paint.isSrcOver()) + { + SkSurfaceProps* newPaint = fLazy.init(surfaceProps.flags(), kUnknown_SkPixelGeometry); + fSurfaceProps = newPaint; + } else { + fSurfaceProps = &surfaceProps; + } + } + + const SkSurfaceProps& operator()() const { return *fSurfaceProps; } + +private: + const SkSurfaceProps* fSurfaceProps; + SkTLazy<SkSurfaceProps> fLazy; +}; + void SkBitmapDevice::drawText(const void* text, size_t len, SkScalar x, SkScalar y, const SkPaint& paint) { - LOOP_TILER( drawText((const char*)text, len, x, y, paint, &fSurfaceProps), nullptr) + SkBitmapDeviceFilteredSurfaceProps props(fBitmap, paint, fSurfaceProps); + LOOP_TILER( drawText((const char*)text, len, x, y, paint, &props()), nullptr) } void SkBitmapDevice::drawPosText(const void* text, size_t len, const SkScalar xpos[], int scalarsPerPos, const SkPoint& offset, const SkPaint& paint) { - LOOP_TILER( drawPosText((const char*)text, len, xpos, scalarsPerPos, offset, paint, - &fSurfaceProps), nullptr) + SkBitmapDeviceFilteredSurfaceProps props(fBitmap, paint, fSurfaceProps); + LOOP_TILER( drawPosText((const char*)text, len, xpos, scalarsPerPos, offset, paint, &props()), + nullptr) } void SkBitmapDevice::drawVertices(const SkVertices* vertices, SkBlendMode bmode, @@ -714,20 +740,6 @@ SkImageFilterCache* SkBitmapDevice::getImageFilterCache() { /////////////////////////////////////////////////////////////////////////////////////////////////// -bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const { - if (kN32_SkColorType != fBitmap.colorType() || - paint.getPathEffect() || - paint.isFakeBoldText() || - paint.getStyle() != SkPaint::kFill_Style || - !paint.isSrcOver()) - { - return true; - } - return false; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - void SkBitmapDevice::onSave() { fRCStack.save(); } diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index 26214261a5..e040b6b0c6 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h @@ -61,7 +61,6 @@ public: SkRasterHandleAllocator* = nullptr); protected: - bool onShouldDisableLCD(const SkPaint&) const override; void* getRasterHandle() const override { return fRasterHandle; } /** These are called inside the per-device-layer loop for each draw call. diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index f836491352..635f453bf7 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -2380,33 +2380,12 @@ void SkCanvas::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattic LOOPER_END } -class SkDeviceFilteredPaint { -public: - SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { - uint32_t filteredFlags = device->filterTextFlags(paint); - if (filteredFlags != paint.getFlags()) { - SkPaint* newPaint = fLazy.set(paint); - newPaint->setFlags(filteredFlags); - fPaint = newPaint; - } else { - fPaint = &paint; - } - } - - const SkPaint& paint() const { return *fPaint; } - -private: - const SkPaint* fPaint; - SkLazyPaint fLazy; -}; - void SkCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint) { LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr) while (iter.next()) { - SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); - iter.fDevice->drawText(text, byteLength, x, y, dfp.paint()); + iter.fDevice->drawText(text, byteLength, x, y, looper.paint()); } LOOPER_END @@ -2419,9 +2398,7 @@ void SkCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr) while (iter.next()) { - SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); - iter.fDevice->drawPosText(text, byteLength, &pos->fX, 2, textOffset, - dfp.paint()); + iter.fDevice->drawPosText(text, byteLength, &pos->fX, 2, textOffset, looper.paint()); } LOOPER_END @@ -2435,9 +2412,7 @@ void SkCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScala LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr) while (iter.next()) { - SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); - iter.fDevice->drawPosText(text, byteLength, xpos, 1, textOffset, - dfp.paint()); + iter.fDevice->drawPosText(text, byteLength, xpos, 1, textOffset, looper.paint()); } LOOPER_END @@ -2448,8 +2423,7 @@ void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPat LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr) while (iter.next()) { - iter.fDevice->drawTextOnPath(text, byteLength, path, - matrix, looper.paint()); + iter.fDevice->drawTextOnPath(text, byteLength, path, matrix, looper.paint()); } LOOPER_END @@ -2491,8 +2465,7 @@ void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, bounds) while (iter.next()) { - SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); - iter.fDevice->drawTextBlob(blob, x, y, dfp.paint(), drawFilter); + iter.fDevice->drawTextBlob(blob, x, y, looper.paint(), drawFilter); } LOOPER_END diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 96a7e8dbfe..35cfc9ab71 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -156,8 +156,6 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, continue; } - runPaint.setFlags(this->filterTextFlags(runPaint)); - switch (it.positioning()) { case SkTextBlob::kDefault_Positioning: this->drawText(it.glyphs(), textLen, x + offset.x(), y + offset.y(), runPaint); @@ -526,23 +524,6 @@ void SkBaseDevice::drawTextRSXform(const void* text, size_t len, ////////////////////////////////////////////////////////////////////////////////////////// -uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { - uint32_t flags = paint.getFlags(); - - if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { - return flags; - } - - if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() - || this->onShouldDisableLCD(paint)) { - - flags &= ~SkPaint::kLCDRenderText_Flag; - flags |= SkPaint::kGenA8FromLCD_Flag; - } - - return flags; -} - sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps const&) { return nullptr; } diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index 6739230115..fb91c8a444 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -125,12 +125,6 @@ public: void setGlobalCTM(const SkMatrix& ctm); virtual void validateDevBounds(const SkIRect&) {} - /** - * Returns the text-related flags, possibly modified based on the state of the - * device (e.g. support for LCD). - */ - uint32_t filterTextFlags(const SkPaint&) const; - protected: enum TileUsage { kPossible_TileUsage, //!< the created device may be drawn tiled @@ -141,8 +135,6 @@ protected: uint32_t fFlags; // SkPaint::getFlags() }; - virtual bool onShouldDisableLCD(const SkPaint&) const { return false; } - virtual void onSave() {} virtual void onRestore() {} virtual void onClipRect(const SkRect& rect, SkClipOp, bool aa) {} diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp index ca6cdb13b0..77259ff50c 100644 --- a/src/core/SkFont.cpp +++ b/src/core/SkFont.cpp @@ -122,9 +122,6 @@ sk_sp<SkFont> SkFont::Testing_CreateFromPaint(const SkPaint& paint) { if (paint.isEmbeddedBitmapText()) { flags |= kEmbeddedBitmaps_Flag; } - if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) { - flags |= kGenA8FromLCD_Flag; - } if (paint.isFakeBoldText()) { flags |= kEmbolden_Flag; } diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 1e0830e0bc..3dc0af66f1 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -656,8 +656,7 @@ SkPaint::kDevKernText_Flag | \ SkPaint::kLinearText_Flag | \ SkPaint::kLCDRenderText_Flag | \ SkPaint::kEmbeddedBitmapText_Flag | \ -SkPaint::kAutoHinting_Flag | \ -SkPaint::kGenA8FromLCD_Flag ) +SkPaint::kAutoHinting_Flag ) SkScalar SkPaint::setupForAsPaths() { uint32_t flags = this->getFlags(); @@ -1656,8 +1655,6 @@ void SkPaint::toString(SkString* str) const { "EmbeddedBitmapText", &needSeparator); SkAddFlagToString(str, this->isAutohinted(), "Autohinted", &needSeparator); SkAddFlagToString(str, this->isVerticalText(), "VerticalText", &needSeparator); - SkAddFlagToString(str, SkToBool(this->getFlags() & SkPaint::kGenA8FromLCD_Flag), - "GenA8FromLCD", &needSeparator); } else { str->append("None"); } diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp index b7a0cddd85..84dcdda3cb 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -178,18 +178,6 @@ public: const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixelGeometry); return new TrackLayerDevice(this->getGlobalBounds(), surfaceProps); } - - // Stolen from the SkBitmapDevice, but the SkGPUDevice is similar. - bool onShouldDisableLCD(const SkPaint& paint) const override { - if (paint.getPathEffect() || - paint.isFakeBoldText() || - paint.getStyle() != SkPaint::kFill_Style || - !paint.isSrcOver()) - { - return true; - } - return false; - } }; // -- SkTextBlobCacheDiffCanvas ------------------------------------------------------------------- @@ -221,7 +209,6 @@ void SkTextBlobCacheDiffCanvas::onDrawTextBlob( // applyFontToPaint() always overwrites the exact same attributes, // so it is safe to not re-seed the paint for this reason. it.applyFontToPaint(&runPaint); - runPaint.setFlags(this->getTopDevice()->filterTextFlags(runPaint)); if (auto looper = runPaint.getLooper()) { this->processLooper(position, it, runPaint, looper); } else { diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 27ecca4641..096554437c 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -1008,9 +1008,6 @@ void SkScalerContext::MakeRecAndEffects(const SkPaint& paint, if (paint.isVerticalText()) { flags |= SkScalerContext::kVertical_Flag; } - if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) { - flags |= SkScalerContext::kGenA8FromLCD_Flag; - } rec->fFlags = SkToU16(flags); // these modify fFlags, so do them after assigning fFlags diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp index eac2430f5f..2c29d9d613 100644 --- a/src/core/SkTextBlob.cpp +++ b/src/core/SkTextBlob.cpp @@ -71,8 +71,7 @@ private: SkPaint::kLCDRenderText_Flag | SkPaint::kEmbeddedBitmapText_Flag | SkPaint::kAutoHinting_Flag | - SkPaint::kVerticalText_Flag | - SkPaint::kGenA8FromLCD_Flag; + SkPaint::kVerticalText_Flag ; SkScalar fSize; SkScalar fScaleX; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index fca372eabd..f26ed7b8ab 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1676,12 +1676,6 @@ void SkGpuDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, /////////////////////////////////////////////////////////////////////////////// -bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { - return GrTextUtils::ShouldDisableLCD(paint); -} - -/////////////////////////////////////////////////////////////////////////////// - void SkGpuDevice::flush() { this->flushAndSignalSemaphores(0, nullptr); } diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index da691a3da3..b6c7bf7cef 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -128,7 +128,6 @@ public: protected: bool onReadPixels(const SkPixmap&, int, int) override; bool onWritePixels(const SkPixmap&, int, int) override; - bool onShouldDisableLCD(const SkPaint&) const final; private: // We want these unreffed in RenderTargetContext, GrContext order. diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index 7acf617299..8ec5f4ee6d 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -258,10 +258,11 @@ inline std::unique_ptr<GrAtlasTextOp> GrAtlasTextBlob::makeOp( std::unique_ptr<GrAtlasTextOp> op; if (info.drawAsDistanceFields()) { bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); + bool useLCD = info.hasUseLCDText() && props.pixelGeometry() != kUnknown_SkPixelGeometry; op = GrAtlasTextOp::MakeDistanceField( std::move(grPaint), glyphCount, distanceAdjustTable, target->colorSpaceInfo().isGammaCorrect(), paint.luminanceColor(), - info.hasUseLCDText(), useBGR, info.isAntiAliased()); + useLCD, useBGR, info.isAntiAliased()); } else { op = GrAtlasTextOp::MakeBitmap(std::move(grPaint), format, glyphCount, info.hasScaledGlyphs()); @@ -309,7 +310,7 @@ void GrAtlasTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& p // GrAtlasTextBlob::makeOp only takes uint16_t values for run and subRun indices. // Encountering something larger than this is highly unlikely, so we'll just not draw it. int lastRun = SkTMin(fRunCount, (1 << 16)) - 1; - GrTextUtils::RunPaint runPaint(&paint, nullptr, props); + GrTextUtils::RunPaint runPaint(&paint, nullptr); for (int runIndex = 0; runIndex <= lastRun; runIndex++) { Run& run = fRuns[runIndex]; diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp index 8f6cba0341..b0f5405649 100644 --- a/src/gpu/text/GrAtlasTextContext.cpp +++ b/src/gpu/text/GrAtlasTextContext.cpp @@ -198,7 +198,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, // Regenerate textblob SkTextBlobRunIterator it(blob); - GrTextUtils::RunPaint runPaint(&paint, drawFilter, props); + GrTextUtils::RunPaint runPaint(&paint, drawFilter); for (int run = 0; !it.done(); it.next(), run++) { int glyphCount = it.glyphCount(); size_t textLen = glyphCount * sizeof(uint16_t); diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp index 7d693d1e29..738cfb68be 100644 --- a/src/gpu/text/GrTextUtils.cpp +++ b/src/gpu/text/GrTextUtils.cpp @@ -52,30 +52,9 @@ bool GrTextUtils::RunPaint::modifyForRun(std::function<void(SkPaint*)> paintModF // The draw filter could have changed either the paint color or color filter. this->initFilteredColor(); } - fModifiedPaint.get()->setFlags(FilterTextFlags(fProps, *fModifiedPaint.get())); return true; } -uint32_t GrTextUtils::FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint) { - uint32_t flags = paint.getFlags(); - - if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { - return flags; - } - - if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisableLCD(paint)) { - flags &= ~SkPaint::kLCDRenderText_Flag; - flags |= SkPaint::kGenA8FromLCD_Flag; - } - - return flags; -} - -bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) { - return paint.getMaskFilter() || paint.getPathEffect() || - paint.isFakeBoldText() || paint.getStyle() != SkPaint::kFill_Style; -} - bool GrTextUtils::PathTextIter::next(const SkGlyph** skGlyph, const SkPath** path, SkScalar* xpos) { SkASSERT(skGlyph); SkASSERT(path); diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h index ec26a86018..8b07f1c245 100644 --- a/src/gpu/text/GrTextUtils.h +++ b/src/gpu/text/GrTextUtils.h @@ -108,8 +108,8 @@ public: */ class RunPaint : public Paint { public: - RunPaint(const Paint* paint, SkDrawFilter* filter, const SkSurfaceProps& props) - : fOriginalPaint(paint), fFilter(filter), fProps(props) { + RunPaint(const Paint* paint, SkDrawFilter* filter) + : fOriginalPaint(paint), fFilter(filter) { // Initially we represent the original paint. fPaint = &fOriginalPaint->skPaint(); fDstColorSpaceInfo = fOriginalPaint->dstColorSpaceInfo(); @@ -122,13 +122,8 @@ public: SkTLazy<SkPaint> fModifiedPaint; const Paint* fOriginalPaint; SkDrawFilter* fFilter; - const SkSurfaceProps& fProps; }; - static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint); - - static bool ShouldDisableLCD(const SkPaint& paint); - class PathTextIter : SkTextBaseIter { public: PathTextIter(const char text[], size_t length, const SkPaint& paint, diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 98e34b004e..95864d9cb9 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -1421,7 +1421,6 @@ void SkPDFDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) { continue; } - runPaint.setFlags(this->filterTextFlags(runPaint)); SkPoint offset = it.offset() + SkPoint{x, y}; this->internalDrawText(it.glyphs(), sizeof(SkGlyphID) * it.glyphCount(), it.pos(), it.positioning(), offset, runPaint, |