aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-02-16 11:09:25 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-16 11:09:25 -0800
commit8e84a1ed07ad5d529d381d43302e597f31723076 (patch)
tree7ec66370a27dc047a86fb5501ef0c81d8718ac82 /src
parent546d66544bcfac4bc9e77626ba549c4b3a79a654 (diff)
Delete GrTextContext
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawingManager.h7
-rw-r--r--src/gpu/SkGpuDevice.cpp4
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp2
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h1
-rw-r--r--src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp3
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp5
-rw-r--r--src/gpu/text/GrAtlasTextContext.h14
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp4
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.h16
-rw-r--r--src/gpu/text/GrTextContext.cpp59
-rw-r--r--src/gpu/text/GrTextContext.h60
-rw-r--r--src/gpu/text/GrTextUtils.cpp51
-rw-r--r--src/gpu/text/GrTextUtils.h6
13 files changed, 74 insertions, 158 deletions
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index d82a3a2d41..0a4c3e3c7d 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -18,13 +18,8 @@ class GrContext;
class GrDrawContext;
class GrSingleOWner;
class GrSoftwarePathRenderer;
-class GrTextContext;
-// Currently the DrawingManager creates a separate GrTextContext for each
-// combination of text drawing options (pixel geometry x DFT use)
-// and hands the appropriate one back given the DrawContext's request.
-//
-// It allocates a new GrDrawContext for each GrRenderTarget
+// The GrDrawingManager allocates a new GrDrawContext for each GrRenderTarget
// but all of them still land in the same GrDrawTarget!
//
// In the future this class will allocate a new GrDrawContext for
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 060b2a1e45..cb92ab3edf 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -46,7 +46,7 @@
#include "effects/GrDashingEffect.h"
#include "effects/GrSimpleTextureEffect.h"
#include "effects/GrTextureDomain.h"
-#include "text/GrTextContext.h"
+#include "text/GrTextUtils.h"
#if SK_SUPPORT_GPU
@@ -1755,7 +1755,7 @@ void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
///////////////////////////////////////////////////////////////////////////////
bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const {
- return GrTextContext::ShouldDisableLCD(paint);
+ return GrTextUtils::ShouldDisableLCD(paint);
}
void SkGpuDevice::flush() {
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 2775098ecc..f2ca3d2186 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -366,7 +366,7 @@ void GrAtlasTextBlob::flushRunAsPaths(GrContext* context, GrDrawContext* dc,
return;
}
- runPaint.setFlags(GrTextContext::FilterTextFlags(props, runPaint));
+ runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 63eb56b6f8..8b175c8e96 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -20,7 +20,6 @@
class GrBlobRegenHelper;
struct GrDistanceFieldAdjustTable;
class GrMemoryPool;
-class GrTextContext;
class SkDrawFilter;
class SkTextBlob;
class SkTextBlobRunIterator;
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
index 6443d41ac5..14bf4a5d61 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
@@ -8,6 +8,7 @@
#include "GrAtlasTextBlob.h"
#include "GrBatchFlushState.h"
+#include "GrTextUtils.h"
#include "SkDistanceFieldGen.h"
#include "SkGlyphCache.h"
@@ -146,7 +147,7 @@ void GrAtlasTextBlob::regenInBatch(GrDrawBatch::Target* target,
}
*desc = newDesc;
*cache = SkGlyphCache::DetachCache(run->fTypeface, *desc);
- *scaler = GrTextContext::GetGrFontScaler(*cache);
+ *scaler = GrTextUtils::GetGrFontScaler(*cache);
*typeface = run->fTypeface;
}
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 8f45731bc3..0f36fe355a 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -190,7 +190,7 @@ void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
continue;
}
- runPaint.setFlags(FilterTextFlags(props, runPaint));
+ runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
cacheBlob->push_back_run(run);
@@ -373,9 +373,6 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
gContextID = context->uniqueID();
delete gTextContext;
- // 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();
}
diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h
index c4948db8f6..edc157552a 100644
--- a/src/gpu/text/GrAtlasTextContext.h
+++ b/src/gpu/text/GrAtlasTextContext.h
@@ -8,8 +8,6 @@
#ifndef GrAtlasTextContext_DEFINED
#define GrAtlasTextContext_DEFINED
-#include "GrTextContext.h"
-
#include "GrAtlasTextBlob.h"
#include "GrDistanceFieldAdjustTable.h"
#include "GrGeometryProcessor.h"
@@ -27,9 +25,9 @@ class GrTextBlobCache;
class SkGlyph;
/*
- * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs.
+ * Renders text using some kind of an atlas, ie BitmapText or DistanceField text
*/
-class GrAtlasTextContext : public GrTextContext {
+class GrAtlasTextContext {
public:
static GrAtlasTextContext* Create();
@@ -38,16 +36,16 @@ public:
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;
+ const SkIRect& regionClipBounds);
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;
+ const SkPoint& offset, const SkIRect& regionClipBounds);
void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&,
const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
SkScalar x, SkScalar y,
- SkDrawFilter*, const SkIRect& clipBounds) override;
+ SkDrawFilter*, const SkIRect& clipBounds);
private:
GrAtlasTextContext();
@@ -87,8 +85,6 @@ private:
#ifdef GR_TEST_UTILS
DRAW_BATCH_TEST_FRIEND(TextBlobBatch);
#endif
-
- typedef GrTextContext INHERITED;
};
#endif
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 08487d9859..205c6d976a 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -159,7 +159,7 @@ void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrContext* context,
continue;
}
- runPaint.setFlags(FilterTextFlags(props, runPaint));
+ runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
GrPaint grPaint;
if (!SkPaintToGrPaint(context, runPaint, viewMatrix, &grPaint)) {
@@ -572,7 +572,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
const SkSurfaceProps& props,
SkScalar x, SkScalar y,
const SkIRect& clipBounds,
- GrTextContext* fallbackTextContext,
+ GrAtlasTextContext* fallbackTextContext,
const SkPaint& originalSkPaint) const {
SkASSERT(fInstanceData);
SkASSERT(dc->accessRenderTarget()->isStencilBufferMultisampled() || !fFont.isAntiAlias());
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.h b/src/gpu/text/GrStencilAndCoverTextContext.h
index 302df0b5fc..892e279f59 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.h
+++ b/src/gpu/text/GrStencilAndCoverTextContext.h
@@ -8,9 +8,10 @@
#ifndef GrStencilAndCoverTextContext_DEFINED
#define GrStencilAndCoverTextContext_DEFINED
-#include "GrTextContext.h"
#include "GrDrawTarget.h"
#include "GrStrokeInfo.h"
+#include "SkDrawFilter.h"
+#include "SkTextBlob.h"
#include "SkTHash.h"
#include "SkTInternalLList.h"
#include "SkTLList.h"
@@ -24,9 +25,8 @@ class SkSurfaceProps;
/*
* This class implements text rendering using stencil and cover path rendering
* (by the means of GrDrawTarget::drawPath).
- * This class exposes the functionality through GrTextContext interface.
*/
-class GrStencilAndCoverTextContext : public GrTextContext {
+class GrStencilAndCoverTextContext {
public:
static GrStencilAndCoverTextContext* Create();
@@ -34,17 +34,17 @@ public:
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;
+ SkScalar y, const SkIRect& clipBounds);
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;
+ const SkPoint& offset, const SkIRect& clipBounds);
void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&,
const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
SkScalar x, SkScalar y,
- SkDrawFilter*, const SkIRect& clipBounds) override;
+ SkDrawFilter*, const SkIRect& clipBounds);
virtual ~GrStencilAndCoverTextContext();
@@ -81,7 +81,7 @@ private:
void draw(GrContext*, GrDrawContext*, GrPipelineBuilder*, GrColor, const SkMatrix&,
const SkSurfaceProps&,
SkScalar x, SkScalar y, const SkIRect& clipBounds,
- GrTextContext* fallbackTextContext, const SkPaint& originalSkPaint) const;
+ GrAtlasTextContext* fallbackTextContext, const SkPaint& originalSkPaint) const;
void releaseGlyphCache() const;
@@ -152,8 +152,6 @@ private:
SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache;
SkTInternalLList<TextBlob> fLRUList;
size_t fCacheSize;
-
- typedef GrTextContext INHERITED;
};
#endif
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
deleted file mode 100644
index 1e2d290e90..0000000000
--- a/src/gpu/text/GrTextContext.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrTextContext.h"
-#include "GrFontScaler.h"
-
-#include "SkGlyphCache.h"
-
-bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) {
- if (!SkXfermode::AsMode(paint.getXfermode(), nullptr) ||
- paint.getMaskFilter() ||
- paint.getRasterizer() ||
- paint.getPathEffect() ||
- paint.isFakeBoldText() ||
- paint.getStyle() != SkPaint::kFill_Style)
- {
- return true;
- }
- return false;
-}
-
-uint32_t GrTextContext::FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint) {
- uint32_t flags = paint.getFlags();
-
- if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
- return flags;
- }
-
- if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisableLCD(paint)) {
- flags &= ~SkPaint::kLCDRenderText_Flag;
- flags |= SkPaint::kGenA8FromLCD_Flag;
- }
-
- return flags;
-}
-
-static void GlyphCacheAuxProc(void* data) {
- GrFontScaler* scaler = (GrFontScaler*)data;
- SkSafeUnref(scaler);
-}
-
-GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) {
- void* auxData;
- GrFontScaler* scaler = nullptr;
-
- if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) {
- scaler = (GrFontScaler*)auxData;
- }
- if (nullptr == scaler) {
- scaler = new GrFontScaler(cache);
- cache->setAuxProc(GlyphCacheAuxProc, scaler);
- }
-
- return scaler;
-}
diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h
deleted file mode 100644
index 04959a05aa..0000000000
--- a/src/gpu/text/GrTextContext.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrTextContext_DEFINED
-#define GrTextContext_DEFINED
-
-#include "GrClip.h"
-#include "GrGlyph.h"
-#include "GrPaint.h"
-#include "SkSurfaceProps.h"
-#include "SkPostConfig.h"
-
-class GrClip;
-class GrContext;
-class GrDrawContext;
-class GrFontScaler;
-class SkDrawFilter;
-class SkTextBlob;
-
-/*
- * This class wraps the state for a single text render
- */
-class GrTextContext {
-public:
- virtual ~GrTextContext() {}
-
- 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(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(GrContext*, GrDrawContext* dc, const GrClip&,
- const SkPaint&, const SkMatrix& viewMatrix,
- const SkSurfaceProps& props, const SkTextBlob*,
- SkScalar x, SkScalar y,
- SkDrawFilter*, const SkIRect& clipBounds) = 0;
-
- static bool ShouldDisableLCD(const SkPaint& paint);
-
-protected:
- static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
- static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint);
-
- friend class GrAtlasTextBatch;
- friend class GrAtlasTextBlob; // for FilterTextFlags
- friend class GrTextUtils; // for some static functions
-};
-
-#endif
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 96b12b018b..59ecbc0fba 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -13,7 +13,6 @@
#include "GrCaps.h"
#include "GrContext.h"
#include "GrDrawContext.h"
-#include "GrTextContext.h"
#include "SkDistanceFieldGen.h"
#include "SkDrawProcs.h"
@@ -59,7 +58,7 @@ void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
// Get GrFontScaler from cache
SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix, false);
- GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
+ GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
SkFindAndPlaceGlyph::ProcessText(
skPaint.getTextEncoding(), text, byteLength,
@@ -100,7 +99,7 @@ void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
// Get GrFontScaler from cache
SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix, false);
- GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
+ GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
SkFindAndPlaceGlyph::ProcessPosText(
skPaint.getTextEncoding(), text, byteLength,
@@ -342,7 +341,7 @@ void GrTextUtils::DrawDFPosText(GrAtlasTextBlob* blob, int runIndex,
SkGlyphCache* cache = blob->setupCache(runIndex, props, dfPaint, nullptr, true);
SkDrawCacheProc glyphCacheProc = dfPaint.getDrawCacheProc();
- GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
+ GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
const char* stop = text + byteLength;
@@ -536,3 +535,47 @@ void GrTextUtils::DrawPosTextAsPath(GrContext* context,
pos += scalarsPerPosition;
}
}
+
+bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) {
+ return !SkXfermode::AsMode(paint.getXfermode(), nullptr) ||
+ paint.getMaskFilter() ||
+ paint.getRasterizer() ||
+ paint.getPathEffect() ||
+ paint.isFakeBoldText() ||
+ paint.getStyle() != SkPaint::kFill_Style;
+}
+
+uint32_t GrTextUtils::FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint) {
+ uint32_t flags = paint.getFlags();
+
+ if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
+ return flags;
+ }
+
+ if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisableLCD(paint)) {
+ flags &= ~SkPaint::kLCDRenderText_Flag;
+ flags |= SkPaint::kGenA8FromLCD_Flag;
+ }
+
+ return flags;
+}
+
+static void glyph_cache_aux_proc(void* data) {
+ GrFontScaler* scaler = (GrFontScaler*)data;
+ SkSafeUnref(scaler);
+}
+
+GrFontScaler* GrTextUtils::GetGrFontScaler(SkGlyphCache* cache) {
+ void* auxData;
+ GrFontScaler* scaler = nullptr;
+
+ if (cache->getAuxProcData(glyph_cache_aux_proc, &auxData)) {
+ scaler = (GrFontScaler*)auxData;
+ }
+ if (nullptr == scaler) {
+ scaler = new GrFontScaler(cache);
+ cache->setAuxProc(glyph_cache_aux_proc, scaler);
+ }
+
+ return scaler;
+}
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index d6b7e94ea2..096434b69f 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -81,6 +81,12 @@ public:
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds);
+
+ static bool ShouldDisableLCD(const SkPaint& paint);
+
+ static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
+ static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint);
+
private:
static void InitDistanceFieldPaint(GrAtlasTextBlob* blob,
SkPaint* skPaint,