Skip to content

Commit

Permalink
Remove posText system from GrTextContext
Browse files Browse the repository at this point in the history
Remove the drawPosText code stack, and all supporting code.

Change-Id: Ie6ee64d012d390911faeb3c486d66cac40497744
Reviewed-on: https://skia-review.googlesource.com/145533
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
  • Loading branch information
herbderby authored and Skia Commit-Bot committed Aug 6, 2018
1 parent 641ac7d commit 82c11e0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 447 deletions.
37 changes: 13 additions & 24 deletions src/core/SkRemoteGlyphCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,18 @@ SkScalar glyph_size_limit(const SkTextBlobCacheDiffCanvas::Settings& settings) {
}

void add_glyph_to_cache(SkStrikeServer::SkGlyphCacheState* cache, SkTypeface* tf,
const SkScalerContextEffects& effects, const char** text) {
const SkScalerContextEffects& effects, SkGlyphID glyphID) {
SkASSERT(cache != nullptr);
SkASSERT(text != nullptr);

const uint16_t* ptr = *(const uint16_t**)text;
unsigned glyphID = *ptr;
ptr += 1;
*text = (const char*)ptr;
cache->addGlyph(tf, effects, SkPackedGlyphID(glyphID, 0, 0), false);
}

void add_fallback_text_to_cache(const GrTextContext::FallbackTextHelper& helper,
void add_fallback_text_to_cache(const GrTextContext::FallbackGlyphRunHelper& helper,
const SkSurfaceProps& props,
const SkMatrix& matrix,
const SkPaint& origPaint,
SkStrikeServer* server) {
if (!helper.fallbackText().count()) return;
if (helper.fallbackText().empty()) return;

TRACE_EVENT0("skia", "add_fallback_text_to_cache");
SkPaint fallbackPaint{origPaint};
Expand All @@ -204,10 +199,8 @@ void add_fallback_text_to_cache(const GrTextContext::FallbackTextHelper& helper,
server->getOrCreateCache(fallbackPaint, &props, &fallbackMatrix,
SkScalerContextFlags::kFakeGammaAndBoostContrast, &effects);

const char* text = helper.fallbackText().begin();
const char* stop = text + helper.fallbackText().count();
while (text < stop) {
add_glyph_to_cache(glyphCacheState, fallbackPaint.getTypeface(), effects, &text);
for (auto glyphID : helper.fallbackText()) {
add_glyph_to_cache(glyphCacheState, fallbackPaint.getTypeface(), effects, glyphID);
}
}
#endif
Expand Down Expand Up @@ -343,7 +336,7 @@ class SkTextBlobCacheDiffCanvas::TrackLayerDevice : public SkNoPixelsDevice {
SkPaint pathPaint(runPaint);
#if SK_SUPPORT_GPU
SkScalar matrixScale = pathPaint.setupForAsPaths();
GrTextContext::FallbackTextHelper fallbackTextHelper(
GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(
runMatrix, runPaint, glyph_size_limit(fSettings), matrixScale);
const SkPoint emptyPosition{0, 0};
#else
Expand All @@ -359,18 +352,16 @@ class SkTextBlobCacheDiffCanvas::TrackLayerDevice : public SkNoPixelsDevice {
SkScalerContextFlags::kFakeGammaAndBoostContrast, &effects);

const bool asPath = true;
const SkIPoint subPixelPos{0, 0};
const uint16_t* glyphs = it.glyphs();
const SkGlyphID* glyphs = it.glyphs();
for (uint32_t index = 0; index < it.glyphCount(); index++) {
auto glyphID = SkPackedGlyphID(glyphs[index], subPixelPos.x(), subPixelPos.y());
auto glyphID = glyphs[index];
#if SK_SUPPORT_GPU
const auto& glyph =
glyphCacheState->findGlyph(runPaint.getTypeface(), effects, glyphID);
if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
// Note that we send data for the original glyph even in the case of fallback
// since its glyph metrics will still be used on the client.
fallbackTextHelper.appendText(glyph, sizeof(uint16_t), (const char*)&glyphs[index],
emptyPosition);
fallbackTextHelper.appendGlyph(glyph, glyphID, emptyPosition);
}
#endif
glyphCacheState->addGlyph(runPaint.getTypeface(), effects, glyphID, asPath);
Expand Down Expand Up @@ -407,27 +398,25 @@ class SkTextBlobCacheDiffCanvas::TrackLayerDevice : public SkNoPixelsDevice {
auto* glyphCacheState = fStrikeServer->getOrCreateCache(dfPaint, &this->surfaceProps(),
nullptr, flags, &effects);

GrTextContext::FallbackTextHelper fallbackTextHelper(
GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(
runMatrix, runPaint, glyph_size_limit(fSettings), textRatio);
const bool asPath = false;
const SkIPoint subPixelPos{0, 0};
const SkPoint emptyPosition{0, 0};
const uint16_t* glyphs = it.glyphs();
for (uint32_t index = 0; index < it.glyphCount(); index++) {
auto glyphID = SkPackedGlyphID(glyphs[index], subPixelPos.x(), subPixelPos.y());
auto glyphID = glyphs[index];
const auto& glyph =
glyphCacheState->findGlyph(runPaint.getTypeface(), effects, glyphID);
if (glyph.fMaskFormat != SkMask::kSDF_Format) {
// Note that we send data for the original glyph even in the case of fallback
// since its glyph metrics will still be used on the client.
fallbackTextHelper.appendText(glyph, sizeof(uint16_t), (const char*)&glyphs[index],
emptyPosition);
fallbackTextHelper.appendGlyph(glyph, glyphID, emptyPosition);
}

glyphCacheState->addGlyph(
runPaint.getTypeface(),
effects,
SkPackedGlyphID(glyphs[index], subPixelPos.x(), subPixelPos.y()),
SkPackedGlyphID(glyphs[index]),
asPath);
}

Expand Down
16 changes: 0 additions & 16 deletions src/gpu/GrRenderTargetContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,6 @@ GrOpList* GrRenderTargetContext::getOpList() {
return this->getRTOpList();
}

void GrRenderTargetContext::drawPosText(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) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "drawPosText", fContext);

GrTextContext* atlasTextContext = this->drawingManager()->getTextContext();
atlasTextContext->drawPosText(fContext, fTextTarget.get(), clip, paint, viewMatrix,
fSurfaceProps, text, byteLength, pos, scalarsPerPosition, offset,
clipBounds);
}

void GrRenderTargetContext::drawGlyphRunList(
const GrClip& clip, const SkMatrix& viewMatrix,
const SkGlyphRunList& blob, const SkIRect& clipBounds) {
Expand Down
9 changes: 0 additions & 9 deletions src/gpu/GrRenderTargetContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ class SK_API GrRenderTargetContext : public GrSurfaceContext {
public:
~GrRenderTargetContext() override;

// We use SkPaint rather than GrPaint here for two reasons:
// * The SkPaint carries extra text settings. If these were extracted to a lighter object
// we could use GrPaint except that
// * SkPaint->GrPaint conversion depends upon whether the glyphs are color or grayscale and
// this can vary within a text run.
virtual void drawPosText(const GrClip&, const SkPaint&, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, const SkScalar pos[],
int scalarsPerPosition, const SkPoint& offset,
const SkIRect& clipBounds);
virtual void drawGlyphRunList(const GrClip&,
const SkMatrix& viewMatrix, const SkGlyphRunList&,
const SkIRect& clipBounds);
Expand Down
7 changes: 0 additions & 7 deletions src/gpu/SkGpuDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1630,13 +1630,6 @@ void SkGpuDevice::drawPosText(const void* text, size_t byteLength,
const SkPoint& offset, const SkPaint& paint) {

SK_ABORT("Oh no!!! There is not drawPosText for GPU device anymore!");
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext.get());
SkDEBUGCODE(this->validate();)

fRenderTargetContext->drawPosText(this->clip(), paint, this->ctm(), (const char*)text,
byteLength, pos, scalarsPerPos, offset,
this->devClipBounds());
}

void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
Expand Down
Loading

0 comments on commit 82c11e0

Please sign in to comment.