Revert "Convert bitmap device drawing to SkFont removing all LEGACY calls"

This reverts commit 85a216ce89.

Reason for revert: broke some svg layout tests?

https://ci.chromium.org/p/chromium/builders/luci.chromium.try/mac_chromium_rel_ng/203829

Original change's description:
> Convert bitmap device drawing to SkFont removing all LEGACY calls
> 
> Change-Id: I096042a63395f361f758306993cdbb2621937aef
> Reviewed-on: https://skia-review.googlesource.com/c/175840
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

TBR=herb@google.com,reed@google.com

Change-Id: Ia88e22d4dcbdfcba01febd7378a2f6bbda235644
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/175831
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-12-08 14:01:42 +00:00 committed by Skia Commit-Bot
parent 955f021a4d
commit 4037a18e5d
3 changed files with 23 additions and 23 deletions

View File

@ -495,7 +495,6 @@ private:
void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const;
friend class SkCanonicalizeFont;
friend class SkGlyphRunListPainter;
friend class SkPaint;
friend class SVGTextBuilder;
};

View File

@ -19,7 +19,6 @@
#include "SkDevice.h"
#include "SkDistanceFieldGen.h"
#include "SkDraw.h"
#include "SkFontPriv.h"
#include "SkGlyphCache.h"
#include "SkMaskFilter.h"
#include "SkPaintPriv.h"
@ -102,8 +101,7 @@ SkGlyphRunListPainter::SkGlyphRunListPainter(const GrRenderTargetContext& rtc)
#endif
bool SkGlyphRunListPainter::ShouldDrawAsPath(
const SkPaint& paint, const SkFont& font, const SkMatrix& matrix) {
bool SkGlyphRunListPainter::ShouldDrawAsPath(const SkPaint& paint, const SkMatrix& matrix) {
// hairline glyphs are fast enough so we don't need to cache them
if (SkPaint::kStroke_Style == paint.getStyle() && 0 == paint.getStrokeWidth()) {
return true;
@ -114,7 +112,9 @@ bool SkGlyphRunListPainter::ShouldDrawAsPath(
return true;
}
return SkPaint::TooBigToUseCache(matrix, SkFontPriv::MakeTextMatrix(font), 1024);
SkMatrix textM;
SkPaintPriv::MakeTextMatrix(&textM, paint);
return SkPaint::TooBigToUseCache(matrix, textM, 1024);
}
void SkGlyphRunListPainter::ensureBitmapBuffers(size_t runSize) {
@ -161,28 +161,28 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
const BitmapDevicePainter* bitmapDevice) {
SkPoint origin = glyphRunList.origin();
const SkPaint& runPaint = glyphRunList.paint();
// The bitmap blitters can only draw lcd text to a N32 bitmap in srcOver. Otherwise,
// convert the lcd text into A8 text. The props communicates this to the scaler.
auto& props = (kN32_SkColorType == fColorType && runPaint.isSrcOver())
? fDeviceProps
: fBitmapFallbackProps;
for (auto& glyphRun : glyphRunList) {
// The bitmap blitters can only draw lcd text to a N32 bitmap in srcOver. Otherwise,
// convert the lcd text into A8 text. The props communicates this to the scaler.
auto& props = (kN32_SkColorType == fColorType && glyphRunList.paint().isSrcOver())
? fDeviceProps
: fBitmapFallbackProps;
SkPaint paint{glyphRunList.paint()};
glyphRun.font().LEGACY_applyToPaint(&paint);
auto runSize = glyphRun.runSize();
this->ensureBitmapBuffers(runSize);
const SkFont& runFont = glyphRun.font();
if (ShouldDrawAsPath(runPaint, runFont, deviceMatrix)) {
if (ShouldDrawAsPath(paint, deviceMatrix)) {
SkMatrix::MakeTrans(origin.x(), origin.y()).mapPoints(
fPositions, glyphRun.positions().data(), runSize);
// setup our std pathPaint, in hopes of getting hits in the cache
SkPaint pathPaint(runPaint);
SkFont pathFont = runFont;
SkScalar textScale = pathFont.setupForAsPaths(&pathPaint);
SkPaint pathPaint(paint);
SkScalar textScale = pathPaint.setupForAsPaths();
auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive(
pathFont, pathPaint, props, fScalerContextFlags, SkMatrix::I());
SkFont::LEGACY_ExtractFromPaint(pathPaint), pathPaint, props,
fScalerContextFlags, SkMatrix::I());
SkTDArray<PathAndPos> pathsAndPositions;
pathsAndPositions.setReserve(runSize);
@ -202,10 +202,12 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
bitmapDevice->paintPaths(
SkSpan<const PathAndPos>{pathsAndPositions.begin(), pathsAndPositions.size()},
textScale, runPaint);
textScale,
paint);
} else {
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
runFont, runPaint, props, fScalerContextFlags, deviceMatrix);
SkFont::LEGACY_ExtractFromPaint(paint), paint, props,
fScalerContextFlags, deviceMatrix);
// Add rounding and origin.
SkMatrix matrix = deviceMatrix;
@ -227,8 +229,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
}
}
}
bitmapDevice->paintMasks(
SkSpan<const SkMask>{masks.begin(), masks.size()}, runPaint);
bitmapDevice->paintMasks(SkSpan<const SkMask>{masks.begin(), masks.size()}, paint);
}
}
}

View File

@ -107,7 +107,7 @@ public:
PerEmptyT&& perEmpty, PerSDFT&& perSDF, PerPathT&& perPath, ARGBFallback&& perFallback);
private:
static bool ShouldDrawAsPath(const SkPaint& paint, const SkFont& font, const SkMatrix& matrix);
static bool ShouldDrawAsPath(const SkPaint& paint, const SkMatrix& matrix);
void ensureBitmapBuffers(size_t runSize);
void processARGBFallback(