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

Unified Diff: src/gpu/GrAtlasTextContext.cpp

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl Created 5 years, 4 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/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/GrBatchAtlas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAtlasTextContext.cpp
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index b6e0acc58f8660d7fd6b60fabebe94390df443dd..fbfb2e1c94d26034ebf470444abfe23f4b5a6c68 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -7,7 +7,7 @@
#include "GrAtlasTextContext.h"
#include "GrBatchFontCache.h"
-#include "GrBatchTarget.h"
+#include "GrBatchFlushState.h"
#include "GrBatchTest.h"
#include "GrBlurUtils.h"
#include "GrDefaultGeoProcFactory.h"
@@ -1535,7 +1535,7 @@ public:
int fVertexOffset;
};
- void generateGeometry(GrBatchTarget* batchTarget) override {
+ void onPrepareDraws(Target* target) override {
// if we have RGB, then we won't have any SkShaders so no need to use a localmatrix.
// TODO actually only invert if we don't have RGBA
SkMatrix localMatrix;
@@ -1575,17 +1575,17 @@ public:
get_vertex_stride_df(maskFormat, isLCD) :
get_vertex_stride(maskFormat)));
- batchTarget->initDraw(gp, this->pipeline());
+ target->initDraw(gp, this->pipeline());
int glyphCount = this->numGlyphs();
const GrVertexBuffer* vertexBuffer;
- void* vertices = batchTarget->makeVertSpace(vertexStride,
- glyphCount * kVerticesPerGlyph,
- &vertexBuffer,
- &flushInfo.fVertexOffset);
+ void* vertices = target->makeVertexSpace(vertexStride,
+ glyphCount * kVerticesPerGlyph,
+ &vertexBuffer,
+ &flushInfo.fVertexOffset);
flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
- flushInfo.fIndexBuffer.reset(batchTarget->resourceProvider()->refQuadIndexBuffer());
+ flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer());
if (!vertices || !flushInfo.fVertexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
@@ -1689,13 +1689,12 @@ public:
//SkASSERT(glyph->fMaskFormat == this->maskFormat());
if (!fFontCache->hasGlyph(glyph) &&
- !strike->addGlyphToAtlas(batchTarget, glyph, scaler, skGlyph,
- maskFormat)) {
- this->flush(batchTarget, &flushInfo);
- batchTarget->initDraw(gp, this->pipeline());
+ !strike->addGlyphToAtlas(target, glyph, scaler, skGlyph, maskFormat)) {
+ this->flush(target, &flushInfo);
+ target->initDraw(gp, this->pipeline());
brokenRun = glyphIdx > 0;
- SkDEBUGCODE(bool success =) strike->addGlyphToAtlas(batchTarget,
+ SkDEBUGCODE(bool success =) strike->addGlyphToAtlas(target,
glyph,
scaler,
skGlyph,
@@ -1703,7 +1702,7 @@ public:
SkASSERT(success);
}
fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseToken, glyph,
- batchTarget->currentToken());
+ target->currentToken());
// Texture coords are the last vertex attribute so we get a pointer to the
// first one and then map with stride in regenerateTextureCoords
@@ -1747,9 +1746,7 @@ public:
// set use tokens for all of the glyphs in our subrun. This is only valid if we
// have a valid atlas generation
- fFontCache->setUseTokenBulk(info.fBulkUseToken,
- batchTarget->currentToken(),
- maskFormat);
+ fFontCache->setUseTokenBulk(info.fBulkUseToken, target->currentToken(), maskFormat);
}
// now copy all vertices
@@ -1762,7 +1759,7 @@ public:
if (cache) {
SkGlyphCache::AttachCache(cache);
}
- this->flush(batchTarget, &flushInfo);
+ this->flush(target, &flushInfo);
}
// to avoid even the initial copy of the struct, we have a getter for the first item which
@@ -1875,14 +1872,14 @@ private:
}
}
- void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) {
+ void flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) {
GrVertices vertices;
int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads();
vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
maxGlyphsPerDraw);
- batchTarget->draw(vertices);
+ target->draw(vertices);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0;
}
« no previous file with comments | « src/gpu/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/GrBatchAtlas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698