Move GrAtlasTextContext to GrDrawingManager, so we only have one.
Ultimately, avoids wasteful redundant computation and storage of distance field fake-gamma tables. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2240623002 Review-Url: https://codereview.chromium.org/2240623002
This commit is contained in:
parent
c6d855f7f3
commit
86e7626f08
@ -17,7 +17,6 @@
|
||||
#include "../private/GrInstancedPipelineInfo.h"
|
||||
#include "../private/GrSingleOwner.h"
|
||||
|
||||
class GrAtlasTextContext;
|
||||
class GrAuditTrail;
|
||||
class GrClip;
|
||||
class GrContext;
|
||||
@ -367,7 +366,6 @@ 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;
|
||||
SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext;
|
||||
GrContext* fContext;
|
||||
GrInstancedPipelineInfo fInstancedPipelineInfo;
|
||||
|
||||
|
@ -135,12 +135,9 @@ void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawText");
|
||||
|
||||
if (!fAtlasTextContext) {
|
||||
fAtlasTextContext.reset(GrAtlasTextContext::Create());
|
||||
}
|
||||
|
||||
fAtlasTextContext->drawText(fContext, this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
|
||||
text, byteLength, x, y, clipBounds);
|
||||
GrAtlasTextContext* atlasTextContext = fDrawingManager->getAtlasTextContext();
|
||||
atlasTextContext->drawText(fContext, this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
|
||||
text, byteLength, x, y, clipBounds);
|
||||
}
|
||||
|
||||
void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
|
||||
@ -154,13 +151,10 @@ void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPosText");
|
||||
|
||||
if (!fAtlasTextContext) {
|
||||
fAtlasTextContext.reset(GrAtlasTextContext::Create());
|
||||
}
|
||||
|
||||
fAtlasTextContext->drawPosText(fContext, this, clip, grPaint, skPaint, viewMatrix,
|
||||
fSurfaceProps, text, byteLength, pos, scalarsPerPosition,
|
||||
offset, clipBounds);
|
||||
GrAtlasTextContext* atlasTextContext = fDrawingManager->getAtlasTextContext();
|
||||
atlasTextContext->drawPosText(fContext, this, clip, grPaint, skPaint, viewMatrix,
|
||||
fSurfaceProps, text, byteLength, pos, scalarsPerPosition,
|
||||
offset, clipBounds);
|
||||
|
||||
}
|
||||
|
||||
@ -173,12 +167,9 @@ void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawTextBlob");
|
||||
|
||||
if (!fAtlasTextContext) {
|
||||
fAtlasTextContext.reset(GrAtlasTextContext::Create());
|
||||
}
|
||||
|
||||
fAtlasTextContext->drawTextBlob(fContext, this, clip, skPaint, viewMatrix, fSurfaceProps, blob,
|
||||
x, y, filter, clipBounds);
|
||||
GrAtlasTextContext* atlasTextContext = fDrawingManager->getAtlasTextContext();
|
||||
atlasTextContext->drawTextBlob(fContext, this, clip, skPaint, viewMatrix, fSurfaceProps, blob,
|
||||
x, y, filter, clipBounds);
|
||||
}
|
||||
|
||||
void GrDrawContext::discard() {
|
||||
|
@ -150,6 +150,14 @@ GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
|
||||
return SkRef(dt);
|
||||
}
|
||||
|
||||
GrAtlasTextContext* GrDrawingManager::getAtlasTextContext() {
|
||||
if (!fAtlasTextContext) {
|
||||
fAtlasTextContext.reset(GrAtlasTextContext::Create());
|
||||
}
|
||||
|
||||
return fAtlasTextContext.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* This method finds a path renderer that can draw the specified path on
|
||||
* the provided target.
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef GrDrawingManager_DEFINED
|
||||
#define GrDrawingManager_DEFINED
|
||||
|
||||
#include "text/GrAtlasTextContext.h"
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrBatchFlushState.h"
|
||||
#include "GrPathRendererChain.h"
|
||||
@ -41,6 +42,8 @@ public:
|
||||
|
||||
GrContext* getContext() { return fContext; }
|
||||
|
||||
GrAtlasTextContext* getAtlasTextContext();
|
||||
|
||||
GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args,
|
||||
bool allowSW,
|
||||
GrPathRendererChain::DrawType drawType,
|
||||
@ -55,6 +58,7 @@ private:
|
||||
, fOptionsForDrawTargets(optionsForDrawTargets)
|
||||
, fSingleOwner(singleOwner)
|
||||
, fAbandoned(false)
|
||||
, fAtlasTextContext(nullptr)
|
||||
, fPathRendererChain(nullptr)
|
||||
, fSoftwarePathRenderer(nullptr)
|
||||
, fFlushState(context->getGpu(), context->resourceProvider())
|
||||
@ -71,20 +75,22 @@ private:
|
||||
static const int kNumPixelGeometries = 5; // The different pixel geometries
|
||||
static const int kNumDFTOptions = 2; // DFT or no DFT
|
||||
|
||||
GrContext* fContext;
|
||||
GrDrawTarget::Options fOptionsForDrawTargets;
|
||||
GrContext* fContext;
|
||||
GrDrawTarget::Options fOptionsForDrawTargets;
|
||||
|
||||
// In debug builds we guard against improper thread handling
|
||||
GrSingleOwner* fSingleOwner;
|
||||
GrSingleOwner* fSingleOwner;
|
||||
|
||||
bool fAbandoned;
|
||||
SkTDArray<GrDrawTarget*> fDrawTargets;
|
||||
bool fAbandoned;
|
||||
SkTDArray<GrDrawTarget*> fDrawTargets;
|
||||
|
||||
GrPathRendererChain* fPathRendererChain;
|
||||
GrSoftwarePathRenderer* fSoftwarePathRenderer;
|
||||
SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext;
|
||||
|
||||
GrBatchFlushState fFlushState;
|
||||
bool fFlushing;
|
||||
GrPathRendererChain* fPathRendererChain;
|
||||
GrSoftwarePathRenderer* fSoftwarePathRenderer;
|
||||
|
||||
GrBatchFlushState fFlushState;
|
||||
bool fFlushing;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,8 @@ void GrPathRenderingDrawContext::drawText(const GrClip& clip, const GrPaint& gr
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::drawText");
|
||||
|
||||
if (!fStencilAndCoverTextContext) {
|
||||
fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create());
|
||||
GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
|
||||
fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
|
||||
}
|
||||
|
||||
fStencilAndCoverTextContext->drawText(this->drawingManager()->getContext(), this, clip, grPaint,
|
||||
@ -46,7 +47,8 @@ void GrPathRenderingDrawContext::drawPosText(const GrClip& clip, const GrPaint&
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::drawPosText");
|
||||
|
||||
if (!fStencilAndCoverTextContext) {
|
||||
fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create());
|
||||
GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
|
||||
fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
|
||||
}
|
||||
|
||||
fStencilAndCoverTextContext->drawPosText(this->drawingManager()->getContext(), this, clip,
|
||||
@ -65,7 +67,8 @@ void GrPathRenderingDrawContext::drawTextBlob(const GrClip& clip, const SkPaint&
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::drawTextBlob");
|
||||
|
||||
if (!fStencilAndCoverTextContext) {
|
||||
fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create());
|
||||
GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
|
||||
fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
|
||||
}
|
||||
|
||||
fStencilAndCoverTextContext->drawTextBlob(this->drawingManager()->getContext(), this, clip,
|
||||
|
@ -37,21 +37,17 @@ template<typename T> static void delete_hash_table_entry(T* val) {
|
||||
delete *val;
|
||||
}
|
||||
|
||||
GrStencilAndCoverTextContext::GrStencilAndCoverTextContext()
|
||||
: fFallbackTextContext(nullptr)
|
||||
GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrAtlasTextContext* fallbackTextContext)
|
||||
: fFallbackTextContext(fallbackTextContext)
|
||||
, fCacheSize(0) {
|
||||
}
|
||||
|
||||
GrStencilAndCoverTextContext*
|
||||
GrStencilAndCoverTextContext::Create() {
|
||||
GrStencilAndCoverTextContext* textContext = new GrStencilAndCoverTextContext();
|
||||
textContext->fFallbackTextContext = GrAtlasTextContext::Create();
|
||||
|
||||
return textContext;
|
||||
GrStencilAndCoverTextContext::Create(GrAtlasTextContext* fallbackTextContext) {
|
||||
return new GrStencilAndCoverTextContext(fallbackTextContext);;
|
||||
}
|
||||
|
||||
GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() {
|
||||
delete fFallbackTextContext;
|
||||
fBlobIdCache.foreach(delete_hash_map_entry<uint32_t, TextBlob*>);
|
||||
fBlobKeyCache.foreach(delete_hash_table_entry<TextBlob*>);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class SkSurfaceProps;
|
||||
*/
|
||||
class GrStencilAndCoverTextContext {
|
||||
public:
|
||||
static GrStencilAndCoverTextContext* Create();
|
||||
static GrStencilAndCoverTextContext* Create(GrAtlasTextContext* fallbackTextContext);
|
||||
|
||||
void drawText(GrContext*, GrDrawContext* dc,
|
||||
const GrClip&, const GrPaint&, const SkPaint&,
|
||||
@ -50,7 +50,7 @@ public:
|
||||
virtual ~GrStencilAndCoverTextContext();
|
||||
|
||||
private:
|
||||
GrStencilAndCoverTextContext();
|
||||
GrStencilAndCoverTextContext(GrAtlasTextContext* fallbackTextContext);
|
||||
|
||||
bool canDraw(const SkPaint& skPaint, const SkMatrix&) {
|
||||
return this->internalCanDraw(skPaint);
|
||||
|
Loading…
Reference in New Issue
Block a user