aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text
diff options
context:
space:
mode:
authorGravatar Leon Scroggins <scroggo@google.com>2018-01-20 17:09:02 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-20 17:09:10 +0000
commit2914555e004676465c5255d8b42ee0d25887ac73 (patch)
treea93a781cd867005eb72071577064667e970c8430 /src/gpu/text
parent4f7f197c09443232f02cd81f3ac7fb5a216acd05 (diff)
Revert "Move more internal methods from GrContext to GrContextPriv (take 2)"
This reverts commit c22e50bd317fe3658445c04e18a6e319d746c510. Reason for revert: Speculative fix for Android roll Original change's description: > Move more internal methods from GrContext to GrContextPriv (take 2) > > Change-Id: I47108910517d61edeb52f82793d384fdb5605d45 > Reviewed-on: https://skia-review.googlesource.com/97241 > Commit-Queue: Robert Phillips <robertphillips@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: I3a77ac33c5f48529357cf9c683d5f4cacaa2379f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/97582 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/gpu/text')
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp33
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h8
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp64
-rw-r--r--src/gpu/text/GrTextUtils.cpp4
-rw-r--r--src/gpu/text/GrTextUtils.h20
5 files changed, 57 insertions, 72 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 8c3cefe33f..df848db6f7 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -348,7 +348,7 @@ static void calculate_translation(bool applyVM,
}
}
-void GrAtlasTextBlob::flushBigGlyphs(GrTextUtils::Target* target,
+void GrAtlasTextBlob::flushBigGlyphs(GrContext* context, GrTextUtils::Target* target,
const GrClip& clip, const SkPaint& paint,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
const SkIRect& clipBounds) {
@@ -367,11 +367,11 @@ void GrAtlasTextBlob::flushBigGlyphs(GrTextUtils::Target* target,
}
}
-void GrAtlasTextBlob::flushBigRun(GrTextUtils::Target* target,
- const SkSurfaceProps& props, const SkTextBlobRunIterator& it,
- const GrClip& clip, const GrTextUtils::Paint& paint,
- SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
- const SkIRect& clipBounds, SkScalar x, SkScalar y) {
+void GrAtlasTextBlob::flushBigRun(GrContext* context, GrTextUtils::Target* target,
+ const SkSurfaceProps& props, const SkTextBlobRunIterator& it,
+ const GrClip& clip, const GrTextUtils::Paint& paint,
+ SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
+ const SkIRect& clipBounds, SkScalar x, SkScalar y) {
size_t textLen = it.glyphCount() * sizeof(uint16_t);
const SkPoint& offset = it.offset();
@@ -382,24 +382,24 @@ void GrAtlasTextBlob::flushBigRun(GrTextUtils::Target* target,
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
- GrTextUtils::DrawBigText(target, clip, runPaint, viewMatrix,
+ GrTextUtils::DrawBigText(context, target, clip, runPaint, viewMatrix,
(const char*)it.glyphs(), textLen, x + offset.x(),
y + offset.y(), clipBounds);
break;
case SkTextBlob::kHorizontal_Positioning:
- GrTextUtils::DrawBigPosText(target, props, clip, runPaint, viewMatrix,
+ GrTextUtils::DrawBigPosText(context, target, props, clip, runPaint, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 1,
SkPoint::Make(x, y + offset.y()), clipBounds);
break;
case SkTextBlob::kFull_Positioning:
- GrTextUtils::DrawBigPosText(target, props, clip, runPaint, viewMatrix,
+ GrTextUtils::DrawBigPosText(context, target, props, clip, runPaint, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 2,
SkPoint::Make(x, y), clipBounds);
break;
}
}
-void GrAtlasTextBlob::flushCached(GrAtlasGlyphCache* atlasGlyphCache, GrTextUtils::Target* target,
+void GrAtlasTextBlob::flushCached(GrContext* context, GrTextUtils::Target* target,
const SkTextBlob* blob, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
const GrTextUtils::Paint& paint, SkDrawFilter* drawFilter,
@@ -410,20 +410,19 @@ void GrAtlasTextBlob::flushCached(GrAtlasGlyphCache* atlasGlyphCache, GrTextUtil
SkTextBlobRunIterator it(blob);
for (int run = 0; !it.done(); it.next(), run++) {
if (fRuns[run].fTooBigForAtlas) {
- this->flushBigRun(target, props, it, clip, paint, drawFilter, viewMatrix,
+ this->flushBigRun(context, target, props, it, clip, paint, drawFilter, viewMatrix,
clipBounds, x, y);
continue;
}
this->flushRun(target, clip, run, viewMatrix, x, y, paint, props, distanceAdjustTable,
- atlasGlyphCache);
+ context->getAtlasGlyphCache());
}
// Now flush big glyphs
- this->flushBigGlyphs(target, clip, paint, viewMatrix, x, y, clipBounds);
+ this->flushBigGlyphs(context, target, clip, paint, viewMatrix, x, y, clipBounds);
}
-void GrAtlasTextBlob::flushThrowaway(GrAtlasGlyphCache* atlasGlyphCache,
- GrTextUtils::Target* target,
+void GrAtlasTextBlob::flushThrowaway(GrContext* context, GrTextUtils::Target* target,
const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
const GrTextUtils::Paint& paint, const GrClip& clip,
@@ -431,11 +430,11 @@ void GrAtlasTextBlob::flushThrowaway(GrAtlasGlyphCache* atlasGlyphCache,
SkScalar x, SkScalar y) {
for (int run = 0; run < fRunCount; run++) {
this->flushRun(target, clip, run, viewMatrix, x, y, paint, props, distanceAdjustTable,
- atlasGlyphCache);
+ context->getAtlasGlyphCache());
}
// Now flush big glyphs
- this->flushBigGlyphs(target, clip, paint, viewMatrix, x, y, clipBounds);
+ this->flushBigGlyphs(context, target, clip, paint, viewMatrix, x, y, clipBounds);
}
std::unique_ptr<GrDrawOp> GrAtlasTextBlob::test_makeOp(
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 2b4047bdd6..b93632fcfe 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -195,14 +195,14 @@ public:
const SkMatrix& viewMatrix, SkScalar x, SkScalar y);
// flush a GrAtlasTextBlob associated with a SkTextBlob
- void flushCached(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkTextBlob* blob,
+ void flushCached(GrContext* context, GrTextUtils::Target*, const SkTextBlob* blob,
const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
const GrTextUtils::Paint&, SkDrawFilter* drawFilter, const GrClip& clip,
const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, SkScalar y);
// flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob
- void flushThrowaway(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkSurfaceProps& props,
+ void flushThrowaway(GrContext* context, GrTextUtils::Target*, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
const GrTextUtils::Paint& paint, const GrClip& clip,
const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
@@ -295,11 +295,11 @@ private:
const GrDistanceFieldAdjustTable* distanceAdjustTable,
GrAtlasGlyphCache* cache);
- void flushBigGlyphs(GrTextUtils::Target*, const GrClip& clip,
+ void flushBigGlyphs(GrContext* context, GrTextUtils::Target*, const GrClip& clip,
const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
const SkIRect& clipBounds);
- void flushBigRun(GrTextUtils::Target*, const SkSurfaceProps& props,
+ void flushBigRun(GrContext* context, GrTextUtils::Target*, const SkSurfaceProps& props,
const SkTextBlobRunIterator& it, const GrClip& clip,
const GrTextUtils::Paint& paint, SkDrawFilter* drawFilter,
const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 9fef8e39a3..bdbc600cc1 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -6,7 +6,6 @@
*/
#include "GrAtlasTextContext.h"
#include "GrContext.h"
-#include "GrContextPriv.h"
#include "GrTextBlobCache.h"
#include "SkDistanceFieldGen.h"
#include "SkDraw.h"
@@ -122,9 +121,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* t
drawFilter);
uint32_t scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo());
- auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
- GrTextBlobCache* textBlobCache = context->contextPriv().getTextBlobCache();
-
+ GrTextBlobCache* cache = context->getTextBlobCache();
if (canCache) {
bool hasLCD = HasLCD(blob);
@@ -144,7 +141,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* t
key.fHasBlur = SkToBool(mf);
key.fCanonicalColor = canonicalColor;
key.fScalerContextFlags = scalerContextFlags;
- cacheBlob = textBlobCache->find(key);
+ cacheBlob = cache->find(key);
}
GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
@@ -153,21 +150,21 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* t
// We have to remake the blob because changes may invalidate our masks.
// TODO we could probably get away reuse most of the time if the pointer is unique,
// but we'd have to clear the subrun information
- textBlobCache->remove(cacheBlob.get());
- cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint);
- this->regenerateTextBlob(cacheBlob.get(), atlasGlyphCache,
+ cache->remove(cacheBlob.get());
+ cacheBlob = cache->makeCachedBlob(blob, key, blurRec, skPaint);
+ this->regenerateTextBlob(cacheBlob.get(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), paint, scalerContextFlags,
viewMatrix, props, blob, x, y, drawFilter);
} else {
- textBlobCache->makeMRU(cacheBlob.get());
+ cache->makeMRU(cacheBlob.get());
if (CACHE_SANITY_CHECK) {
int glyphCount = 0;
int runCount = 0;
GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
- sk_sp<GrAtlasTextBlob> sanityBlob(textBlobCache->makeBlob(glyphCount, runCount));
+ sk_sp<GrAtlasTextBlob> sanityBlob(cache->makeBlob(glyphCount, runCount));
sanityBlob->setupKey(key, blurRec, skPaint);
- this->regenerateTextBlob(sanityBlob.get(), atlasGlyphCache,
+ this->regenerateTextBlob(sanityBlob.get(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), paint, scalerContextFlags,
viewMatrix, props, blob, x, y, drawFilter);
GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
@@ -175,16 +172,16 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* t
}
} else {
if (canCache) {
- cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint);
+ cacheBlob = cache->makeCachedBlob(blob, key, blurRec, skPaint);
} else {
- cacheBlob = textBlobCache->makeBlob(blob);
+ cacheBlob = cache->makeBlob(blob);
}
- this->regenerateTextBlob(cacheBlob.get(), atlasGlyphCache,
+ this->regenerateTextBlob(cacheBlob.get(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), paint, scalerContextFlags,
viewMatrix, props, blob, x, y, drawFilter);
}
- cacheBlob->flushCached(atlasGlyphCache, target, blob, props, fDistanceAdjustTable.get(), paint,
+ cacheBlob->flushCached(context, target, blob, props, fDistanceAdjustTable.get(), paint,
drawFilter, clip, viewMatrix, clipBounds, x, y);
}
@@ -321,27 +318,23 @@ void GrAtlasTextContext::drawText(GrContext* context, GrTextUtils::Target* targe
if (context->abandoned()) {
return;
}
-
- auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
- auto textBlobCache = context->contextPriv().getTextBlobCache();
-
GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
- if (this->canDraw(atlasGlyphCache, skPaint, viewMatrix, props,
+ if (this->canDraw(context->getAtlasGlyphCache(), skPaint, viewMatrix, props,
*context->caps()->shaderCaps())) {
sk_sp<GrAtlasTextBlob> blob(
- this->makeDrawTextBlob(textBlobCache, atlasGlyphCache,
+ this->makeDrawTextBlob(context->getTextBlobCache(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), paint,
ComputeScalerContextFlags(target->colorSpaceInfo()),
viewMatrix, props, text, byteLength, x, y));
if (blob) {
- blob->flushThrowaway(atlasGlyphCache, target, props, fDistanceAdjustTable.get(), paint,
- clip, viewMatrix, regionClipBounds, x, y);
+ blob->flushThrowaway(context, target, props, fDistanceAdjustTable.get(), paint, clip,
+ viewMatrix, regionClipBounds, x, y);
}
return;
}
// fall back to drawing as a path or scaled glyph
- GrTextUtils::DrawBigText(target, clip, paint, viewMatrix, text, byteLength, x, y,
+ GrTextUtils::DrawBigText(context, target, clip, paint, viewMatrix, text, byteLength, x, y,
regionClipBounds);
}
@@ -354,27 +347,22 @@ void GrAtlasTextContext::drawPosText(GrContext* context, GrTextUtils::Target* ta
GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
if (context->abandoned()) {
return;
- }
-
- auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
- auto textBlobCache = context->contextPriv().getTextBlobCache();
-
- if (this->canDraw(atlasGlyphCache, skPaint, viewMatrix, props,
- *context->caps()->shaderCaps())) {
+ } else if (this->canDraw(context->getAtlasGlyphCache(), skPaint, viewMatrix, props,
+ *context->caps()->shaderCaps())) {
sk_sp<GrAtlasTextBlob> blob(this->makeDrawPosTextBlob(
- textBlobCache, atlasGlyphCache,
+ context->getTextBlobCache(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), paint,
ComputeScalerContextFlags(target->colorSpaceInfo()), viewMatrix, props, text,
byteLength, pos, scalarsPerPosition, offset));
if (blob) {
- blob->flushThrowaway(atlasGlyphCache, target, props, fDistanceAdjustTable.get(), paint,
- clip, viewMatrix, regionClipBounds, offset.fX, offset.fY);
+ blob->flushThrowaway(context, target, props, fDistanceAdjustTable.get(), paint, clip,
+ viewMatrix, regionClipBounds, offset.fX, offset.fY);
}
return;
}
// fall back to drawing as a path or scaled glyph
- GrTextUtils::DrawBigPosText(target, props, clip, paint, viewMatrix, text,
+ GrTextUtils::DrawBigPosText(context, target, props, clip, paint, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, regionClipBounds);
}
@@ -848,18 +836,16 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) {
SkScalar x = SkIntToScalar(xInt);
SkScalar y = SkIntToScalar(yInt);
- auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
-
// right now we don't handle textblobs, nor do we handle drawPosText. Since we only intend to
// test the text op with this unit test, that is okay.
sk_sp<GrAtlasTextBlob> blob(gTextContext->makeDrawTextBlob(
- context->contextPriv().getTextBlobCache(), atlasGlyphCache,
+ context->getTextBlobCache(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), utilsPaint,
GrAtlasTextContext::kTextBlobOpScalerContextFlags, viewMatrix, gSurfaceProps, text,
static_cast<size_t>(textLen), x, y));
return blob->test_makeOp(textLen, 0, 0, viewMatrix, x, y, utilsPaint, gSurfaceProps,
- gTextContext->dfAdjustTable(), atlasGlyphCache,
+ gTextContext->dfAdjustTable(), context->getAtlasGlyphCache(),
rtc->textTarget());
}
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index d4a80e0600..20a3a5c52c 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -78,7 +78,7 @@ bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) {
paint.isFakeBoldText() || paint.getStyle() != SkPaint::kFill_Style;
}
-void GrTextUtils::DrawBigText(GrTextUtils::Target* target,
+void GrTextUtils::DrawBigText(GrContext* context, GrTextUtils::Target* target,
const GrClip& clip, const SkPaint& paint,
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) {
@@ -104,7 +104,7 @@ void GrTextUtils::DrawBigText(GrTextUtils::Target* target,
}
}
-void GrTextUtils::DrawBigPosText(GrTextUtils::Target* target,
+void GrTextUtils::DrawBigPosText(GrContext* context, GrTextUtils::Target* target,
const SkSurfaceProps& props, const GrClip& clip,
const SkPaint& origPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, const SkScalar pos[],
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 252cd7c626..3b1968decd 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -129,17 +129,17 @@ public:
static bool ShouldDisableLCD(const SkPaint& paint);
// Functions for drawing large text either as paths or (for color emoji) as scaled glyphs
- static void DrawBigText(GrTextUtils::Target*, const GrClip& clip,
- const SkPaint& paint, const SkMatrix& viewMatrix, const char text[],
- size_t byteLength, SkScalar x, SkScalar y,
- const SkIRect& clipBounds);
-
- static void DrawBigPosText(GrTextUtils::Target*,
- const SkSurfaceProps& props, const GrClip& clip,
- const SkPaint& paint, const SkMatrix& viewMatrix,
- const char text[], size_t byteLength, const SkScalar pos[],
- int scalarsPerPosition, const SkPoint& offset,
+ static void DrawBigText(GrContext*, GrTextUtils::Target*, const GrClip& clip,
+ const SkPaint& paint, const SkMatrix& viewMatrix, const char text[],
+ size_t byteLength, SkScalar x, SkScalar y,
const SkIRect& clipBounds);
+
+ static void DrawBigPosText(GrContext* context, GrTextUtils::Target*,
+ const SkSurfaceProps& props, const GrClip& clip,
+ const SkPaint& paint, const SkMatrix& viewMatrix,
+ const char text[], size_t byteLength, const SkScalar pos[],
+ int scalarsPerPosition, const SkPoint& offset,
+ const SkIRect& clipBounds);
};
#endif