fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
+ fTextContext->drawText(fContext, this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
text, byteLength, x, y, clipBounds);
}
fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps, text,
- byteLength, pos, scalarsPerPosition, offset, clipBounds);
+ fTextContext->drawPosText(fContext, this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
+ text, byteLength, pos, scalarsPerPosition, offset, clipBounds);
}
fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, fSurfaceProps, blob, x, y, filter,
- clipBounds);
+ fTextContext->drawTextBlob(fContext, this, clip, skPaint, viewMatrix, fSurfaceProps, blob, x,
+ y, filter, clipBounds);
}
void GrDrawContext::discard() {
GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAttachment(rt);
if (sb) {
if (!fNVPRTextContext) {
- fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext);
+ fNVPRTextContext = GrStencilAndCoverTextContext::Create();
}
return fNVPRTextContext;
}
if (!fAtlasTextContext) {
- fAtlasTextContext = GrAtlasTextContext::Create(fContext);
+ fAtlasTextContext = GrAtlasTextContext::Create();
}
return fAtlasTextContext;
#include "GrDrawContext.h"
#include "GrDrawTarget.h"
-#include "GrFontScaler.h"
-#include "GrStrokeInfo.h"
#include "GrTextBlobCache.h"
-#include "GrTexturePriv.h"
#include "GrTextUtils.h"
-#include "GrVertexBuffer.h"
-#include "SkAutoKern.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
-#include "SkDistanceFieldGen.h"
#include "SkDraw.h"
#include "SkDrawFilter.h"
-#include "SkDrawProcs.h"
-#include "SkFindAndPlaceGlyph.h"
-#include "SkGlyphCache.h"
-#include "SkGpuDevice.h"
#include "SkGrPriv.h"
-#include "SkPath.h"
-#include "SkRTConf.h"
-#include "SkStrokeRec.h"
-#include "SkTextBlob.h"
-#include "SkTextMapStateProc.h"
-
-#include "batches/GrAtlasTextBatch.h"
-
-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
- static_assert(GrAtlasTextBlob::kGrayTextVASize >= GrAtlasTextBlob::kColorTextVASize &&
- GrAtlasTextBlob::kGrayTextVASize >= GrAtlasTextBlob::kLCDTextVASize,
- "vertex_attribute_changed");
- fCache = context->getTextBlobCache();
+
+GrAtlasTextContext::GrAtlasTextContext()
+ : fDistanceAdjustTable(new GrDistanceFieldAdjustTable) {
}
-GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context) {
- return new GrAtlasTextContext(context);
+GrAtlasTextContext* GrAtlasTextContext::Create() {
+ return new GrAtlasTextContext();
}
bool GrAtlasTextContext::canDraw(const SkPaint& skPaint,
const SkMatrix& viewMatrix,
- const SkSurfaceProps& props) {
- return GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props,
- *fContext->caps()->shaderCaps()) ||
+ const SkSurfaceProps& props,
+ const GrShaderCaps& shaderCaps) {
+ return GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderCaps) ||
!SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix);
}
return false;
}
-void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
+void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
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
- if (fContext->abandoned()) {
+ if (context->abandoned()) {
return;
}
(mf && !mf->asABlur(&blurRec)) ||
drawFilter);
+ GrTextBlobCache* cache = context->getTextBlobCache();
if (canCache) {
bool hasLCD = HasLCD(blob);
key.fStyle = skPaint.getStyle();
key.fHasBlur = SkToBool(mf);
key.fCanonicalColor = canonicalColor;
- cacheBlob.reset(SkSafeRef(fCache->find(key)));
+ cacheBlob.reset(SkSafeRef(cache->find(key)));
}
SkScalar transX = 0.f;
// Though for the time being runs in the textblob can override the paint, they only touch font
// info.
GrPaint grPaint;
- if (!SkPaintToGrPaint(fContext, skPaint, viewMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &grPaint)) {
return;
}
// 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
- fCache->remove(cacheBlob);
- cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, skPaint)));
- this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix, props,
- blob, x, y, drawFilter);
+ cache->remove(cacheBlob);
+ cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, skPaint)));
+ RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
+ *context->caps()->shaderCaps(), skPaint, grPaint.getColor(),
+ viewMatrix, props,
+ blob, x, y, drawFilter);
} else {
- fCache->makeMRU(cacheBlob);
+ cache->makeMRU(cacheBlob);
if (CACHE_SANITY_CHECK) {
int glyphCount = 0;
int runCount = 0;
GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
- SkAutoTUnref<GrAtlasTextBlob> sanityBlob(fCache->createBlob(glyphCount, runCount));
+ SkAutoTUnref<GrAtlasTextBlob> sanityBlob(cache->createBlob(glyphCount, runCount));
sanityBlob->setupKey(key, blurRec, skPaint);
- this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor(), viewMatrix, props,
- blob, x, y, drawFilter);
+ RegenerateTextBlob(sanityBlob, context->getBatchFontCache(),
+ *context->caps()->shaderCaps(), skPaint,
+ grPaint.getColor(), viewMatrix, props,
+ blob, x, y, drawFilter);
GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
}
}
} else {
if (canCache) {
- cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, skPaint)));
+ cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, skPaint)));
} else {
- cacheBlob.reset(fCache->createBlob(blob));
+ cacheBlob.reset(cache->createBlob(blob));
}
- this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix, props,
- blob, x, y, drawFilter);
+ RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
+ *context->caps()->shaderCaps(), skPaint, grPaint.getColor(),
+ viewMatrix, props,
+ blob, x, y, drawFilter);
}
- cacheBlob->flushCached(fContext, dc, blob, props, fDistanceAdjustTable, skPaint,
+ cacheBlob->flushCached(context, dc, blob, props, fDistanceAdjustTable, skPaint,
grPaint, drawFilter, clip, viewMatrix, clipBounds, x, y, transX, transY);
}
-void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
+void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
+ GrBatchFontCache* fontCache,
+ const GrShaderCaps& shaderCaps,
const SkPaint& skPaint, GrColor color,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
cacheBlob->push_back_run(run);
- if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props,
- *fContext->caps()->shaderCaps())) {
+ if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, shaderCaps)) {
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning: {
- GrTextUtils::DrawDFText(cacheBlob, run, fContext->getBatchFontCache(),
+ GrTextUtils::DrawDFText(cacheBlob, run, fontCache,
props, runPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
}
case SkTextBlob::kHorizontal_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
- GrTextUtils::DrawDFPosText(cacheBlob, run, fContext->getBatchFontCache(),
+ GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
1, dfOffset);
}
case SkTextBlob::kFull_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y);
- GrTextUtils::DrawDFPosText(cacheBlob, run, fContext->getBatchFontCache(),
+ GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
2, dfOffset);
} else {
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
- GrTextUtils::DrawBmpText(cacheBlob, run, fContext->getBatchFontCache(),
+ GrTextUtils::DrawBmpText(cacheBlob, run, fontCache,
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(),
+ GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
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(),
+ GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
props, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 2,
SkPoint::Make(x, y));
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::createDrawTextBlob(const GrPaint& paint,
+GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
+ GrBatchFontCache* fontCache,
+ const GrShaderCaps& shaderCaps,
+ const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
SkScalar x, SkScalar y) {
int glyphCount = skPaint.countText(text, byteLength);
- GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1);
+ GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1);
blob->initThrowawayBlob(viewMatrix, x, y);
- if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props,
- *fContext->caps()->shaderCaps())) {
- GrTextUtils::DrawDFText(blob, 0, fContext->getBatchFontCache(), props,
+ if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderCaps)) {
+ GrTextUtils::DrawDFText(blob, 0, fontCache, props,
skPaint, paint.getColor(), viewMatrix, text,
byteLength, x, y);
} else {
- GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), props, skPaint,
+ GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint,
paint.getColor(), viewMatrix, text, byteLength, x, y);
}
return blob;
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& skPaint,
+GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFontCache* fontCache,
+ const GrShaderCaps& shaderCaps, 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) {
int glyphCount = skPaint.countText(text, byteLength);
- GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1);
+ GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1);
blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y());
- if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props,
- *fContext->caps()->shaderCaps())) {
- GrTextUtils::DrawDFPosText(blob, 0, fContext->getBatchFontCache(), props,
+ if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderCaps)) {
+ GrTextUtils::DrawDFPosText(blob, 0, fontCache, props,
skPaint, paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
} else {
- GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), props, skPaint,
+ GrTextUtils::DrawBmpPosText(blob, 0, fontCache, props, skPaint,
paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
}
return blob;
}
-void GrAtlasTextContext::drawText(GrDrawContext* dc,
+void GrAtlasTextContext::drawText(GrContext* context,
+ 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()) {
+ if (context->abandoned()) {
return;
- } else if (this->canDraw(skPaint, viewMatrix, props)) {
+ } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shaderCaps())) {
SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawTextBlob(paint, skPaint, viewMatrix, props, text, byteLength, x, y));
- blob->flushThrowaway(fContext, dc, props, fDistanceAdjustTable, skPaint, paint,
+ CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFontCache(),
+ *context->caps()->shaderCaps(),
+ paint, skPaint,
+ viewMatrix, props,
+ text, byteLength, x, y));
+ blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
clip, regionClipBounds);
return;
}
// fall back to drawing as a path
- GrTextUtils::DrawTextAsPath(fContext, dc, clip, skPaint, viewMatrix, text, byteLength, x, y,
+ GrTextUtils::DrawTextAsPath(context, dc, clip, skPaint, viewMatrix, text, byteLength, x, y,
regionClipBounds);
}
-void GrAtlasTextContext::drawPosText(GrDrawContext* dc,
+void GrAtlasTextContext::drawPosText(GrContext* context,
+ GrDrawContext* dc,
const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& regionClipBounds) {
- if (fContext->abandoned()) {
+ if (context->abandoned()) {
return;
- } else if (this->canDraw(skPaint, viewMatrix, props)) {
+ } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shaderCaps())) {
SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawPosTextBlob(paint, skPaint, viewMatrix, props,
- text, byteLength,
- pos, scalarsPerPosition,
- offset));
- blob->flushThrowaway(fContext, dc, props, fDistanceAdjustTable, skPaint, paint,
+ CreateDrawPosTextBlob(context->getTextBlobCache(),
+ context->getBatchFontCache(),
+ *context->caps()->shaderCaps(),
+ paint, skPaint, viewMatrix, props,
+ text, byteLength,
+ pos, scalarsPerPosition,
+ offset));
+ blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
clip, regionClipBounds);
return;
}
// fall back to drawing as a path
- GrTextUtils::DrawPosTextAsPath(fContext, dc, props, clip, skPaint, viewMatrix, text,
+ GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, skPaint, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, regionClipBounds);
}
// 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);
+ gTextContext = GrAtlasTextContext::Create();
}
// Setup dummy SkPaint / GrPaint
// 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, gSurfaceProps, text,
- static_cast<size_t>(textLen), 0, 0));
+ GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(),
+ context->getBatchFontCache(),
+ *context->caps()->shaderCaps(), 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
// bounds and vertices will get out of sync
*/
class GrAtlasTextContext : public GrTextContext {
public:
- static GrAtlasTextContext* Create(GrContext*);
+ static GrAtlasTextContext* Create();
- bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProps&);
- void drawText(GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint&,
+ bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProps&,
+ const GrShaderCaps&);
+ void drawText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint&,
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&,
+ void drawPosText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&,
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&,
+ void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&,
const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds) override;
private:
- GrAtlasTextContext(GrContext*);
+ GrAtlasTextContext();
// 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);
+ static void RegenerateTextBlob(GrAtlasTextBlob* bmp,
+ GrBatchFontCache*,
+ const GrShaderCaps&,
+ const SkPaint& skPaint, GrColor,
+ const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
+ const SkTextBlob* blob, SkScalar x, SkScalar y,
+ SkDrawFilter* drawFilter);
inline static bool HasLCD(const SkTextBlob*);
- // 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);
+ static inline GrAtlasTextBlob* CreateDrawTextBlob(GrTextBlobCache*,
+ GrBatchFontCache*, const GrShaderCaps&,
+ const GrPaint&,
+ const SkPaint&, const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
+ const char text[], size_t byteLength,
+ SkScalar x, SkScalar y);
+ static inline GrAtlasTextBlob* CreateDrawPosTextBlob(GrTextBlobCache*, GrBatchFontCache*,
+ const GrShaderCaps&,
+ const GrPaint&,
+ const SkPaint&, const SkMatrix& viewMatrix,
+ const SkSurfaceProps&,
+ const char text[], size_t byteLength,
+ const SkScalar pos[],
+ int scalarsPerPosition,
+ const SkPoint& offset);
const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAdjustTable; }
- GrTextBlobCache* fCache;
SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable;
#ifdef GR_TEST_UTILS
delete *val;
}
-GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context)
- : INHERITED(context)
- , fFallbackTextContext(nullptr)
+GrStencilAndCoverTextContext::GrStencilAndCoverTextContext()
+ : fFallbackTextContext(nullptr)
, fCacheSize(0) {
}
GrStencilAndCoverTextContext*
-GrStencilAndCoverTextContext::Create(GrContext* context) {
- GrStencilAndCoverTextContext* textContext =
- new GrStencilAndCoverTextContext(context);
- textContext->fFallbackTextContext = GrAtlasTextContext::Create(context);
+GrStencilAndCoverTextContext::Create() {
+ GrStencilAndCoverTextContext* textContext = new GrStencilAndCoverTextContext();
+ textContext->fFallbackTextContext = GrAtlasTextContext::Create();
return textContext;
}
return SkPaint::kStroke_Style != skPaint.getStyle() || 0 != skPaint.getStrokeWidth();
}
-void GrStencilAndCoverTextContext::drawText(GrDrawContext* dc,
+void GrStencilAndCoverTextContext::drawText(GrContext* context, 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()) {
+ if (context->abandoned()) {
return;
} else if (this->canDraw(skPaint, viewMatrix)) {
TextRun run(skPaint);
GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
run.setText(text, byteLength, x, y);
- run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0,
+ run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0,
clipBounds, fFallbackTextContext, skPaint);
return;
- } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props)) {
- fFallbackTextContext->drawText(dc, clip, paint, skPaint, viewMatrix, props, text,
+ } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props,
+ *context->caps()->shaderCaps())) {
+ fFallbackTextContext->drawText(context, dc, clip, paint, skPaint, viewMatrix, props, text,
byteLength, x, y, clipBounds);
return;
}
// fall back to drawing as a path
- GrTextUtils::DrawTextAsPath(fContext, dc, clip, skPaint, viewMatrix, text, byteLength, x, y,
+ GrTextUtils::DrawTextAsPath(context, dc, clip, skPaint, viewMatrix, text, byteLength, x, y,
clipBounds);
}
-void GrStencilAndCoverTextContext::drawPosText(GrDrawContext* dc,
+void GrStencilAndCoverTextContext::drawPosText(GrContext* context, GrDrawContext* dc,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
int scalarsPerPosition,
const SkPoint& offset,
const SkIRect& clipBounds) {
- if (fContext->abandoned()) {
+ if (context->abandoned()) {
return;
} else if (this->canDraw(skPaint, viewMatrix)) {
TextRun run(skPaint);
GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
run.setPosText(text, byteLength, pos, scalarsPerPosition, offset);
- run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0,
+ run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0,
clipBounds, fFallbackTextContext, skPaint);
return;
- } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props)) {
- fFallbackTextContext->drawPosText(dc, clip, paint, skPaint, viewMatrix, props,
+ } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props,
+ *context->caps()->shaderCaps())) {
+ fFallbackTextContext->drawPosText(context, dc, clip, paint, skPaint, viewMatrix, props,
text, byteLength, pos,
scalarsPerPosition, offset, clipBounds);
return;
}
// fall back to drawing as a path
- GrTextUtils::DrawPosTextAsPath(fContext, dc, props, clip, skPaint, viewMatrix, text,
+ GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, skPaint, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, clipBounds);
}
-void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrDrawContext* dc,
+void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrContext* context,
+ GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
runPaint.setFlags(FilterTextFlags(props, runPaint));
GrPaint grPaint;
- if (!SkPaintToGrPaint(fContext, runPaint, viewMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(context, runPaint, viewMatrix, &grPaint)) {
return;
}
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
- this->drawText(dc, clip, grPaint, runPaint, viewMatrix, props,
+ this->drawText(context, 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, props,
+ this->drawPosText(context, 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, props,
+ this->drawPosText(context, dc, clip, grPaint, runPaint, viewMatrix, props,
(const char*)it.glyphs(),
textLen, it.pos(), 2, SkPoint::Make(x, y), clipBounds);
break;
}
}
-void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc,
+void GrStencilAndCoverTextContext::drawTextBlob(GrContext* context, 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) {
- if (fContext->abandoned()) {
+ if (context->abandoned()) {
return;
}
if (!this->internalCanDraw(skPaint)) {
- fFallbackTextContext->drawTextBlob(dc, clip, skPaint, viewMatrix, props, skBlob, x, y,
- drawFilter, clipBounds);
+ fFallbackTextContext->drawTextBlob(context, 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, props, skBlob, x, y, drawFilter,
- clipBounds);
+ this->uncachedDrawTextBlob(context, dc, clip, skPaint, viewMatrix, props, skBlob, x, y,
+ drawFilter, clipBounds);
return;
}
GrPaint paint;
- if (!SkPaintToGrPaint(fContext, skPaint, viewMatrix, &paint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &paint)) {
return;
}
TextBlob::Iter iter(blob);
for (TextRun* run = iter.get(); run; run = iter.next()) {
- run->draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, x, y,
+ run->draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, x, y,
clipBounds, fFallbackTextContext, skPaint);
run->releaseGlyphCache();
}
fallbackSkPaint.setStrokeWidth(fStroke.getWidth() * fTextRatio);
}
- fallbackTextContext->drawTextBlob(dc, pipelineBuilder->clip(), fallbackSkPaint, viewMatrix,
- props, fFallbackTextBlob, x, y, nullptr, clipBounds);
+ fallbackTextContext->drawTextBlob(ctx, dc, pipelineBuilder->clip(), fallbackSkPaint,
+ viewMatrix, props, fFallbackTextBlob, x, y, nullptr,
+ clipBounds);
}
}
*/
class GrStencilAndCoverTextContext : public GrTextContext {
public:
- static GrStencilAndCoverTextContext* Create(GrContext*);
+ static GrStencilAndCoverTextContext* Create();
- void drawText(GrDrawContext* dc,
+ void drawText(GrContext*, GrDrawContext* dc,
const GrClip&, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix, const SkSurfaceProps&, const char text[],
size_t byteLength, SkScalar x,
SkScalar y, const SkIRect& clipBounds) override;
- void drawPosText(GrDrawContext*,
+ void drawPosText(GrContext*, GrDrawContext*,
const GrClip&, const GrPaint&, const SkPaint&,
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&,
+ void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&,
const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds) override;
virtual ~GrStencilAndCoverTextContext();
private:
- GrStencilAndCoverTextContext(GrContext*);
+ GrStencilAndCoverTextContext();
bool canDraw(const SkPaint& skPaint, const SkMatrix&) {
return this->internalCanDraw(skPaint);
bool internalCanDraw(const SkPaint&);
- void uncachedDrawTextBlob(GrDrawContext* dc,
+ void uncachedDrawTextBlob(GrContext*, GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const SkSurfaceProps&,
#include "SkGlyphCache.h"
-GrTextContext::GrTextContext(GrContext* context)
- : fContext(context) {
-}
-
bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) {
if (!SkXfermode::AsMode(paint.getXfermode(), nullptr) ||
paint.getMaskFilter() ||
public:
virtual ~GrTextContext() {}
- virtual void drawText(GrDrawContext* dc,
+ virtual void drawText(GrContext*, GrDrawContext* dc,
const GrClip&, const GrPaint&, const SkPaint&,
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,
+ virtual void drawPosText(GrContext*, 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&,
+ virtual void drawTextBlob(GrContext*, GrDrawContext* dc, const GrClip&,
const SkPaint&, const SkMatrix& viewMatrix,
const SkSurfaceProps& props, const SkTextBlob*,
SkScalar x, SkScalar y,
static bool ShouldDisableLCD(const SkPaint& paint);
protected:
- GrContext* fContext;
-
- GrTextContext(GrContext*);
-
static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint);