aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-02-11 05:42:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-11 05:42:30 -0800
commit2c89bc153b5228c6316b5cfa070cad3d6da169ca (patch)
tree5fd37f77042352234538df3a429f0ff23c70b7c5 /src
parent9a1ed5d81dbfc7d5b67b568dfe12b4033a9af154 (diff)
Move surface props off of GrTextContext
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawContext.cpp9
-rw-r--r--src/gpu/GrDrawingManager.cpp20
-rw-r--r--src/gpu/GrDrawingManager.h6
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp83
-rw-r--r--src/gpu/text/GrAtlasTextContext.h19
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp55
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.h14
-rw-r--r--src/gpu/text/GrTextContext.cpp5
-rw-r--r--src/gpu/text/GrTextContext.h12
9 files changed, 121 insertions, 102 deletions
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 6161626501..ed969f7e82 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -118,7 +118,7 @@ void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix,
+ fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
text, byteLength, x, y, clipBounds);
}
@@ -137,8 +137,8 @@ void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, text, byteLength,
- pos, scalarsPerPosition, offset, clipBounds);
+ fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps, text,
+ byteLength, pos, scalarsPerPosition, offset, clipBounds);
}
@@ -155,7 +155,8 @@ void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, blob, x, y, filter, clipBounds);
+ fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, fSurfaceProps, blob, x, y, filter,
+ clipBounds);
}
void GrDrawContext::discard() {
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 9400bcb387..5b23b0c694 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -31,12 +31,8 @@ void GrDrawingManager::cleanup() {
delete fNVPRTextContext;
fNVPRTextContext = nullptr;
- for (int i = 0; i < kNumPixelGeometries; ++i) {
- delete fTextContexts[i][0];
- fTextContexts[i][0] = nullptr;
- delete fTextContexts[i][1];
- fTextContexts[i][1] = nullptr;
- }
+ delete fAtlasTextContext;
+ fAtlasTextContext = nullptr;
delete fPathRendererChain;
fPathRendererChain = nullptr;
@@ -118,13 +114,11 @@ void GrDrawingManager::flush() {
fFlushing = false;
}
-GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props,
- GrRenderTarget* rt) {
+GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, GrRenderTarget* rt) {
if (this->abandoned()) {
return nullptr;
}
- SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
bool useDIF = props.isUseDeviceIndependentFonts();
if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() &&
@@ -132,18 +126,18 @@ GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props,
GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAttachment(rt);
if (sb) {
if (!fNVPRTextContext) {
- fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext, props);
+ fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext);
}
return fNVPRTextContext;
}
}
- if (!fTextContexts[props.pixelGeometry()][useDIF]) {
- fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Create(fContext, props);
+ if (!fAtlasTextContext) {
+ fAtlasTextContext = GrAtlasTextContext::Create(fContext);
}
- return fTextContexts[props.pixelGeometry()][useDIF];
+ return fAtlasTextContext;
}
GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index df6c71a322..a6d0104583 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -36,7 +36,7 @@ public:
bool abandoned() const { return fAbandoned; }
void freeGpuResources();
- GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps);
+ GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps*);
GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt);
@@ -61,11 +61,11 @@ private:
, fSingleOwner(singleOwner)
, fAbandoned(false)
, fNVPRTextContext(nullptr)
+ , fAtlasTextContext(nullptr)
, fPathRendererChain(nullptr)
, fSoftwarePathRenderer(nullptr)
, fFlushState(context->getGpu(), context->resourceProvider())
, fFlushing(false) {
- sk_bzero(fTextContexts, sizeof(fTextContexts));
}
void abandon();
@@ -88,7 +88,7 @@ private:
SkTDArray<GrDrawTarget*> fDrawTargets;
GrTextContext* fNVPRTextContext;
- GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
+ GrTextContext* fAtlasTextContext;
GrPathRendererChain* fPathRendererChain;
GrSoftwarePathRenderer* fSoftwarePathRenderer;
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 5e346452bd..ac2df24e48 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -34,8 +34,8 @@
#include "batches/GrAtlasTextBatch.h"
-GrAtlasTextContext::GrAtlasTextContext(GrContext* context, const SkSurfaceProps& surfaceProps)
- : INHERITED(context, surfaceProps)
+GrAtlasTextContext::GrAtlasTextContext(GrContext* context)
+ : INHERITED(context)
, fDistanceAdjustTable(new GrDistanceFieldAdjustTable) {
// We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
// vertexStride
@@ -46,13 +46,14 @@ GrAtlasTextContext::GrAtlasTextContext(GrContext* context, const SkSurfaceProps&
}
-GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context,
- const SkSurfaceProps& surfaceProps) {
- return new GrAtlasTextContext(context, surfaceProps);
+GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context) {
+ return new GrAtlasTextContext(context);
}
-bool GrAtlasTextContext::canDraw(const SkPaint& skPaint, const SkMatrix& viewMatrix) {
- return GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, fSurfaceProps,
+bool GrAtlasTextContext::canDraw(const SkPaint& skPaint,
+ const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props) {
+ return GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props,
*fContext->caps()->shaderCaps()) ||
!SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix);
}
@@ -93,7 +94,8 @@ bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) {
void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
- const SkMatrix& viewMatrix, const SkTextBlob* blob,
+ const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props, const SkTextBlob* blob,
SkScalar x, SkScalar y,
SkDrawFilter* drawFilter, const SkIRect& clipBounds) {
// If we have been abandoned, then don't draw
@@ -115,7 +117,7 @@ void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
bool hasLCD = HasLCD(blob);
// We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry
- SkPixelGeometry pixelGeometry = hasLCD ? fSurfaceProps.pixelGeometry() :
+ SkPixelGeometry pixelGeometry = hasLCD ? props.pixelGeometry() :
kUnknown_SkPixelGeometry;
// TODO we want to figure out a way to be able to use the canonical color on LCD text,
@@ -150,7 +152,7 @@ void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
// but we'd have to clear the subrun information
fCache->remove(cacheBlob);
cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, skPaint)));
- this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix,
+ this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix, props,
blob, x, y, drawFilter);
} else {
fCache->makeMRU(cacheBlob);
@@ -161,7 +163,7 @@ void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
SkAutoTUnref<GrAtlasTextBlob> sanityBlob(fCache->createBlob(glyphCount, runCount));
sanityBlob->setupKey(key, blurRec, skPaint);
- this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor(), viewMatrix,
+ this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor(), viewMatrix, props,
blob, x, y, drawFilter);
GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
}
@@ -172,17 +174,18 @@ void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
} else {
cacheBlob.reset(fCache->createBlob(blob));
}
- this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix,
+ this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix, props,
blob, x, y, drawFilter);
}
- cacheBlob->flushCached(fContext, dc, blob, fSurfaceProps, fDistanceAdjustTable, skPaint,
+ cacheBlob->flushCached(fContext, dc, blob, props, fDistanceAdjustTable, skPaint,
grPaint, drawFilter, clip, viewMatrix, clipBounds, x, y, transX, transY);
}
void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
const SkPaint& skPaint, GrColor color,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const SkTextBlob* blob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter) {
cacheBlob->initReusableBlob(color, viewMatrix, x, y);
@@ -204,16 +207,16 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
continue;
}
- runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint));
+ runPaint.setFlags(FilterTextFlags(props, runPaint));
cacheBlob->push_back_run(run);
- if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, fSurfaceProps,
+ if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props,
*fContext->caps()->shaderCaps())) {
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning: {
GrTextUtils::DrawDFText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ props, runPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
break;
@@ -221,7 +224,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
case SkTextBlob::kHorizontal_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
GrTextUtils::DrawDFPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
1, dfOffset);
break;
@@ -229,7 +232,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
case SkTextBlob::kFull_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y);
GrTextUtils::DrawDFPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
2, dfOffset);
break;
@@ -241,19 +244,19 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
GrTextUtils::DrawBmpText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ props, runPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
break;
case SkTextBlob::kHorizontal_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 1,
SkPoint::Make(x, y + offset.y()));
break;
case SkTextBlob::kFull_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 2,
SkPoint::Make(x, y));
break;
@@ -268,8 +271,10 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::createDrawTextBlob(const GrPaint& paint, const SkPaint& skPaint,
+GrAtlasTextContext::createDrawTextBlob(const GrPaint& paint,
+ const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
int glyphCount = skPaint.countText(text, byteLength);
@@ -277,13 +282,13 @@ GrAtlasTextContext::createDrawTextBlob(const GrPaint& paint, const SkPaint& skPa
GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1);
blob->initThrowawayBlob(viewMatrix, x, y);
- if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, fSurfaceProps,
+ if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props,
*fContext->caps()->shaderCaps())) {
- GrTextUtils::DrawDFText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps,
+ GrTextUtils::DrawDFText(blob, 0, fContext->getBatchFontCache(), props,
skPaint, paint.getColor(), viewMatrix, text,
byteLength, x, y);
} else {
- GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps, skPaint,
+ GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), props, skPaint,
paint.getColor(), viewMatrix, text, byteLength, x, y);
}
return blob;
@@ -291,7 +296,7 @@ GrAtlasTextContext::createDrawTextBlob(const GrPaint& paint, const SkPaint& skPa
inline GrAtlasTextBlob*
GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& skPaint,
- const SkMatrix& viewMatrix,
+ const SkMatrix& viewMatrix, const SkSurfaceProps& props,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) {
@@ -300,13 +305,13 @@ GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& s
GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1);
blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y());
- if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, fSurfaceProps,
+ if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props,
*fContext->caps()->shaderCaps())) {
- GrTextUtils::DrawDFPosText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps,
+ GrTextUtils::DrawDFPosText(blob, 0, fContext->getBatchFontCache(), props,
skPaint, paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
} else {
- GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps, skPaint,
+ GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), props, skPaint,
paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
}
@@ -317,14 +322,15 @@ void GrAtlasTextContext::drawText(GrDrawContext* dc,
const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& regionClipBounds) {
if (fContext->abandoned()) {
return;
- } else if (this->canDraw(skPaint, viewMatrix)) {
+ } else if (this->canDraw(skPaint, viewMatrix, props)) {
SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawTextBlob(paint, skPaint, viewMatrix, text, byteLength, x, y));
- blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPaint, paint,
+ this->createDrawTextBlob(paint, skPaint, viewMatrix, props, text, byteLength, x, y));
+ blob->flushThrowaway(fContext, dc, props, fDistanceAdjustTable, skPaint, paint,
clip, regionClipBounds);
return;
}
@@ -338,24 +344,25 @@ void GrAtlasTextContext::drawPosText(GrDrawContext* dc,
const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& regionClipBounds) {
if (fContext->abandoned()) {
return;
- } else if (this->canDraw(skPaint, viewMatrix)) {
+ } else if (this->canDraw(skPaint, viewMatrix, props)) {
SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawPosTextBlob(paint, skPaint, viewMatrix,
+ this->createDrawPosTextBlob(paint, skPaint, viewMatrix, props,
text, byteLength,
pos, scalarsPerPosition,
offset));
- blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPaint, paint,
+ blob->flushThrowaway(fContext, dc, props, fDistanceAdjustTable, skPaint, paint,
clip, regionClipBounds);
return;
}
// fall back to drawing as a path
- GrTextUtils::DrawPosTextAsPath(fContext, dc, fSurfaceProps, clip, skPaint, viewMatrix, text,
+ GrTextUtils::DrawPosTextAsPath(fContext, dc, props, clip, skPaint, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, regionClipBounds);
}
@@ -375,7 +382,7 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
// We don't yet test the fall back to paths in the GrTextContext base class. This is mostly
// because we don't really want to have a gpu device here.
// We enable distance fields by twiddling a knob on the paint
- gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps);
+ gTextContext = GrAtlasTextContext::Create(context);
}
// Setup dummy SkPaint / GrPaint
@@ -401,7 +408,7 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
// right now we don't handle textblobs, nor do we handle drawPosText. Since we only
// intend to test the batch with this unit test, that is okay.
SkAutoTUnref<GrAtlasTextBlob> blob(
- gTextContext->createDrawTextBlob(grPaint, skPaint, viewMatrix, text,
+ gTextContext->createDrawTextBlob(grPaint, skPaint, viewMatrix, gSurfaceProps, text,
static_cast<size_t>(textLen), 0, 0));
// We'd like to be able to test this with random translations, but currently the vertex
diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h
index 2168b7e49d..f2536b34db 100644
--- a/src/gpu/text/GrAtlasTextContext.h
+++ b/src/gpu/text/GrAtlasTextContext.h
@@ -31,28 +31,31 @@ class SkGlyph;
*/
class GrAtlasTextContext : public GrTextContext {
public:
- static GrAtlasTextContext* Create(GrContext*, const SkSurfaceProps&);
+ static GrAtlasTextContext* Create(GrContext*);
- bool canDraw(const SkPaint&, const SkMatrix& viewMatrix);
+ bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProps&);
void drawText(GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint&,
- const SkMatrix& viewMatrix, const char text[], size_t byteLength,
- SkScalar x, SkScalar y, const SkIRect& regionClipBounds) override;
+ const SkMatrix& viewMatrix, const SkSurfaceProps&, const char text[],
+ size_t byteLength, SkScalar x, SkScalar y,
+ const SkIRect& regionClipBounds) override;
void drawPosText(GrDrawContext*, const GrClip&, const GrPaint&,
- const SkPaint&, const SkMatrix& viewMatrix,
+ const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProps&,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& regionClipBounds) override;
void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&,
- const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x, SkScalar y,
+ const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
+ SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds) override;
private:
- GrAtlasTextContext(GrContext*, const SkSurfaceProps&);
+ GrAtlasTextContext(GrContext*);
// sets up the descriptor on the blob and returns a detached cache. Client must attach
inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd);
void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColor,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
const SkTextBlob* blob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter);
inline static bool HasLCD(const SkTextBlob*);
@@ -60,10 +63,12 @@ private:
// Test methods
inline GrAtlasTextBlob* createDrawTextBlob(const GrPaint&,
const SkPaint&, const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
const char text[], size_t byteLength,
SkScalar x, SkScalar y);
inline GrAtlasTextBlob* createDrawPosTextBlob(const GrPaint&,
const SkPaint&, const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset);
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 2fbaec8f32..50ec4f23fa 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -37,18 +37,17 @@ template<typename T> static void delete_hash_table_entry(T* val) {
delete *val;
}
-GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context,
- const SkSurfaceProps& surfaceProps)
- : INHERITED(context, surfaceProps)
+GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context)
+ : INHERITED(context)
, fFallbackTextContext(nullptr)
, fCacheSize(0) {
}
GrStencilAndCoverTextContext*
-GrStencilAndCoverTextContext::Create(GrContext* context, const SkSurfaceProps& surfaceProps) {
+GrStencilAndCoverTextContext::Create(GrContext* context) {
GrStencilAndCoverTextContext* textContext =
- new GrStencilAndCoverTextContext(context, surfaceProps);
- textContext->fFallbackTextContext = GrAtlasTextContext::Create(context, surfaceProps);
+ new GrStencilAndCoverTextContext(context);
+ textContext->fFallbackTextContext = GrAtlasTextContext::Create(context);
return textContext;
}
@@ -78,6 +77,7 @@ bool GrStencilAndCoverTextContext::internalCanDraw(const SkPaint& skPaint) {
void GrStencilAndCoverTextContext::drawText(GrDrawContext* dc,
const GrClip& clip, const GrPaint& paint,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) {
if (fContext->abandoned()) {
@@ -86,11 +86,11 @@ void GrStencilAndCoverTextContext::drawText(GrDrawContext* dc,
TextRun run(skPaint);
GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
run.setText(text, byteLength, x, y);
- run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, 0, 0, clipBounds,
- fFallbackTextContext, skPaint);
+ run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0,
+ clipBounds, fFallbackTextContext, skPaint);
return;
- } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix)) {
- fFallbackTextContext->drawText(dc, clip, paint, skPaint, viewMatrix, text,
+ } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props)) {
+ fFallbackTextContext->drawText(dc, clip, paint, skPaint, viewMatrix, props, text,
byteLength, x, y, clipBounds);
return;
}
@@ -105,6 +105,7 @@ void GrStencilAndCoverTextContext::drawPosText(GrDrawContext* dc,
const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const char text[],
size_t byteLength,
const SkScalar pos[],
@@ -117,24 +118,25 @@ void GrStencilAndCoverTextContext::drawPosText(GrDrawContext* dc,
TextRun run(skPaint);
GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
run.setPosText(text, byteLength, pos, scalarsPerPosition, offset);
- run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, 0, 0, clipBounds,
- fFallbackTextContext, skPaint);
+ run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0,
+ clipBounds, fFallbackTextContext, skPaint);
return;
- } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix)) {
- fFallbackTextContext->drawPosText(dc, clip, paint, skPaint, viewMatrix,
+ } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props)) {
+ fFallbackTextContext->drawPosText(dc, clip, paint, skPaint, viewMatrix, props,
text, byteLength, pos,
scalarsPerPosition, offset, clipBounds);
return;
}
// fall back to drawing as a path
- GrTextUtils::DrawPosTextAsPath(fContext, dc, fSurfaceProps, clip, skPaint, viewMatrix, text,
+ GrTextUtils::DrawPosTextAsPath(fContext, dc, props, clip, skPaint, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, clipBounds);
}
void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const SkTextBlob* blob,
SkScalar x, SkScalar y,
SkDrawFilter* drawFilter,
@@ -156,7 +158,7 @@ void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrDrawContext* dc,
continue;
}
- runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint));
+ runPaint.setFlags(FilterTextFlags(props, runPaint));
GrPaint grPaint;
if (!SkPaintToGrPaint(fContext, runPaint, viewMatrix, &grPaint)) {
@@ -165,16 +167,19 @@ void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrDrawContext* dc,
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
- this->drawText(dc, clip, grPaint, runPaint, viewMatrix, (const char *)it.glyphs(),
+ this->drawText(dc, clip, grPaint, runPaint, viewMatrix, props,
+ (const char *)it.glyphs(),
textLen, x + offset.x(), y + offset.y(), clipBounds);
break;
case SkTextBlob::kHorizontal_Positioning:
- this->drawPosText(dc, clip, grPaint, runPaint, viewMatrix, (const char*)it.glyphs(),
+ this->drawPosText(dc, clip, grPaint, runPaint, viewMatrix, props,
+ (const char*)it.glyphs(),
textLen, it.pos(), 1, SkPoint::Make(x, y + offset.y()),
clipBounds);
break;
case SkTextBlob::kFull_Positioning:
- this->drawPosText(dc, clip, grPaint, runPaint, viewMatrix, (const char*)it.glyphs(),
+ this->drawPosText(dc, clip, grPaint, runPaint, viewMatrix, props,
+ (const char*)it.glyphs(),
textLen, it.pos(), 2, SkPoint::Make(x, y), clipBounds);
break;
}
@@ -189,6 +194,7 @@ void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrDrawContext* dc,
void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const SkTextBlob* skBlob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter,
const SkIRect& clipBounds) {
@@ -197,14 +203,14 @@ void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc,
}
if (!this->internalCanDraw(skPaint)) {
- fFallbackTextContext->drawTextBlob(dc, clip, skPaint, viewMatrix, skBlob, x, y,
+ fFallbackTextContext->drawTextBlob(dc, clip, skPaint, viewMatrix, props, skBlob, x, y,
drawFilter, clipBounds);
return;
}
if (drawFilter || skPaint.getPathEffect()) {
// This draw can't be cached.
- this->uncachedDrawTextBlob(dc, clip, skPaint, viewMatrix, skBlob, x, y, drawFilter,
+ this->uncachedDrawTextBlob(dc, clip, skPaint, viewMatrix, props, skBlob, x, y, drawFilter,
clipBounds);
return;
}
@@ -219,8 +225,8 @@ void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc,
TextBlob::Iter iter(blob);
for (TextRun* run = iter.get(); run; run = iter.next()) {
- run->draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, x, y, clipBounds,
- fFallbackTextContext, skPaint);
+ run->draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, x, y,
+ clipBounds, fFallbackTextContext, skPaint);
run->releaseGlyphCache();
}
}
@@ -562,6 +568,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
SkScalar x, SkScalar y,
const SkIRect& clipBounds,
GrTextContext* fallbackTextContext,
@@ -614,7 +621,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
}
fallbackTextContext->drawTextBlob(dc, pipelineBuilder->clip(), fallbackSkPaint, viewMatrix,
- fFallbackTextBlob, x, y, nullptr, clipBounds);
+ props, fFallbackTextBlob, x, y, nullptr, clipBounds);
}
}
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.h b/src/gpu/text/GrStencilAndCoverTextContext.h
index bc00a74406..053fbd3d69 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.h
+++ b/src/gpu/text/GrStencilAndCoverTextContext.h
@@ -28,26 +28,28 @@ class SkSurfaceProps;
*/
class GrStencilAndCoverTextContext : public GrTextContext {
public:
- static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps&);
+ static GrStencilAndCoverTextContext* Create(GrContext*);
void drawText(GrDrawContext* dc,
const GrClip&, const GrPaint&, const SkPaint&,
- const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x,
+ const SkMatrix& viewMatrix, const SkSurfaceProps&, const char text[],
+ size_t byteLength, SkScalar x,
SkScalar y, const SkIRect& clipBounds) override;
void drawPosText(GrDrawContext*,
const GrClip&, const GrPaint&, const SkPaint&,
- const SkMatrix& viewMatrix,
+ const SkMatrix& viewMatrix, const SkSurfaceProps&,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) override;
void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&,
- const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x, SkScalar y,
+ const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
+ SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds) override;
virtual ~GrStencilAndCoverTextContext();
private:
- GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&);
+ GrStencilAndCoverTextContext(GrContext*);
bool canDraw(const SkPaint& skPaint, const SkMatrix&) {
return this->internalCanDraw(skPaint);
@@ -58,6 +60,7 @@ private:
void uncachedDrawTextBlob(GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
const SkTextBlob* blob,
SkScalar x, SkScalar y,
SkDrawFilter* drawFilter,
@@ -76,6 +79,7 @@ private:
int scalarsPerPosition, const SkPoint& offset);
void draw(GrContext*, GrDrawContext*, GrPipelineBuilder*, GrColor, const SkMatrix&,
+ const SkSurfaceProps&,
SkScalar x, SkScalar y, const SkIRect& clipBounds,
GrTextContext* fallbackTextContext, const SkPaint& originalSkPaint) const;
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 7f5ad55b09..7885c5a578 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -10,9 +10,8 @@
#include "SkGlyphCache.h"
-GrTextContext::GrTextContext(GrContext* context, const SkSurfaceProps& surfaceProps)
- : fContext(context)
- , fSurfaceProps(surfaceProps) {
+GrTextContext::GrTextContext(GrContext* context)
+ : fContext(context) {
}
bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) {
diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h
index 3de2ae2416..90ae4f35e8 100644
--- a/src/gpu/text/GrTextContext.h
+++ b/src/gpu/text/GrTextContext.h
@@ -30,16 +30,19 @@ public:
virtual void drawText(GrDrawContext* dc,
const GrClip&, const GrPaint&, const SkPaint&,
- const SkMatrix& viewMatrix, const char text[], size_t byteLength,
+ const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props, const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) = 0;
virtual void drawPosText(GrDrawContext* dc,
const GrClip&, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) = 0;
- virtual void drawTextBlob(GrDrawContext* dc, const GrClip&, const SkPaint&,
- const SkMatrix& viewMatrix, const SkTextBlob*,
+ virtual void drawTextBlob(GrDrawContext* dc, const GrClip&,
+ const SkPaint&, const SkMatrix& viewMatrix,
+ const SkSurfaceProps& props, const SkTextBlob*,
SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds) = 0;
@@ -47,9 +50,8 @@ public:
protected:
GrContext* fContext;
- SkSurfaceProps fSurfaceProps;
- GrTextContext(GrContext*, const SkSurfaceProps&);
+ GrTextContext(GrContext*);
static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint);