aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-04-13 15:50:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-16 21:11:10 +0000
commitd234afdc2e562d395925ca3ac8294398608271a6 (patch)
treedf395701b78e38fc3ddbab5c308cab8af79ea27e /src/core
parentf7621cb5bb4ee181d557aeb6fa557819daba5fd2 (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/core')
-rw-r--r--src/core/SkBitmapDevice.cpp46
-rw-r--r--src/core/SkBitmapDevice.h1
-rw-r--r--src/core/SkCanvas.cpp37
-rw-r--r--src/core/SkDevice.cpp19
-rw-r--r--src/core/SkDevice.h8
-rw-r--r--src/core/SkFont.cpp3
-rw-r--r--src/core/SkPaint.cpp5
-rw-r--r--src/core/SkRemoteGlyphCache.cpp13
-rw-r--r--src/core/SkScalerContext.cpp3
-rw-r--r--src/core/SkTextBlob.cpp3
10 files changed, 36 insertions, 102 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;