Delete GrTextContext
TBR=bsalomon@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1699073004 Review URL: https://codereview.chromium.org/1699073004
This commit is contained in:
parent
546d66544b
commit
8e84a1ed07
@ -308,8 +308,6 @@
|
||||
'<(skia_src_path)/gpu/text/GrStencilAndCoverTextContext.h',
|
||||
'<(skia_src_path)/gpu/text/GrTextBlobCache.cpp',
|
||||
'<(skia_src_path)/gpu/text/GrTextBlobCache.h',
|
||||
'<(skia_src_path)/gpu/text/GrTextContext.cpp',
|
||||
'<(skia_src_path)/gpu/text/GrTextContext.h',
|
||||
'<(skia_src_path)/gpu/text/GrTextUtils.cpp',
|
||||
'<(skia_src_path)/gpu/text/GrTextUtils.h',
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "SkSurfaceProps.h"
|
||||
#include "../private/GrSingleOwner.h"
|
||||
|
||||
class GrAtlasTextContext;
|
||||
class GrAuditTrail;
|
||||
class GrClip;
|
||||
class GrContext;
|
||||
@ -27,7 +28,6 @@ class GrPipelineBuilder;
|
||||
class GrRenderTarget;
|
||||
class GrStrokeInfo;
|
||||
class GrSurface;
|
||||
class GrTextContext;
|
||||
class SkDrawFilter;
|
||||
struct SkIPoint;
|
||||
struct SkIRect;
|
||||
@ -316,7 +316,7 @@ private:
|
||||
// In MDB-mode the drawTarget can be closed by some other drawContext that has picked
|
||||
// it up. For this reason, the drawTarget should only ever be accessed via 'getDrawTarget'.
|
||||
GrDrawTarget* fDrawTarget;
|
||||
GrTextContext* fAtlasTextContext; // lazily gotten from GrContext::DrawingManager
|
||||
GrAtlasTextContext* fAtlasTextContext;
|
||||
GrContext* fContext;
|
||||
|
||||
SkSurfaceProps fSurfaceProps;
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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:
|
||||
|
@ -20,7 +20,6 @@
|
||||
class GrBlobRegenHelper;
|
||||
struct GrDistanceFieldAdjustTable;
|
||||
class GrMemoryPool;
|
||||
class GrTextContext;
|
||||
class SkDrawFilter;
|
||||
class SkTextBlob;
|
||||
class SkTextBlobRunIterator;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user