aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-01-22 14:39:27 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-23 18:13:36 +0000
commitd8327a8c8bad870112b574c4533270370f5c1ccf (patch)
treef62b2e9f47f60bf0eb2cbcddb9686ad2cf9fee03 /src/gpu/text
parent0331d37af9656e2e7c5dd1d79cb12396d51a19e9 (diff)
Clean up SkScalerContext descriptor creation
Allow a descriptor creation using just a rec and effects. This is the most complex part of the change. Cleanup SkScalerContextFlags to be a real thing. This has spread everywhere. BUG=skia:7515 Change-Id: I67189c9aeb51f1777a1c60145216524d440cb890 Reviewed-on: https://skia-review.googlesource.com/98320 Commit-Queue: Herb Derby <herb@google.com> Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src/gpu/text')
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp4
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h2
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp31
-rw-r--r--src/gpu/text/GrAtlasTextContext.h61
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp2
5 files changed, 53 insertions, 47 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 9e9f58a4d6..69e5e775be 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -49,7 +49,7 @@ sk_sp<GrAtlasTextBlob> GrAtlasTextBlob::Make(GrMemoryPool* pool, int glyphCount,
SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex,
const SkSurfaceProps& props,
- uint32_t scalerContextFlags,
+ SkScalerContextFlags scalerContextFlags,
const SkPaint& skPaint,
const SkMatrix* viewMatrix) {
GrAtlasTextBlob::Run* run = &fRuns[runIndex];
@@ -58,7 +58,7 @@ SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex,
SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDescriptor.get() :
&run->fDescriptor;
SkScalerContextEffects effects;
- skPaint.getScalerContextDescriptor(&effects, desc, props, scalerContextFlags, viewMatrix);
+ skPaint.getScalerContextDescriptor(&effects, desc, &props, scalerContextFlags, viewMatrix);
run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
run->fPathEffect = sk_ref_sp(effects.fPathEffect);
run->fMaskFilter = sk_ref_sp(effects.fMaskFilter);
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 11cb059602..94ec54a775 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -163,7 +163,7 @@ public:
SkGlyphCache* setupCache(int runIndex,
const SkSurfaceProps& props,
- uint32_t scalerContextFlags,
+ SkScalerContextFlags scalerContextFlags,
const SkPaint& skPaint,
const SkMatrix* viewMatrix);
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 946bf1371a..4193c7d32c 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -78,13 +78,14 @@ SkColor GrAtlasTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd
return canonicalColor;
}
-uint32_t GrAtlasTextContext::ComputeScalerContextFlags(const GrColorSpaceInfo& colorSpaceInfo) {
+SkScalerContextFlags GrAtlasTextContext::ComputeScalerContextFlags(
+ const GrColorSpaceInfo& colorSpaceInfo) {
// If we're doing gamma-correct rendering, then we can disable the gamma hacks.
// Otherwise, leave them on. In either case, we still want the contrast boost:
if (colorSpaceInfo.isGammaCorrect()) {
- return SkPaint::kBoostContrast_ScalerContextFlag;
+ return SkScalerContextFlags::kBoostContrast;
} else {
- return SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
+ return SkScalerContextFlags::kFakeGammaAndBoostContrast;
}
}
@@ -120,7 +121,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* t
bool canCache = !(skPaint.getPathEffect() ||
(mf && !mf->asABlur(&blurRec)) ||
drawFilter);
- uint32_t scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo());
+ SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo());
auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
GrTextBlobCache* textBlobCache = context->contextPriv().getTextBlobCache();
@@ -192,7 +193,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
GrAtlasGlyphCache* fontCache,
const GrShaderCaps& shaderCaps,
const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props, const SkTextBlob* blob,
SkScalar x, SkScalar y,
@@ -262,7 +263,7 @@ GrAtlasTextContext::makeDrawTextBlob(GrTextBlobCache* blobCache,
GrAtlasGlyphCache* fontCache,
const GrShaderCaps& shaderCaps,
const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
const char text[], size_t byteLength,
@@ -289,7 +290,7 @@ GrAtlasTextContext::makeDrawPosTextBlob(GrTextBlobCache* blobCache,
GrAtlasGlyphCache* fontCache,
const GrShaderCaps& shaderCaps,
const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
const char text[], size_t byteLength,
@@ -380,7 +381,8 @@ void GrAtlasTextContext::drawPosText(GrContext* context, GrTextUtils::Target* ta
void GrAtlasTextContext::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
GrAtlasGlyphCache* fontCache, const SkSurfaceProps& props,
- const GrTextUtils::Paint& paint, uint32_t scalerContextFlags,
+ const GrTextUtils::Paint& paint,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix, const char text[],
size_t byteLength, SkScalar x, SkScalar y) {
SkASSERT(byteLength == 0 || text != nullptr);
@@ -413,7 +415,8 @@ void GrAtlasTextContext::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
void GrAtlasTextContext::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
GrAtlasGlyphCache* fontCache, const SkSurfaceProps& props,
const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags, const SkMatrix& viewMatrix,
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& viewMatrix,
const char text[], size_t byteLength, const SkScalar pos[],
int scalarsPerPosition, const SkPoint& offset,
SkScalar textRatio) {
@@ -580,7 +583,8 @@ void GrAtlasTextContext::initDistanceFieldPaint(GrAtlasTextBlob* blob,
void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex,
GrAtlasGlyphCache* fontCache, const SkSurfaceProps& props,
- const GrTextUtils::Paint& paint, uint32_t scalerContextFlags,
+ const GrTextUtils::Paint& paint,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix, const char text[],
size_t byteLength, SkScalar x, SkScalar y) const {
SkASSERT(byteLength == 0 || text != nullptr);
@@ -597,7 +601,7 @@ void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex,
SkScalerContextEffects effects;
// We apply the fake-gamma by altering the distance in the shader, so we ignore the
// passed-in scaler context flags. (It's only used when we fall-back to bitmap text).
- skPaint.getScalerContextDescriptor(&effects, &desc, props, SkPaint::kNone_ScalerContextFlags,
+ skPaint.getScalerContextDescriptor(&effects, &desc, &props, SkScalerContextFlags::kNone,
nullptr);
SkGlyphCache* origPaintCache =
SkGlyphCache::DetachCache(skPaint.getTypeface(), effects, desc.getDesc());
@@ -654,7 +658,8 @@ void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex,
void GrAtlasTextContext::drawDFPosText(GrAtlasTextBlob* blob, int runIndex,
GrAtlasGlyphCache* fontCache, const SkSurfaceProps& props,
- const GrTextUtils::Paint& paint, uint32_t scalerContextFlags,
+ const GrTextUtils::Paint& paint,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix, const char text[],
size_t byteLength, const SkScalar pos[],
int scalarsPerPosition, const SkPoint& offset) const {
@@ -691,7 +696,7 @@ void GrAtlasTextContext::drawDFPosText(GrAtlasTextBlob* blob, int runIndex,
// We apply the fake-gamma by altering the distance in the shader, so we ignore the
// passed-in scaler context flags. (It's only used when we fall-back to bitmap text).
SkGlyphCache* cache =
- blob->setupCache(runIndex, props, SkPaint::kNone_ScalerContextFlags, dfPaint, nullptr);
+ blob->setupCache(runIndex, props, SkScalerContextFlags::kNone, dfPaint, nullptr);
SkPaint::GlyphCacheProc glyphCacheProc =
SkPaint::GetGlyphCacheProc(dfPaint.getTextEncoding(), dfPaint.isDevKernText(), true);
diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h
index b03ffa3fbf..36e83c4574 100644
--- a/src/gpu/text/GrAtlasTextContext.h
+++ b/src/gpu/text/GrAtlasTextContext.h
@@ -62,50 +62,50 @@ private:
GrAtlasTextContext(const Options& options);
// sets up the descriptor on the blob and returns a detached cache. Client must attach
- inline static SkColor ComputeCanonicalColor(const SkPaint&, bool lcd);
+ static SkColor ComputeCanonicalColor(const SkPaint&, bool lcd);
// Determines if we need to use fake gamma (and contrast boost):
- inline static uint32_t ComputeScalerContextFlags(const GrColorSpaceInfo&);
+ static SkScalerContextFlags ComputeScalerContextFlags(const GrColorSpaceInfo&);
void regenerateTextBlob(GrAtlasTextBlob* bmp,
GrAtlasGlyphCache*,
const GrShaderCaps&,
const GrTextUtils::Paint&,
- uint32_t scalerContextFlags,
+ SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps&,
const SkTextBlob* blob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter) const;
- inline static bool HasLCD(const SkTextBlob*);
-
- inline sk_sp<GrAtlasTextBlob> makeDrawTextBlob(GrTextBlobCache*, GrAtlasGlyphCache*,
- const GrShaderCaps&,
- const GrTextUtils::Paint&,
- uint32_t scalerContextFlags,
- const SkMatrix& viewMatrix,
- const SkSurfaceProps&,
- const char text[], size_t byteLength,
- SkScalar x, SkScalar y) const;
-
- inline sk_sp<GrAtlasTextBlob> makeDrawPosTextBlob(GrTextBlobCache*, GrAtlasGlyphCache*,
- const GrShaderCaps&,
- const GrTextUtils::Paint&,
- uint32_t scalerContextFlags,
- const SkMatrix& viewMatrix,
- const SkSurfaceProps&,
- const char text[], size_t byteLength,
- const SkScalar pos[],
- int scalarsPerPosition,
- const SkPoint& offset) const;
+ static bool HasLCD(const SkTextBlob*);
+
+ sk_sp<GrAtlasTextBlob> makeDrawTextBlob(GrTextBlobCache*, GrAtlasGlyphCache*,
+ const GrShaderCaps&,
+ const GrTextUtils::Paint&,
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
+ const char text[], size_t byteLength,
+ SkScalar x, SkScalar y) const;
+
+ sk_sp<GrAtlasTextBlob> makeDrawPosTextBlob(GrTextBlobCache*, GrAtlasGlyphCache*,
+ const GrShaderCaps&,
+ const GrTextUtils::Paint&,
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
+ const char text[], size_t byteLength,
+ const SkScalar pos[],
+ int scalarsPerPosition,
+ const SkPoint& offset) const;
// Functions for appending BMP text to GrAtlasTextBlob
static void DrawBmpText(GrAtlasTextBlob*, int runIndex, GrAtlasGlyphCache*,
const SkSurfaceProps&, const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags, const SkMatrix& viewMatrix,
+ SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, SkScalar x, SkScalar y);
static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex, GrAtlasGlyphCache*,
const SkSurfaceProps&, const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags, const SkMatrix& viewMatrix,
+ SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, const SkScalar pos[],
int scalarsPerPosition, const SkPoint& offset,
SkScalar textRatio);
@@ -115,13 +115,14 @@ private:
const SkSurfaceProps& props, const GrShaderCaps& caps) const;
void drawDFText(GrAtlasTextBlob* blob, int runIndex, GrAtlasGlyphCache*, const SkSurfaceProps&,
- const GrTextUtils::Paint& paint, uint32_t scalerContextFlags,
+ const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x,
SkScalar y) const;
void drawDFPosText(GrAtlasTextBlob* blob, int runIndex, GrAtlasGlyphCache*,
const SkSurfaceProps&, const GrTextUtils::Paint& paint,
- uint32_t scalerContextFlags, const SkMatrix& viewMatrix, const char text[],
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& viewMatrix, const char text[],
size_t byteLength, const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) const;
@@ -147,8 +148,8 @@ private:
bool fDistanceFieldVerticesAlwaysHaveW;
#if GR_TEST_UTILS
- static const uint32_t kTextBlobOpScalerContextFlags =
- SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
+ static const SkScalerContextFlags kTextBlobOpScalerContextFlags =
+ SkScalerContextFlags::kFakeGammaAndBoostContrast;
GR_DRAW_OP_TEST_FRIEND(GrAtlasTextOp);
#endif
};
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index fd467fcea5..2170f0a486 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -605,7 +605,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
SkGlyphCache* GrStencilAndCoverTextContext::TextRun::getGlyphCache() const {
if (!fDetachedGlyphCache) {
- fDetachedGlyphCache = fFont.detachCache(nullptr, SkPaint::kNone_ScalerContextFlags,
+ fDetachedGlyphCache = fFont.detachCache(nullptr, SkScalerContextFlags::kNone,
nullptr);
}
return fDetachedGlyphCache;