Revert "Move remove ptr args to MakeRecAndEffects"

This reverts commit b07aba4214.

Reason for revert: Changes GMs

Original change's description:
> Move remove ptr args to MakeRecAndEffects
> 
> Move this conversion out through the transitive closure of calls. As you
> move up the stack, everything becomes refs instread of pointers.
> 
> Reorder args of MakeRecAndEffects and setupCache to match the majority of other
> calls.
> 
> Change-Id: I72baf457cd9140f76ee5f7122493284c4be5bcd0
> Reviewed-on: https://skia-review.googlesource.com/c/169765
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

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

Change-Id: I29e54cea5b7b5709dd6db6816cb6556d73e003e0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/170221
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2018-11-09 19:01:00 +00:00 committed by Skia Commit-Bot
parent b07aba4214
commit 1062963232
19 changed files with 106 additions and 116 deletions

View File

@ -46,7 +46,7 @@ private:
void onDelayedSetup() override {
SkPaint defaultPaint;
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(defaultPaint);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint);
for (int i = 0; i < kNumGlyphs; ++i) {
SkPackedGlyphID id(cache->unicharToGlyph(kGlyphs[i]));
sk_ignore_unused_variable(cache->getScalerContext()->getPath(id, &fGlyphs[i]));

View File

@ -21,8 +21,7 @@ static void do_font_stuff(SkPaint* paint) {
for (SkScalar i = 8; i < 64; i++) {
paint->setTextSize(i);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
*paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
SkScalerContextFlags::kNone, SkMatrix::I());
*paint, nullptr, SkScalerContextFlags::kNone, nullptr);
uint16_t glyphs['z'];
for (int c = ' '; c < 'z'; c++) {
glyphs[c] = cache->unicharToGlyph(c);

View File

@ -33,7 +33,7 @@ public:
void onOnceBeforeDraw() final {
SkPaint defaultPaint;
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(defaultPaint);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint);
SkPath glyphPaths[52];
for (int i = 0; i < 52; ++i) {
// I and l are rects on OS X ...

View File

@ -368,7 +368,7 @@ void SkGlyphRunBuilder::simplifyDrawText(
if (!glyphIDs.empty()) {
fScratchAdvances.resize(runSize);
{
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(runPaint);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(runPaint);
cache->getAdvances(glyphIDs, fScratchAdvances.data());
}

View File

@ -180,7 +180,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
SkScalar textScale = pathPaint.setupForAsPaths();
auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive(
pathPaint, props, fScalerContextFlags, SkMatrix::I());
pathPaint, &props, fScalerContextFlags, nullptr);
SkTDArray<PathAndPos> pathsAndPositions;
pathsAndPositions.setReserve(runSize);
@ -204,7 +204,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
paint);
} else {
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
paint, props, fScalerContextFlags, deviceMatrix);
paint, &props, fScalerContextFlags, &deviceMatrix);
// Add rounding and origin.
SkMatrix matrix = deviceMatrix;
@ -599,8 +599,8 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
fBlob->setHasBitmap();
fBlob->setSubRunHasW(fRunIndex, glyphCacheMatrix.hasPerspective());
SkExclusiveStrikePtr fallbackCache =
fBlob->setupCache(fRunIndex,
fallbackPaint, fProps, fScalerContextFlags, glyphCacheMatrix);
fBlob->setupCache(fRunIndex, fProps, fScalerContextFlags,
fallbackPaint, &glyphCacheMatrix);
sk_sp<GrTextStrike> strike = fGlyphCache->getStrike(fallbackCache.get());
const SkPoint* glyphPos = positions.data();
for (auto glyphID : glyphIDs) {
@ -649,7 +649,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
{
auto cache = this->setupCache(
runIndex, distanceFieldPaint, props, flags, SkMatrix::I());
runIndex, props, flags, distanceFieldPaint, &SkMatrix::I());
sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());
@ -698,7 +698,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
SkScalar textScale = pathPaint.setupForAsPaths();
auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive(
pathPaint, props, scalerContextFlags, SkMatrix::I());
pathPaint, &props, scalerContextFlags, &SkMatrix::I());
// Given a glyph that is not ARGB, draw it.
auto perPath = [textScale, runIndex, this, &pathCache]
@ -723,7 +723,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
this->setHasBitmap();
auto cache = this->setupCache(
runIndex, runPaint, props, scalerContextFlags, viewMatrix);
runIndex, props, scalerContextFlags, runPaint, &viewMatrix);
sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());

View File

@ -73,7 +73,7 @@ void SkOverdrawCanvas::drawPosTextCommon(const void* text, size_t byteLength, co
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
this->getProps(&props);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
paint, props, SkScalerContextFlags::kNone, this->getTotalMatrix());
paint, &props, SkScalerContextFlags::kNone, &this->getTotalMatrix());
SkFindAndPlaceGlyph::ProcessPosText(paint.getTextEncoding(), (const char*) text, byteLength,
SkPoint::Make(0, 0), SkMatrix(), (const SkScalar*) pos, 2,
cache.get(), processBounds);

View File

@ -102,7 +102,7 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyp
return SkToInt(byteLength >> 1);
}
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(*this);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(*this);
const void* stop = (const char*)textData + byteLength;
uint16_t* gptr = glyphs;
@ -137,7 +137,7 @@ bool SkPaint::containsText(const void* textData, size_t byteLength) const {
return true;
}
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(*this);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(*this);
const void* stop = (const char*)textData + byteLength;
const SkTypeface::Encoding encoding = to_encoding(this->getTextEncoding());
while (textData < stop) {
@ -158,7 +158,7 @@ void SkPaint::glyphsToUnichars(const uint16_t glyphs[], int count, SkUnichar tex
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
*this, props, SkScalerContextFlags::kFakeGammaAndBoostContrast, SkMatrix::I());
*this, &props, SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
for (int index = 0; index < count; index++) {
textData[index] = cache->glyphToUnichar(glyphs[index]);
@ -390,7 +390,7 @@ SkScalar SkPaint::measureText(const void* textData, size_t length, SkRect* bound
const SkPaint& paint = canon.getPaint();
SkScalar scale = canon.getScale();
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint);
SkScalar width = 0;
@ -443,7 +443,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
maxWidth /= scale;
}
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint);
GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
false);
@ -486,8 +486,7 @@ SkScalar SkPaint::getFontMetrics(SkFontMetrics* metrics) const {
SkScalerContextEffects effects;
auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
SkScalerContextFlags::kNone, SkMatrix::I(), &ad, &effects);
paint, nullptr, SkScalerContextFlags::kNone, nullptr, &ad, &effects);
{
auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint);
@ -526,7 +525,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength,
const SkPaint& paint = canon.getPaint();
SkScalar scale = canon.getScale();
auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint);
GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
nullptr != bounds);
@ -788,7 +787,9 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
}
// SRGBTODO: Is this correct?
fCache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(fPaint);
fCache = SkStrikeCache::FindOrCreateStrikeExclusive(
fPaint, nullptr,
SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
SkPaint::Style style = SkPaint::kFill_Style;
sk_sp<SkPathEffect> pe;

View File

@ -64,7 +64,7 @@ static const SkDescriptor* create_descriptor(
SkScalerContextRec deviceRec;
bool enableTypefaceFiltering = (type == kDevice);
SkScalerContext::MakeRecAndEffects(
font, paint, props, flags, m, &deviceRec, effects, enableTypefaceFiltering);
font, paint, &props, &m, flags, &deviceRec, effects, enableTypefaceFiltering);
return SkScalerContext::AutoDescriptorGivenRecAndEffects(deviceRec, *effects, ad);
}

View File

@ -900,14 +900,15 @@ static SkFontHinting computeHinting(const SkFont& font) {
// The only reason this is not file static is because it needs the context of SkScalerContext to
// access SkPaint::computeLuminanceColor.
void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
void SkScalerContext::MakeRecAndEffects(const SkFont& font,
const SkPaint& paint,
const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix,
SkScalerContextRec* rec,
SkScalerContextEffects* effects,
bool enableTypefaceFiltering) {
SkASSERT(!deviceMatrix.hasPerspective());
SkASSERT(deviceMatrix == nullptr || !deviceMatrix->hasPerspective());
sk_bzero(rec, sizeof(SkScalerContextRec));
@ -920,19 +921,24 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint
bool checkPost2x2 = false;
const SkMatrix::TypeMask mask = deviceMatrix.getType();
if (mask & SkMatrix::kScale_Mask) {
rec->fPost2x2[0][0] = sk_relax(deviceMatrix.getScaleX());
rec->fPost2x2[1][1] = sk_relax(deviceMatrix.getScaleY());
checkPost2x2 = true;
if (deviceMatrix) {
const SkMatrix::TypeMask mask = deviceMatrix->getType();
if (mask & SkMatrix::kScale_Mask) {
rec->fPost2x2[0][0] = sk_relax(deviceMatrix->getScaleX());
rec->fPost2x2[1][1] = sk_relax(deviceMatrix->getScaleY());
checkPost2x2 = true;
} else {
rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
}
if (mask & SkMatrix::kAffine_Mask) {
rec->fPost2x2[0][1] = sk_relax(deviceMatrix->getSkewX());
rec->fPost2x2[1][0] = sk_relax(deviceMatrix->getSkewY());
checkPost2x2 = true;
} else {
rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
}
} else {
rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
}
if (mask & SkMatrix::kAffine_Mask) {
rec->fPost2x2[0][1] = sk_relax(deviceMatrix.getSkewX());
rec->fPost2x2[1][0] = sk_relax(deviceMatrix.getSkewY());
checkPost2x2 = true;
} else {
rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
}
@ -983,8 +989,9 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint
rec->fMaskFormat = SkMask::kA8_Format;
flags |= SkScalerContext::kGenA8FromLCD_Flag;
} else {
SkPixelGeometry geometry = surfaceProps.pixelGeometry();
SkPixelGeometry geometry = surfaceProps
? surfaceProps->pixelGeometry()
: SkSurfacePropsDefaultPixelGeometry();
switch (geometry) {
case kUnknown_SkPixelGeometry:
// eeek, can't support LCD
@ -1106,14 +1113,14 @@ SkDescriptor* SkScalerContext::MakeDescriptorForPaths(SkFontID typefaceID,
}
SkDescriptor* SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
const SkPaint& paint, const SkSurfaceProps& surfaceProps,
const SkPaint& paint, const SkSurfaceProps* surfaceProps,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix, SkAutoDescriptor* ad,
const SkMatrix* deviceMatrix, SkAutoDescriptor* ad,
SkScalerContextEffects* effects) {
SkFont font = SkFont::LEGACY_ExtractFromPaint(paint);
SkScalerContextRec rec;
MakeRecAndEffects(font, paint, surfaceProps, scalerContextFlags, deviceMatrix, &rec, effects);
MakeRecAndEffects(font, paint, surfaceProps, deviceMatrix, scalerContextFlags, &rec, effects);
return AutoDescriptorGivenRecAndEffects(rec, *effects, ad);
}

View File

@ -19,7 +19,6 @@
#include "SkMaskGamma.h"
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkSurfacePriv.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
@ -312,23 +311,25 @@ public:
static bool GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma,
uint8_t* data);
static void MakeRecAndEffects(const SkFont& font, const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
static void MakeRecAndEffects(const SkFont& font,
const SkPaint& paint,
const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix,
SkScalerContextRec* rec,
SkScalerContextEffects* effects,
bool enableTypefaceFiltering = true);
// If we are creating rec and effects from a font only, then there is no device around either.
static void MakeRecAndEffectsFromFont(const SkFont& font,
SkScalerContextRec* rec,
SkScalerContextEffects* effects,
bool enableTypefaceFiltering = true) {
static void MakeRecAndEffectsUsingDefaultPaint(const SkFont& font,
const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix,
SkScalerContextFlags scalerContextFlags,
SkScalerContextRec* rec,
SkScalerContextEffects* effects,
bool enableTypefaceFiltering = true) {
SkPaint paint;
return MakeRecAndEffects(
font, paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
SkScalerContextFlags::kNone, SkMatrix::I(), rec, effects, enableTypefaceFiltering);
return MakeRecAndEffects(font, paint, surfaceProps, deviceMatrix, scalerContextFlags,
rec, effects, enableTypefaceFiltering);
}
static SkDescriptor* MakeDescriptorForPaths(SkFontID fontID,
@ -363,9 +364,9 @@ public:
SkAxisAlignment computeAxisAlignmentForHText() const;
static SkDescriptor* CreateDescriptorAndEffectsUsingPaint(
const SkPaint& paint, const SkSurfaceProps& surfaceProps,
const SkPaint& paint, const SkSurfaceProps* surfaceProps,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix, SkAutoDescriptor* ad,
const SkMatrix* deviceMatrix, SkAutoDescriptor* ad,
SkScalerContextEffects* effects);
protected:

View File

@ -148,9 +148,9 @@ SkExclusiveStrikePtr SkStrikeCache::findOrCreateStrikeExclusive(
SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(
const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
const SkSurfaceProps* surfaceProps,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix)
const SkMatrix* deviceMatrix)
{
SkAutoDescriptor ad;
SkScalerContextEffects effects;
@ -163,10 +163,9 @@ SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(
return FindOrCreateStrikeExclusive(*desc, effects, *tf);
}
SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(const SkPaint& paint) {
SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(const SkPaint& paint) {
return FindOrCreateStrikeExclusive(
paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
kFakeGammaAndBoostContrast, SkMatrix::I());
paint, nullptr, kFakeGammaAndBoostContrast, nullptr);
}
void SkStrikeCache::PurgeAll() {

View File

@ -104,11 +104,11 @@ public:
static ExclusiveStrikePtr FindOrCreateStrikeExclusive(
const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
const SkSurfaceProps* surfaceProps,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix);
const SkMatrix* deviceMatrix);
static ExclusiveStrikePtr FindOrCreateStrikeWithNoDeviceExclusive(const SkPaint& paint);
static ExclusiveStrikePtr FindOrCreateStrikeExclusive(const SkPaint& paint);
static std::unique_ptr<SkScalerContext> CreateScalerContext(
const SkDescriptor&, const SkScalerContextEffects&, const SkTypeface&);

View File

@ -20,6 +20,10 @@ static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* p
}
}
static inline SkPixelGeometry SkSurfacePropsDefaultPixelGeometry() {
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType).pixelGeometry();
}
constexpr size_t kIgnoreRowBytesValue = static_cast<size_t>(~0);
bool SkSurfaceValidateRasterInfo(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);

View File

@ -14,7 +14,6 @@
#include "SkOTTable_OS_2.h"
#include "SkOnce.h"
#include "SkStream.h"
#include "SkSurfacePriv.h"
#include "SkTypeface.h"
#include "SkTypefaceCache.h"
@ -402,7 +401,10 @@ bool SkTypeface::onComputeBounds(SkRect* bounds) const {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContext::MakeRecAndEffectsFromFont(font, &rec, &effects);
const SkSurfaceProps* defaultProps = nullptr;
const SkMatrix* noDeviceMatrix = nullptr;
SkScalerContext::MakeRecAndEffectsUsingDefaultPaint(
font, defaultProps, noDeviceMatrix, SkScalerContextFlags::kNone, &rec, &effects);
SkAutoDescriptor ad;
SkScalerContextEffects noeffects;

View File

@ -59,10 +59,10 @@ sk_sp<GrTextBlob> GrTextBlob::Make(int glyphCount, int runCount) {
}
SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex,
const SkPaint& skPaint,
const SkSurfaceProps& props,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix) {
const SkSurfaceProps& props,
SkScalerContextFlags scalerContextFlags,
const SkPaint& skPaint,
const SkMatrix* viewMatrix) {
GrTextBlob::Run* run = &fRuns[runIndex];
// if we have an override descriptor for the run, then we should use that
@ -70,7 +70,7 @@ SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex,
&run->fDescriptor;
SkScalerContextEffects effects;
SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
skPaint, props, scalerContextFlags, viewMatrix, desc, &effects);
skPaint, &props, scalerContextFlags, viewMatrix, desc, &effects);
run->fTypeface = SkPaintPriv::RefTypefaceOrDefault(skPaint);
run->fPathEffect = sk_ref_sp(effects.fPathEffect);
run->fMaskFilter = sk_ref_sp(effects.fMaskFilter);

View File

@ -180,10 +180,10 @@ public:
}
SkExclusiveStrikePtr setupCache(int runIndex,
const SkPaint& skPaint,
const SkSurfaceProps& props,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix);
const SkPaint& skPaint,
const SkMatrix* viewMatrix);
// Appends a glyph to the blob. If the glyph is too large, the glyph will be appended
// as a path.

View File

@ -46,7 +46,7 @@ SkExclusiveStrikePtr SkPDFFont::MakeVectorCache(SkTypeface* face, int* size) {
tmpPaint.setTextSize((SkScalar)unitsPerEm);
const SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
return SkStrikeCache::FindOrCreateStrikeExclusive(
tmpPaint, props, SkScalerContextFlags::kFakeGammaAndBoostContrast, SkMatrix::I());
tmpPaint, &props, SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
}
namespace {

View File

@ -1873,8 +1873,8 @@ HRESULT SkXPSDevice::CreateTypefaceUse(const SkPaint& paint,
newTypefaceUse.xpsFont = xpsFontResource.release();
auto glyphCache =
SkStrikeCache::FindOrCreateStrikeExclusive(
paint, this->surfaceProps(),
SkScalerContextFlags::kNone, SkMatrix::I());
paint, &this->surfaceProps(),
SkScalerContextFlags::kNone, nullptr);
unsigned int glyphCount = glyphCache->getGlyphCount();
newTypefaceUse.glyphsUsed = new SkBitSet(glyphCount);
@ -2057,8 +2057,8 @@ void SkXPSDevice::drawPosText(const void* text, size_t byteLen,
auto cache =
SkStrikeCache::FindOrCreateStrikeExclusive(
paint, this->surfaceProps(),
SkScalerContextFlags::kNone, SkMatrix::I());
paint, &this->surfaceProps(),
SkScalerContextFlags::kNone, nullptr);
// Advance width and offsets for glyphs measured in hundredths of the font em size
// (XPS Spec 5.1.3).

View File

@ -14,7 +14,6 @@
#include "SkRemoteGlyphCacheImpl.h"
#include "SkStrikeCache.h"
#include "SkSurface.h"
#include "SkSurfacePriv.h"
#include "SkTestEmptyTypeface.h"
#include "SkTextBlob.h"
#include "SkTypeface_remote.h"
@ -119,21 +118,12 @@ SkTextBlobCacheDiffCanvas::Settings MakeSettings(GrContext* context) {
return settings;
}
sk_sp<SkSurface> MakeSurface(int width, int height, GrContext* context) {
const SkImageInfo info =
SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
}
const SkSurfaceProps FindSurfaceProps(GrContext* context) {
auto surface = MakeSurface(1, 1, context);
return surface->props();
}
SkBitmap RasterBlob(sk_sp<SkTextBlob> blob, int width, int height, const SkPaint& paint,
GrContext* context, const SkMatrix* matrix = nullptr,
SkScalar x = 0) {
auto surface = MakeSurface(width, height, context);
const SkImageInfo info =
SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
if (matrix) surface->getCanvas()->concat(*matrix);
surface->getCanvas()->drawTextBlob(blob.get(), x, 0, paint);
SkBitmap bitmap;
@ -171,7 +161,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_StrikeSerialization, repor
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
auto props = FindSurfaceProps(ctxInfo.grContext());
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@ -412,7 +402,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter,
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
auto props = FindSurfaceProps(ctxInfo.grContext());
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@ -489,7 +479,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsMaskWithPathFall
auto serverBlob = make_blob_causing_fallback(serverTf, serverTf.get(), reporter);
auto props = FindSurfaceProps(ctxInfo.grContext());
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@ -529,7 +519,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextXY, reporter, ctxI
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
auto props = FindSurfaceProps(ctxInfo.grContext());
const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0.5, 0, paint);
@ -658,9 +648,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
SkScalerContext::MakeRecAndEffects(
font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
SkMatrix::I(), &rec, &effects, false);
SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf);
@ -678,9 +666,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
SkScalerContext::MakeRecAndEffects(
font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
SkMatrix::I(), &rec, &effects, false);
SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto testCache = strikeCache.findStrikeExclusive(*desc);
REPORTER_ASSERT(reporter, !(testCache == nullptr));
@ -692,10 +678,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kNone;
SkScalerContext::MakeRecAndEffects(
font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
SkMatrix::I(),
&rec, &effects, false);
SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
testCache = strikeCache.findStrikeExclusive(*desc);
REPORTER_ASSERT(reporter, testCache == nullptr);
@ -771,9 +754,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(serverTf);
SkScalerContext::MakeRecAndEffects(
font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
SkMatrix::I(), &rec, &effects, false);
SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto context = serverTf->createScalerContext(effects, desc, false);
@ -791,9 +772,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(clientTf);
SkScalerContext::MakeRecAndEffects(
font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
SkMatrix::I(), &rec, &effects, false);
SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf);
@ -812,7 +791,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(serverTf);
auto* cacheState = server.getOrCreateCache(
paint, SkSurfacePropsCopyOrDefault(nullptr),
paint, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
SkMatrix::I(), flags, &effects);
cacheState->addGlyph(lostGlyphID, false);
@ -830,9 +809,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(clientTf);
SkScalerContext::MakeRecAndEffects(
font, paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), flags,
SkMatrix::I(), &rec, &effects, false);
SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto fallbackCache = strikeCache.findStrikeExclusive(*desc);