Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 683923002: Distance field path optimizations and clean up. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index e2cee650dc1fbf6b6ec020161b32a7ead3dd34a8..bcdbd8ed22799124a340ac2857e17dcc1e1af000 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -21,7 +21,6 @@
#define ATLAS_TEXTURE_WIDTH 1024
#define ATLAS_TEXTURE_HEIGHT 1024
-
#define PLOT_WIDTH 256
#define PLOT_HEIGHT 256
@@ -37,6 +36,12 @@ static int g_NumFreedPaths = 0;
#endif
////////////////////////////////////////////////////////////////////////////////
+GrAADistanceFieldPathRenderer::GrAADistanceFieldPathRenderer(GrContext* context)
+ : fContext(context)
+ , fAtlas(NULL)
+ , fEffectFlags(kInvalid_DistanceFieldEffectFlag) {
+}
+
GrAADistanceFieldPathRenderer::~GrAADistanceFieldPathRenderer() {
PathDataList::Iter iter;
iter.init(fPathList, PathDataList::Iter::kHead_IterStart);
@@ -280,7 +285,6 @@ bool GrAADistanceFieldPathRenderer::freeUnusedPlot() {
bool GrAADistanceFieldPathRenderer::internalDrawPath(const SkPath& path,
const PathData* pathData,
GrDrawTarget* target) {
-
GrTexture* texture = fAtlas->getTexture();
GrDrawState* drawState = target->drawState();
GrDrawState::AutoRestoreEffects are(drawState);
@@ -293,8 +297,7 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(const SkPath& path,
drawState->setVertexAttribs<gSDFPathVertexAttribs>(SK_ARRAY_COUNT(gSDFPathVertexAttribs),
kSDFPathVASize);
void* vertices = NULL;
- void* indices = NULL;
- bool success = target->reserveVertexAndIndexSpace(4, 6, &vertices, &indices);
+ bool success = target->reserveVertexAndIndexSpace(4, 0, &vertices, NULL);
GrAlwaysAssert(success);
SkScalar dx = pathData->fBounds.fLeft;
@@ -328,29 +331,24 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(const SkPath& path,
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + th)),
vertSize);
- uint16_t* indexPtr = reinterpret_cast<uint16_t*>(indices);
- *indexPtr++ = 0;
- *indexPtr++ = 1;
- *indexPtr++ = 2;
- *indexPtr++ = 0;
- *indexPtr++ = 2;
- *indexPtr++ = 3;
-
// set up any flags
uint32_t flags = 0;
const SkMatrix& vm = drawState->getViewMatrix();
flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode);
- drawState->setGeometryProcessor(GrDistanceFieldNoGammaTextureEffect::Create(texture,
- params,
- flags))->unref();
-
+ if (flags != fEffectFlags) {
+ fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Create(texture,
+ params,
+ flags));
+ fEffectFlags = flags;
+ }
+ drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
vm.mapRect(&r);
+ target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &r);
target->resetVertexSource();
- target->resetIndexSource();
return true;
}
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698