aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrRenderTargetContext.cpp12
-rw-r--r--src/gpu/text/GrTextContext.cpp36
-rw-r--r--src/gpu/text/GrTextContext.h3
-rw-r--r--src/gpu/text/GrTextUtils.h3
4 files changed, 35 insertions, 19 deletions
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index a67e19a9d9..fd515c7ec7 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -27,6 +27,7 @@
#include "GrStyle.h"
#include "GrTracing.h"
#include "SkDrawShadowInfo.h"
+#include "SkGlyphRun.h"
#include "SkGr.h"
#include "SkLatticeIter.h"
#include "SkMatrixPriv.h"
@@ -53,12 +54,15 @@
#include "text/GrTextContext.h"
#include "text/GrTextUtils.h"
+
+
class GrRenderTargetContext::TextTarget : public GrTextUtils::Target {
public:
TextTarget(GrRenderTargetContext* renderTargetContext)
: Target(renderTargetContext->width(), renderTargetContext->height(),
renderTargetContext->colorSpaceInfo())
- , fRenderTargetContext(renderTargetContext) {}
+ , fRenderTargetContext(renderTargetContext)
+ , fGlyphDrawer{*renderTargetContext}{}
void addDrawOp(const GrClip& clip, std::unique_ptr<GrAtlasTextOp> op) override {
fRenderTargetContext->addDrawOp(clip, std::move(op));
@@ -87,8 +91,14 @@ public:
return fRenderTargetContext->fContext;
}
+ SkGlyphRunListDrawer* glyphDrawer() override {
+ return &fGlyphDrawer;
+ }
+
private:
GrRenderTargetContext* fRenderTargetContext;
+ SkGlyphRunListDrawer fGlyphDrawer;
+
};
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this->drawingManager()->getContext())
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 7b15abc666..6017742707 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -92,7 +92,8 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
- const SkGlyphRunList& glyphRunList) const {
+ const SkGlyphRunList& glyphRunList,
+ SkGlyphRunListDrawer* glyphDrawer) {
SkPoint origin = glyphRunList.origin();
cacheBlob->initReusableBlob(paint.luminanceColor(), viewMatrix, origin.x(), origin.y());
@@ -193,19 +194,17 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
sk_sp<GrTextStrike> currStrike;
auto cache = cacheBlob->setupCache(
runIndex, props, scalerContextFlags, runPaint, &viewMatrix);
- SkFindAndPlaceGlyph::ProcessPosText(
- SkPaint::kGlyphID_TextEncoding,
- (const char*) glyphRun.shuntGlyphsIDs().data(),
- glyphRun.shuntGlyphsIDs().size() * sizeof(SkGlyphID),
- origin, viewMatrix, (const SkScalar*) glyphRun.positions().data(), 2, cache.get(),
- [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
- position += rounding;
- BmpAppendGlyph(cacheBlob, runIndex, glyphCache, &currStrike, glyph,
- SkScalarFloorToScalar(position.fX),
- SkScalarFloorToScalar(position.fY),
- runPaint.filteredPremulColor(), cache.get(), SK_Scalar1, false);
- }
- );
+
+ auto drawOneGlyph =
+ [cacheBlob, runIndex, glyphCache, &currStrike, runPaint, cache{cache.get()}]
+ (const SkMask& mask, const SkGlyph& glyph, SkPoint position) {
+ BmpAppendGlyph(cacheBlob, runIndex, glyphCache, &currStrike, glyph,
+ SkScalarFloorToScalar(position.fX),
+ SkScalarFloorToScalar(position.fY),
+ runPaint.filteredPremulColor(), cache, SK_Scalar1, false);
+ };
+
+ glyphDrawer->drawUsingMasks(cache.get(), glyphRun, origin, viewMatrix, drawOneGlyph);
}
runIndex += 1;
}
@@ -270,7 +269,8 @@ void GrTextContext::drawGlyphRunList(
cacheBlob = textBlobCache->makeCachedBlob(glyphRunList, key, blurRec, skPaint);
this->regenerateGlyphRunList(cacheBlob.get(), glyphCache,
*context->contextPriv().caps()->shaderCaps(), paint,
- scalerContextFlags, viewMatrix, props, glyphRunList);
+ scalerContextFlags, viewMatrix, props, glyphRunList,
+ target->glyphDrawer());
} else {
textBlobCache->makeMRU(cacheBlob.get());
@@ -281,7 +281,8 @@ void GrTextContext::drawGlyphRunList(
sanityBlob->setupKey(key, blurRec, skPaint);
this->regenerateGlyphRunList(
sanityBlob.get(), glyphCache, *context->contextPriv().caps()->shaderCaps(),
- paint, scalerContextFlags, viewMatrix, props, glyphRunList);
+ paint, scalerContextFlags, viewMatrix, props, glyphRunList,
+ target->glyphDrawer());
GrTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
}
}
@@ -293,7 +294,8 @@ void GrTextContext::drawGlyphRunList(
}
this->regenerateGlyphRunList(cacheBlob.get(), glyphCache,
*context->contextPriv().caps()->shaderCaps(), paint,
- scalerContextFlags, viewMatrix, props, glyphRunList);
+ scalerContextFlags, viewMatrix, props, glyphRunList,
+ target->glyphDrawer());
}
cacheBlob->flush(target, props, fDistanceAdjustTable.get(), paint,
diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h
index 2794a84b82..908e6419b8 100644
--- a/src/gpu/text/GrTextContext.h
+++ b/src/gpu/text/GrTextContext.h
@@ -158,7 +158,8 @@ private:
SkScalerContextFlags scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps&,
- const SkGlyphRunList& glyphRunList) const;
+ const SkGlyphRunList& glyphRunList,
+ SkGlyphRunListDrawer* glyphDrawer);
sk_sp<GrTextBlob> makeDrawPosTextBlob(GrTextBlobCache*, GrGlyphCache*,
const GrShaderCaps&,
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 05fbf6f35e..a02cebf7dd 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -27,6 +27,7 @@ class GrPaint;
class GrShaderCaps;
class SkColorSpace;
class SkGlyph;
+class SkGlyphRunListDrawer;
class SkMatrix;
struct SkIRect;
struct SkPoint;
@@ -58,6 +59,8 @@ public:
virtual GrContext* getContext() = 0;
+ virtual SkGlyphRunListDrawer* glyphDrawer() = 0;
+
protected:
Target(int width, int height, const GrColorSpaceInfo& colorSpaceInfo)
: fWidth(width), fHeight(height), fColorSpaceInfo(colorSpaceInfo) {}