diff options
author | Mike Reed <reed@google.com> | 2018-01-19 19:09:32 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-21 18:24:11 +0000 |
commit | 8ad91a9bf896d728b905124847d74787aac698a7 (patch) | |
tree | 4a5ac4b68bb0a5f5b5d6e6447ffb02b5173b912b /src | |
parent | 07853659fae395877fd5e09e92ae3b690ba3c222 (diff) |
remove unused SkRasterizer
Bug: skia:7500
Change-Id: Iaa683cf8f0b18887cce4ec676631d1e1efee1712
Reviewed-on: https://skia-review.googlesource.com/97400
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 1 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 23 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 65 | ||||
-rw-r--r-- | src/core/SkPictureFlat.cpp | 3 | ||||
-rw-r--r-- | src/core/SkRasterizer.cpp | 46 | ||||
-rw-r--r-- | src/core/SkReadBuffer.h | 2 | ||||
-rw-r--r-- | src/core/SkRecordOpts.cpp | 1 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 32 | ||||
-rw-r--r-- | src/core/SkScalerContext.h | 12 | ||||
-rw-r--r-- | src/effects/SkLayerRasterizer.cpp | 226 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.cpp | 1 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.h | 2 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp | 1 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextContext.cpp | 5 | ||||
-rw-r--r-- | src/gpu/text/GrStencilAndCoverTextContext.cpp | 3 | ||||
-rw-r--r-- | src/gpu/text/GrTextUtils.cpp | 2 | ||||
-rw-r--r-- | src/pipe/SkPipeCanvas.cpp | 3 | ||||
-rw-r--r-- | src/pipe/SkPipeReader.cpp | 1 | ||||
-rw-r--r-- | src/ports/SkGlobalInitialization_default.cpp | 4 | ||||
-rw-r--r-- | src/utils/SkLua.cpp | 1 | ||||
-rw-r--r-- | src/xps/SkXPSDevice.cpp | 46 |
21 files changed, 28 insertions, 452 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 1cf644a13b..90b721a2f0 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -522,7 +522,6 @@ SkImageFilterCache* SkBitmapDevice::getImageFilterCache() { bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const { if (kN32_SkColorType != fBitmap.colorType() || - paint.getRasterizer() || paint.getPathEffect() || paint.isFakeBoldText() || paint.getStyle() != SkPaint::kFill_Style || diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 70cb485f73..fc65160e68 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -24,7 +24,6 @@ #include "SkPaint.h" #include "SkPathEffect.h" #include "SkRasterClip.h" -#include "SkRasterizer.h" #include "SkRectPriv.h" #include "SkRRect.h" #include "SkScan.h" @@ -699,8 +698,7 @@ SkDraw::RectType SkDraw::ComputeRectType(const SkPaint& paint, } if (paint.getPathEffect() || paint.getMaskFilter() || - paint.getRasterizer() || !matrix.rectStaysRect() || - SkPaint::kStrokeAndFill_Style == style) { + !matrix.rectStaysRect() || SkPaint::kStrokeAndFill_Style == style) { rtype = kPath_RectType; } else if (SkPaint::kFill_Style == style) { rtype = kFill_RectType; @@ -916,10 +914,6 @@ void SkDraw::drawRRect(const SkRRect& rrect, const SkPaint& paint) const { if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) { goto DRAW_PATH; } - - if (paint.getRasterizer()) { - goto DRAW_PATH; - } } if (paint.getMaskFilter()) { @@ -1055,8 +1049,7 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, tmpPath.setIsVolatile(true); if (prePathMatrix) { - if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_Style || - origPaint.getRasterizer()) { + if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_Style) { SkPath* result = pathPtr; if (!pathIsMutable) { @@ -1110,17 +1103,6 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, pathPtr = &tmpPath; } - if (paint->getRasterizer()) { - SkMask mask; - if (paint->getRasterizer()->rasterize(*pathPtr, *matrix, - &fRC->getBounds(), paint->getMaskFilter(), &mask, - SkMask::kComputeBoundsAndRenderImage_CreateMode)) { - this->drawDevMask(mask, *paint); - SkMask::FreeImage(mask.fImage); - } - return; - } - // avoid possibly allocating a new path in transform if we can SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath; @@ -1340,7 +1322,6 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& ori matrix.reset(); draw.fMatrix = &matrix; // call ourself with a rect - // is this OK if paint has a rasterizer? draw.drawRect(r, paintWithShader); } diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 7c3edb3fe2..05e3e360bf 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -23,7 +23,6 @@ #include "SkOpts.h" #include "SkPaintDefaults.h" #include "SkPathEffect.h" -#include "SkRasterizer.h" #include "SkSafeRange.h" #include "SkScalar.h" #include "SkScalerContext.h" @@ -75,7 +74,6 @@ SkPaint::SkPaint(const SkPaint& src) , COPY(fShader) , COPY(fMaskFilter) , COPY(fColorFilter) - , COPY(fRasterizer) , COPY(fDrawLooper) , COPY(fImageFilter) , COPY(fTextSize) @@ -96,7 +94,6 @@ SkPaint::SkPaint(SkPaint&& src) { MOVE(fShader); MOVE(fMaskFilter); MOVE(fColorFilter); - MOVE(fRasterizer); MOVE(fDrawLooper); MOVE(fImageFilter); MOVE(fTextSize); @@ -123,7 +120,6 @@ SkPaint& SkPaint::operator=(const SkPaint& src) { ASSIGN(fShader); ASSIGN(fMaskFilter); ASSIGN(fColorFilter); - ASSIGN(fRasterizer); ASSIGN(fDrawLooper); ASSIGN(fImageFilter); ASSIGN(fTextSize); @@ -150,7 +146,6 @@ SkPaint& SkPaint::operator=(SkPaint&& src) { MOVE(fShader); MOVE(fMaskFilter); MOVE(fColorFilter); - MOVE(fRasterizer); MOVE(fDrawLooper); MOVE(fImageFilter); MOVE(fTextSize); @@ -173,7 +168,6 @@ bool operator==(const SkPaint& a, const SkPaint& b) { && EQUAL(fShader) && EQUAL(fMaskFilter) && EQUAL(fColorFilter) - && EQUAL(fRasterizer) && EQUAL(fDrawLooper) && EQUAL(fImageFilter) && EQUAL(fTextSize) @@ -194,7 +188,6 @@ DEFINE_REF_FOO(DrawLooper) DEFINE_REF_FOO(ImageFilter) DEFINE_REF_FOO(MaskFilter) DEFINE_REF_FOO(PathEffect) -DEFINE_REF_FOO(Rasterizer) DEFINE_REF_FOO(Shader) DEFINE_REF_FOO(Typeface) #undef DEFINE_REF_FOO @@ -363,7 +356,6 @@ void SkPaint::setTextEncoding(TextEncoding encoding) { #define MOVE_FIELD(Field) void SkPaint::set##Field(sk_sp<Sk##Field> f) { f##Field = std::move(f); } MOVE_FIELD(Typeface) -MOVE_FIELD(Rasterizer) MOVE_FIELD(ImageFilter) MOVE_FIELD(Shader) MOVE_FIELD(ColorFilter) @@ -1557,7 +1549,6 @@ void SkScalerContext::PostMakeRec(const SkPaint&, SkScalerContextRec* rec) { static void write_out_descriptor(SkDescriptor* desc, const SkScalerContextRec& rec, const SkPathEffect* pe, SkBinaryWriteBuffer* peBuffer, const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer, - const SkRasterizer* ra, SkBinaryWriteBuffer* raBuffer, size_t descSize) { desc->init(); desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec); @@ -1568,9 +1559,6 @@ static void write_out_descriptor(SkDescriptor* desc, const SkScalerContextRec& r if (mf) { add_flattenable(desc, kMaskFilter_SkDescriptorTag, mfBuffer); } - if (ra) { - add_flattenable(desc, kRasterizer_SkDescriptorTag, raBuffer); - } desc->computeChecksum(); } @@ -1580,8 +1568,7 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContextRec* rec, bool fakeGamma, bool boostContrast, const SkMatrix* deviceMatrix, const SkPathEffect* pe, SkBinaryWriteBuffer* peBuffer, - const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer, - const SkRasterizer* ra, SkBinaryWriteBuffer* raBuffer) { + const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer) { SkScalerContext::MakeRec(paint, surfaceProps, deviceMatrix, rec); if (!fakeGamma) { rec->ignoreGamma(); @@ -1611,12 +1598,6 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContextRec* rec, Also, all existing users of blur have calibrated for linear. */ rec->ignorePreBlend(); } - if (ra) { - ra->flatten(*raBuffer); - descSize += raBuffer->bytesWritten(); - entryCount += 1; - rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion - } /////////////////////////////////////////////////////////////////////////// // Now that we're done tweaking the rec, call the PostMakeRec cleanup @@ -1630,7 +1611,6 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContextRec* rec, static void test_desc(const SkScalerContextRec& rec, const SkPathEffect* pe, SkBinaryWriteBuffer* peBuffer, const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer, - const SkRasterizer* ra, SkBinaryWriteBuffer* raBuffer, const SkDescriptor* desc, size_t descSize) { // Check that we completely write the bytes in desc (our key), and that // there are no uninitialized bytes. If there were, then we would get @@ -1659,10 +1639,6 @@ static void test_desc(const SkScalerContextRec& rec, add_flattenable(desc1, kMaskFilter_SkDescriptorTag, mfBuffer); add_flattenable(desc2, kMaskFilter_SkDescriptorTag, mfBuffer); } - if (ra) { - add_flattenable(desc1, kRasterizer_SkDescriptorTag, raBuffer); - add_flattenable(desc2, kRasterizer_SkDescriptorTag, raBuffer); - } SkASSERT(descSize == desc1->getLength()); SkASSERT(descSize == desc2->getLength()); @@ -1683,28 +1659,26 @@ void SkPaint::getScalerContextDescriptor(SkScalerContextEffects* effects, SkPathEffect* pe = this->getPathEffect(); SkMaskFilter* mf = this->getMaskFilter(); - SkRasterizer* ra = this->getRasterizer(); - SkBinaryWriteBuffer peBuffer, mfBuffer, raBuffer; + SkBinaryWriteBuffer peBuffer, mfBuffer; size_t descSize = fill_out_rec(*this, &rec, &surfaceProps, SkToBool(scalerContextFlags & kFakeGamma_ScalerContextFlag), SkToBool(scalerContextFlags & kBoostContrast_ScalerContextFlag), - deviceMatrix, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); + deviceMatrix, pe, &peBuffer, mf, &mfBuffer); ad->reset(descSize); SkDescriptor* desc = ad->getDesc(); - write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize); + write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, descSize); SkASSERT(descSize == desc->getLength()); #ifdef TEST_DESC - test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize); + test_desc(rec, pe, &peBuffer, mf, &mfBuffer, desc, descSize); #endif effects->fPathEffect = pe; effects->fMaskFilter = mf; - effects->fRasterizer = ra; } /* @@ -1722,26 +1696,25 @@ void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps, SkPathEffect* pe = this->getPathEffect(); SkMaskFilter* mf = this->getMaskFilter(); - SkRasterizer* ra = this->getRasterizer(); SkBinaryWriteBuffer peBuffer, mfBuffer, raBuffer; size_t descSize = fill_out_rec(*this, &rec, surfaceProps, SkToBool(scalerContextFlags & kFakeGamma_ScalerContextFlag), SkToBool(scalerContextFlags & kBoostContrast_ScalerContextFlag), - deviceMatrix, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); + deviceMatrix, pe, &peBuffer, mf, &mfBuffer); SkAutoDescriptor ad(descSize); SkDescriptor* desc = ad.getDesc(); - write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize); + write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, descSize); SkASSERT(descSize == desc->getLength()); #ifdef TEST_DESC - test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize); + test_desc(rec, pe, &peBuffer, mf, &mfBuffer, desc, descSize); #endif - proc(fTypeface.get(), { pe, mf, ra }, desc, context); + proc(fTypeface.get(), { pe, mf }, desc, context); } SkGlyphCache* SkPaint::detachCache(const SkSurfaceProps* surfaceProps, @@ -1880,7 +1853,6 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const { asint(this->getShader()) | asint(this->getMaskFilter()) | asint(this->getColorFilter()) | - asint(this->getRasterizer()) | asint(this->getLooper()) | asint(this->getImageFilter())) { flatFlags |= kHasEffects_FlatFlag; @@ -1906,7 +1878,7 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const { buffer.writeFlattenable(this->getShader()); buffer.writeFlattenable(this->getMaskFilter()); buffer.writeFlattenable(this->getColorFilter()); - buffer.writeFlattenable(this->getRasterizer()); + buffer.write32(0); // use to be SkRasterizer buffer.writeFlattenable(this->getLooper()); buffer.writeFlattenable(this->getImageFilter()); } @@ -1942,7 +1914,7 @@ bool SkPaint::unflatten(SkReadBuffer& buffer) { this->setShader(buffer.readShader()); this->setMaskFilter(buffer.readMaskFilter()); this->setColorFilter(buffer.readColorFilter()); - this->setRasterizer(buffer.readRasterizer()); + (void)buffer.read32(); // use to be SkRasterizer this->setLooper(buffer.readDrawLooper()); this->setImageFilter(buffer.readImageFilter()); } else { @@ -1950,7 +1922,6 @@ bool SkPaint::unflatten(SkReadBuffer& buffer) { this->setShader(nullptr); this->setMaskFilter(nullptr); this->setColorFilter(nullptr); - this->setRasterizer(nullptr); this->setLooper(nullptr); this->setImageFilter(nullptr); } @@ -1996,7 +1967,7 @@ bool SkPaint::canComputeFastBounds() const { if (this->getImageFilter() && !this->getImageFilter()->canComputeFastBounds()) { return false; } - return !this->getRasterizer(); + return true; } const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc, @@ -2100,12 +2071,6 @@ void SkPaint::toString(SkString* str) const { str->append("</dd>"); } - SkRasterizer* rasterizer = this->getRasterizer(); - if (rasterizer) { - str->append("<dt>Rasterizer:</dt><dd>"); - str->append("</dd>"); - } - SkDrawLooper* looper = this->getLooper(); if (looper) { str->append("<dt>DrawLooper:</dt><dd>"); @@ -2342,9 +2307,9 @@ bool SkPaint::nothingToDraw() const { } uint32_t SkPaint::getHash() const { - // We're going to hash 10 pointers and 7 32-bit values, finishing up with fBitfields, - // so fBitfields should be 10 pointers and 6 32-bit values from the start. - static_assert(offsetof(SkPaint, fBitfields) == 8 * sizeof(void*) + 7 * sizeof(uint32_t), + // We're going to hash 7 pointers and 7 32-bit values, finishing up with fBitfields, + // so fBitfields should be 7 pointers and 6 32-bit values from the start. + static_assert(offsetof(SkPaint, fBitfields) == 7 * sizeof(void*) + 7 * sizeof(uint32_t), "SkPaint_notPackedTightly"); return SkOpts::hash(reinterpret_cast<const uint32_t*>(this), offsetof(SkPaint, fBitfields) + sizeof(fBitfields)); diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp index 6078cb6293..2895978442 100644 --- a/src/core/SkPictureFlat.cpp +++ b/src/core/SkPictureFlat.cpp @@ -4,13 +4,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "SkPictureFlat.h" +#include "SkPictureFlat.h" #include "SkChecksum.h" #include "SkColorFilter.h" #include "SkDrawLooper.h" #include "SkMaskFilter.h" -#include "SkRasterizer.h" #include "SkShader.h" #include "SkTypeface.h" diff --git a/src/core/SkRasterizer.cpp b/src/core/SkRasterizer.cpp deleted file mode 100644 index 994fb7f4b3..0000000000 --- a/src/core/SkRasterizer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2006 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "SkRasterizer.h" -#include "SkDraw.h" -#include "SkMaskFilter.h" -#include "SkPath.h" -#include "SkStrokeRec.h" - -bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix, - const SkIRect* clipBounds, SkMaskFilter* filter, - SkMask* mask, SkMask::CreateMode mode) const { - SkIRect storage; - - if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) { - SkIPoint margin; - SkMask srcM, dstM; - - srcM.fFormat = SkMask::kA8_Format; - srcM.fBounds.set(0, 0, 1, 1); - if (!filter->filterMask(&dstM, srcM, matrix, &margin)) { - return false; - } - storage = clipBounds->makeOutset(margin.fX, margin.fY); - clipBounds = &storage; - } - - return this->onRasterize(fillPath, matrix, clipBounds, mask, mode); -} - -/* Our default implementation of the virtual method just scan converts -*/ -bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix, - const SkIRect* clipBounds, - SkMask* mask, SkMask::CreateMode mode) const { - SkPath devPath; - - fillPath.transform(matrix, &devPath); - return SkDraw::DrawToMask(devPath, clipBounds, nullptr, nullptr, mask, mode, - SkStrokeRec::kFill_InitStyle); -} diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h index ff4b1671dd..34c3c50fa3 100644 --- a/src/core/SkReadBuffer.h +++ b/src/core/SkReadBuffer.h @@ -17,7 +17,6 @@ #include "SkPath.h" #include "SkPathEffect.h" #include "SkPicture.h" -#include "SkRasterizer.h" #include "SkReadBuffer.h" #include "SkReader32.h" #include "SkRefCnt.h" @@ -146,7 +145,6 @@ public: sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImageFilter>(); } sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); } sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEffect>(); } - sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRasterizer>(); } sk_sp<SkShader> readShader() { return this->readFlattenable<SkShaderBase>(); } // Reads SkAlign4(bytes), but will only copy bytes into the buffer. diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp index 8a1ac59368..8607471636 100644 --- a/src/core/SkRecordOpts.cpp +++ b/src/core/SkRecordOpts.cpp @@ -133,7 +133,6 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint, !layerPaint->isSrcOver() || layerPaint->getMaskFilter() || layerPaint->getColorFilter() || - layerPaint->getRasterizer() || layerPaint->getLooper() || layerPaint->getImageFilter()) { return false; diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 828f978287..fafaf367eb 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -20,7 +20,6 @@ #include "SkPaintPriv.h" #include "SkPathEffect.h" #include "SkRasterClip.h" -#include "SkRasterizer.h" #include "SkReadBuffer.h" #include "SkStroke.h" #include "SkStrokeRec.h" @@ -70,9 +69,8 @@ SkScalerContext::SkScalerContext(sk_sp<SkTypeface> typeface, const SkScalerConte , fTypeface(std::move(typeface)) , fPathEffect(sk_ref_sp(effects.fPathEffect)) , fMaskFilter(sk_ref_sp(effects.fMaskFilter)) - , fRasterizer(sk_ref_sp(effects.fRasterizer)) // Initialize based on our settings. Subclasses can also force this. - , fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != nullptr || fRasterizer != nullptr) + , fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != nullptr) , fPreBlend(fMaskFilter ? SkMaskGamma::PreBlend() : SkScalerContext::GetMaskPreBlend(fRec)) , fPreBlendForFilter(fMaskFilter ? SkScalerContext::GetMaskPreBlend(fRec) @@ -135,19 +133,6 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) { this->internalGetPath(glyph->getPackedID(), &fillPath, &devPath, &fillToDevMatrix); if (fillPath.isEmpty()) { generatingImageFromPath = false; - } else if (fRasterizer) { - SkMask mask; - - if (fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr, - fMaskFilter.get(), &mask, - SkMask::kJustComputeBounds_CreateMode)) { - glyph->fLeft = mask.fBounds.fLeft; - glyph->fTop = mask.fBounds.fTop; - glyph->fWidth = SkToU16(mask.fBounds.width()); - glyph->fHeight = SkToU16(mask.fBounds.height()); - } else { - goto SK_ERROR; - } } else { // just use devPath const SkIRect ir = devPath.getBounds().roundOut(); @@ -487,21 +472,6 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) { if (fillPath.isEmpty()) { generateImage(*glyph); - } else if (fRasterizer) { - // Paths do not have color information, so we should not have a color mask here. - // This case should have been caught up in generateMetrics(). - SkASSERT(SkMask::kARGB32_Format != origGlyph.fMaskFormat); - mask.fFormat = SkMask::kA8_Format; - sk_bzero(glyph->fImage, mask.computeImageSize()); - - if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr, - fMaskFilter.get(), &mask, - SkMask::kJustRenderImage_CreateMode)) { - return; - } - if (fPreBlend.isApplicable()) { - applyLUTToA8Mask(mask, fPreBlend.fG); - } } else { SkASSERT(SkMask::kARGB32_Format != origGlyph.fMaskFormat); SkASSERT(SkMask::kARGB32_Format != mask.fFormat); diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index dc5bac0a29..b1657fd3a1 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -18,16 +18,14 @@ class SkDescriptor; class SkMaskFilter; class SkPathEffect; -class SkRasterizer; struct SkScalerContextEffects { - SkScalerContextEffects() : fPathEffect(nullptr), fMaskFilter(nullptr), fRasterizer(nullptr) {} - SkScalerContextEffects(SkPathEffect* pe, SkMaskFilter* mf, SkRasterizer* ra) - : fPathEffect(pe), fMaskFilter(mf), fRasterizer(ra) {} + SkScalerContextEffects() : fPathEffect(nullptr), fMaskFilter(nullptr) {} + SkScalerContextEffects(SkPathEffect* pe, SkMaskFilter* mf) + : fPathEffect(pe), fMaskFilter(mf) {} SkPathEffect* fPathEffect; SkMaskFilter* fMaskFilter; - SkRasterizer* fRasterizer; }; enum SkAxisAlignment { @@ -271,7 +269,7 @@ public: const SkScalerContextRec& getRec() const { return fRec; } SkScalerContextEffects getEffects() const { - return { fPathEffect.get(), fMaskFilter.get(), fRasterizer.get() }; + return { fPathEffect.get(), fMaskFilter.get() }; } /** @@ -341,7 +339,6 @@ private: // optional objects, which may be null sk_sp<SkPathEffect> fPathEffect; sk_sp<SkMaskFilter> fMaskFilter; - sk_sp<SkRasterizer> fRasterizer; // if this is set, we draw the image from a path, rather than // calling generateImage. @@ -363,7 +360,6 @@ private: #define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c') #define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e') #define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f') -#define kRasterizer_SkDescriptorTag SkSetFourByteTag('r', 'a', 's', 't') /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp deleted file mode 100644 index b3e84593bd..0000000000 --- a/src/effects/SkLayerRasterizer.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2006 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "SkLayerRasterizer.h" -#include "SkDraw.h" -#include "SkReadBuffer.h" -#include "SkWriteBuffer.h" -#include "SkMask.h" -#include "SkMaskFilter.h" -#include "SkPaint.h" -#include "SkPath.h" -#include "SkPathEffect.h" -#include "../core/SkRasterClip.h" -#include "../core/SkStrokeRec.h" -#include <new> - -struct SkLayerRasterizer_Rec { - SkPaint fPaint; - SkVector fOffset; -}; - -SkLayerRasterizer::SkLayerRasterizer() : fLayers(new SkDeque(sizeof(SkLayerRasterizer_Rec))) {} - -SkLayerRasterizer::SkLayerRasterizer(SkDeque* layers) : fLayers(layers) -{ -} - -// Helper function to call destructors on SkPaints held by layers and delete layers. -static void clean_up_layers(SkDeque* layers) { - SkDeque::F2BIter iter(*layers); - SkLayerRasterizer_Rec* rec; - - while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) - rec->fPaint.~SkPaint(); - - delete layers; -} - -SkLayerRasterizer::~SkLayerRasterizer() { - SkASSERT(fLayers); - clean_up_layers(const_cast<SkDeque*>(fLayers)); -} - -static bool compute_bounds(const SkDeque& layers, const SkPath& path, - const SkMatrix& matrix, - const SkIRect* clipBounds, SkIRect* bounds) { - SkDeque::F2BIter iter(layers); - SkLayerRasterizer_Rec* rec; - - bounds->set(SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32); - - while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) { - const SkPaint& paint = rec->fPaint; - SkPath fillPath, devPath; - const SkPath* p = &path; - - if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) { - paint.getFillPath(path, &fillPath); - p = &fillPath; - } - if (p->isEmpty()) { - continue; - } - - // apply the matrix and offset - { - SkMatrix m = matrix; - m.preTranslate(rec->fOffset.fX, rec->fOffset.fY); - p->transform(m, &devPath); - } - - SkMask mask; - if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(), - &matrix, &mask, - SkMask::kJustComputeBounds_CreateMode, - SkStrokeRec::kFill_InitStyle)) { - return false; - } - - bounds->join(mask.fBounds); - } - return true; -} - -bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix, - const SkIRect* clipBounds, - SkMask* mask, SkMask::CreateMode mode) const { - SkASSERT(fLayers); - if (fLayers->empty()) { - return false; - } - - if (SkMask::kJustRenderImage_CreateMode != mode) { - if (!compute_bounds(*fLayers, path, matrix, clipBounds, &mask->fBounds)) - return false; - } - - if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) { - mask->fFormat = SkMask::kA8_Format; - mask->fRowBytes = mask->fBounds.width(); - size_t size = mask->computeImageSize(); - if (0 == size) { - return false; // too big to allocate, abort - } - mask->fImage = SkMask::AllocImage(size); - memset(mask->fImage, 0, size); - } - - if (SkMask::kJustComputeBounds_CreateMode != mode) { - SkDraw draw; - if (!draw.fDst.reset(*mask)) { - return false; - } - - SkRasterClip rectClip; - SkMatrix translatedMatrix; // this translates us to our local pixels - SkMatrix drawMatrix; // this translates the path by each layer's offset - - rectClip.setRect(SkIRect::MakeWH(mask->fBounds.width(), mask->fBounds.height())); - - translatedMatrix = matrix; - translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft), - -SkIntToScalar(mask->fBounds.fTop)); - - draw.fMatrix = &drawMatrix; - draw.fRC = &rectClip; - // we set the matrixproc in the loop, as the matrix changes each time (potentially) - - SkDeque::F2BIter iter(*fLayers); - SkLayerRasterizer_Rec* rec; - - while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) { - drawMatrix = translatedMatrix; - drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY); - draw.drawPath(path, rec->fPaint); - } - } - return true; -} - -sk_sp<SkFlattenable> SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) { - return sk_sp<SkFlattenable>(new SkLayerRasterizer(ReadLayers(buffer))); -} - -SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) { - int count = buffer.readInt(); - - SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec)); - for (int i = 0; i < count; i++) { - SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back(); - - new (&rec->fPaint) SkPaint; - buffer.readPaint(&rec->fPaint); - buffer.readPoint(&rec->fOffset); - } - return layers; -} - -void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const { - this->INHERITED::flatten(buffer); - - SkASSERT(fLayers); - buffer.writeInt(fLayers->count()); - - SkDeque::F2BIter iter(*fLayers); - const SkLayerRasterizer_Rec* rec; - - while ((rec = (const SkLayerRasterizer_Rec*)iter.next()) != nullptr) { - buffer.writePaint(rec->fPaint); - buffer.writePoint(rec->fOffset); - } -} - -SkLayerRasterizer::Builder::Builder() : fLayers(new SkDeque(sizeof(SkLayerRasterizer_Rec))) {} - -SkLayerRasterizer::Builder::~Builder() -{ - if (fLayers != nullptr) { - clean_up_layers(fLayers); - } -} - -void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx, - SkScalar dy) { - SkASSERT(fLayers); - SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back(); - - new (&rec->fPaint) SkPaint(paint); - rec->fOffset.set(dx, dy); -} - -sk_sp<SkLayerRasterizer> SkLayerRasterizer::Builder::detach() { - SkLayerRasterizer* rasterizer; - if (0 == fLayers->count()) { - rasterizer = nullptr; - delete fLayers; - } else { - rasterizer = new SkLayerRasterizer(fLayers); - } - fLayers = nullptr; - return sk_sp<SkLayerRasterizer>(rasterizer); -} - -sk_sp<SkLayerRasterizer> SkLayerRasterizer::Builder::snapshot() const { - if (0 == fLayers->count()) { - return nullptr; - } - SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec), fLayers->count()); - SkDeque::F2BIter iter(*fLayers); - const SkLayerRasterizer_Rec* recOrig; - SkDEBUGCODE(int count = 0;) - while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != nullptr) { - SkDEBUGCODE(count++); - SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(layers->push_back()); - new (&recCopy->fPaint) SkPaint(recOrig->fPaint); - recCopy->fOffset = recOrig->fOffset; - } - SkASSERT(fLayers->count() == count); - SkASSERT(layers->count() == count); - return sk_sp<SkLayerRasterizer>(new SkLayerRasterizer(layers)); -} diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index df848db6f7..ca671b4500 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -61,7 +61,6 @@ SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex, skPaint.getScalerContextDescriptor(&effects, desc, props, scalerContextFlags, viewMatrix); run->fTypeface.reset(SkSafeRef(skPaint.getTypeface())); run->fPathEffect = sk_ref_sp(effects.fPathEffect); - run->fRasterizer = sk_ref_sp(effects.fRasterizer); run->fMaskFilter = sk_ref_sp(effects.fMaskFilter); return SkGlyphCache::DetachCache(run->fTypeface.get(), effects, desc->getDesc()); } diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h index b93632fcfe..7106f11bf8 100644 --- a/src/gpu/text/GrAtlasTextBlob.h +++ b/src/gpu/text/GrAtlasTextBlob.h @@ -18,7 +18,6 @@ #include "SkOpts.h" #include "SkPathEffect.h" #include "SkPoint3.h" -#include "SkRasterizer.h" #include "SkRectPriv.h" #include "SkSurfaceProps.h" #include "SkTInternalLList.h" @@ -489,7 +488,6 @@ private: // Effects from the paint that are used to build a SkScalerContext. sk_sp<SkPathEffect> fPathEffect; - sk_sp<SkRasterizer> fRasterizer; sk_sp<SkMaskFilter> fMaskFilter; // Distance field text cannot draw coloremoji, and so has to fall back. However, diff --git a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp index a49a3ff998..1ae2c79fd4 100644 --- a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp +++ b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp @@ -199,7 +199,6 @@ Regenerator::Result Regenerator::doRegen() { if (!*fLazyCache || (*fLazyCache)->getDescriptor() != *desc) { SkScalerContextEffects effects; effects.fPathEffect = fRun->fPathEffect.get(); - effects.fRasterizer = fRun->fRasterizer.get(); effects.fMaskFilter = fRun->fMaskFilter.get(); fLazyCache->reset(SkGlyphCache::DetachCache(fRun->fTypeface.get(), effects, desc)); } diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp index bdbc600cc1..3578154fcc 100644 --- a/src/gpu/text/GrAtlasTextContext.cpp +++ b/src/gpu/text/GrAtlasTextContext.cpp @@ -494,9 +494,8 @@ bool GrAtlasTextContext::canDrawAsDistanceFields(const SkPaint& skPaint, const S } } - // rasterizers and mask filters modify alpha, which doesn't - // translate well to distance - if (skPaint.getRasterizer() || skPaint.getMaskFilter() || !caps.shaderDerivativeSupport()) { + // mask filters modify alpha, which doesn't translate well to distance + if (skPaint.getMaskFilter() || !caps.shaderDerivativeSupport()) { return false; } diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp index b2dfa6c375..fd467fcea5 100644 --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp @@ -53,9 +53,6 @@ GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { } bool GrStencilAndCoverTextContext::internalCanDraw(const SkPaint& skPaint) { - if (skPaint.getRasterizer()) { - return false; - } if (skPaint.getMaskFilter()) { return false; } diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp index 20a3a5c52c..47585f7fcf 100644 --- a/src/gpu/text/GrTextUtils.cpp +++ b/src/gpu/text/GrTextUtils.cpp @@ -74,7 +74,7 @@ uint32_t GrTextUtils::FilterTextFlags(const SkSurfaceProps& surfaceProps, const } bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) { - return paint.getMaskFilter() || paint.getRasterizer() || paint.getPathEffect() || + return paint.getMaskFilter() || paint.getPathEffect() || paint.isFakeBoldText() || paint.getStyle() != SkPaint::kFill_Style; } diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp index 3d0e69569c..32a615e853 100644 --- a/src/pipe/SkPipeCanvas.cpp +++ b/src/pipe/SkPipeCanvas.cpp @@ -16,7 +16,6 @@ #include "SkPipeCanvas.h" #include "SkPipeFormat.h" #include "SkRSXform.h" -#include "SkRasterizer.h" #include "SkShader.h" #include "SkStream.h" #include "SkTextBlob.h" @@ -70,7 +69,6 @@ static uint16_t compute_nondef(const SkPaint& paint, PaintUsage usage) { if (usage & (kText_PaintUsage | kGeometry_PaintUsage | kTextBlob_PaintUsage)) { bits |= (paint.getPathEffect() ? kPathEffect_NonDef : 0); - bits |= (paint.getRasterizer() ? kRasterizer_NonDef : 0); if (paint.getStyle() != SkPaint::kFill_Style || (usage & kRespectsStroke_PaintUsage)) { bits |= (paint.getStrokeWidth() != kStrokeWidth_Default ? kStrokeWidth_NonDef : 0); @@ -176,7 +174,6 @@ static void write_paint(SkWriteBuffer& writer, const SkPaint& paint, unsigned us CHECK_WRITE_FLATTENABLE(writer, nondef, paint, Shader); CHECK_WRITE_FLATTENABLE(writer, nondef, paint, MaskFilter); CHECK_WRITE_FLATTENABLE(writer, nondef, paint, ColorFilter); - CHECK_WRITE_FLATTENABLE(writer, nondef, paint, Rasterizer); CHECK_WRITE_FLATTENABLE(writer, nondef, paint, ImageFilter); CHECK_WRITE_FLATTENABLE(writer, nondef, paint, DrawLooper); } diff --git a/src/pipe/SkPipeReader.cpp b/src/pipe/SkPipeReader.cpp index ee48d5a23b..2c41453868 100644 --- a/src/pipe/SkPipeReader.cpp +++ b/src/pipe/SkPipeReader.cpp @@ -181,7 +181,6 @@ static SkPaint read_paint(SkReadBuffer& reader) { CHECK_SET_FLATTENABLE(Shader); CHECK_SET_FLATTENABLE(MaskFilter); CHECK_SET_FLATTENABLE(ColorFilter); - CHECK_SET_FLATTENABLE(Rasterizer); CHECK_SET_FLATTENABLE(ImageFilter); CHECK_SET_FLATTENABLE(DrawLooper); diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp index a98083aa7f..4a31044406 100644 --- a/src/ports/SkGlobalInitialization_default.cpp +++ b/src/ports/SkGlobalInitialization_default.cpp @@ -23,7 +23,6 @@ #include "SkHighContrastFilter.h" #include "SkImageSource.h" #include "SkLayerDrawLooper.h" -#include "SkLayerRasterizer.h" #include "SkLightingImageFilter.h" #include "SkLocalMatrixImageFilter.h" #include "SkLumaColorFilter.h" @@ -70,9 +69,6 @@ void SkFlattenable::PrivateInitializer::InitEffects() { // DrawLooper SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper) - // Rasterizer - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer) - // ColorFilter SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilterRowMajor255) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter) diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index 38f9c910f0..c90c13a399 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -973,7 +973,6 @@ static int lpaint_getEffects(lua_State* L) { lua_newtable(L); setfield_bool_if(L, "looper", !!paint->getLooper()); setfield_bool_if(L, "pathEffect", !!paint->getPathEffect()); - setfield_bool_if(L, "rasterizer", !!paint->getRasterizer()); setfield_bool_if(L, "maskFilter", !!paint->getMaskFilter()); setfield_bool_if(L, "shader", !!paint->getShader()); setfield_bool_if(L, "colorFilter", !!paint->getColorFilter()); diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp index 354070ce66..dcf88aac00 100644 --- a/src/xps/SkXPSDevice.cpp +++ b/src/xps/SkXPSDevice.cpp @@ -40,7 +40,6 @@ #include "SkPathOps.h" #include "SkPoint.h" #include "SkRasterClip.h" -#include "SkRasterizer.h" #include "SkSFNTHeader.h" #include "SkShader.h" #include "SkSize.h" @@ -1076,7 +1075,6 @@ static bool rect_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) { return paint.getPathEffect() || paint.getMaskFilter() || - paint.getRasterizer() || (stroke && ( (matrix.hasPerspective() && !zeroWidth) || SkPaint::kMiter_Join != paint.getStrokeJoin() || @@ -1518,7 +1516,7 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath, SkMatrix matrix = this->ctm(); SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath); if (prePathMatrix) { - if (paintHasPathEffect || paint->getRasterizer()) { + if (paintHasPathEffect) { if (!pathIsMutable) { skeletalPath = &modifiedPath; pathIsMutable = true; @@ -1562,11 +1560,10 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath, HRVM(shadedPath->SetGeometryLocal(shadedGeometry.get()), "Could not add the shaded geometry to shaded path."); - SkRasterizer* rasterizer = paint->getRasterizer(); SkMaskFilter* filter = paint->getMaskFilter(); //Determine if we will draw or shade and mask. - if (rasterizer || filter) { + if (filter) { if (paint->getStyle() != SkPaint::kFill_Style) { paint.writable()->setStyle(SkPaint::kFill_Style); } @@ -1581,44 +1578,6 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath, &fill, &stroke)); - //Rasterizer - if (rasterizer) { - SkIRect clipIRect; - SkVector ppuScale; - this->convertToPpm(filter, - &matrix, - &ppuScale, - this->cs().bounds(size(*this)).roundOut(), - &clipIRect); - - SkMask* mask = nullptr; - - //[Fillable-path -> Mask] - SkMask rasteredMask; - if (rasterizer->rasterize( - *fillablePath, - matrix, - &clipIRect, - filter, //just to compute how much to draw. - &rasteredMask, - SkMask::kComputeBoundsAndRenderImage_CreateMode)) { - - SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage); - mask = &rasteredMask; - - //[Mask -> Mask] - SkMask filteredMask; - if (filter && filter->filterMask(&filteredMask, *mask, this->ctm(), nullptr)) { - mask = &filteredMask; - } - SkAutoMaskFreeImage filteredAmi(filteredMask.fImage); - - //Draw mask. - HRV(this->applyMask(*mask, ppuScale, shadedPath.get())); - } - return; - } - //Mask filter if (filter) { SkIRect clipIRect; @@ -2039,7 +1998,6 @@ static bool text_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) { || SkPaint::kStroke_Style == style || SkPaint::kStrokeAndFill_Style == style || paint.getMaskFilter() - || paint.getRasterizer() ; } |