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

Unified Diff: src/gpu/GrDrawContext.cpp

Issue 1279343004: Revise DrawAtlasBatch to get rid of one copy when generating the batch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Picky picky Windows 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 | « no previous file | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawContext.cpp
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index c5cb8559f35f3281067801e934f8c4664af9928f..c4716196b9c266c8a91c99d3fef08639e34814f7 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -21,9 +21,6 @@
#include "batches/GrDrawVerticesBatch.h"
#include "batches/GrRectBatchFactory.h"
-#include "SkGr.h"
-#include "SkRSXform.h"
-
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext)
#define RETURN_IF_ABANDONED if (!fDrawTarget) { return; }
#define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; }
@@ -420,63 +417,10 @@ void GrDrawContext::drawAtlas(GrRenderTarget* rt,
GrPipelineBuilder pipelineBuilder(paint, rt, clip);
- // now build the renderable geometry
- const int vertCount = spriteCount * 4;
- SkAutoTMalloc<SkPoint> vertStorage(vertCount * 2);
- SkPoint* verts = vertStorage.get();
- SkPoint* texs = verts + vertCount;
-
- for (int i = 0; i < spriteCount; ++i) {
- xform[i].toQuad(texRect[i].width(), texRect[i].height(), verts);
- texRect[i].toQuad(texs);
- verts += 4;
- texs += 4;
- }
-
- // TODO clients should give us bounds
- SkRect bounds;
- if (!bounds.setBoundsCheck(vertStorage.get(), vertCount)) {
- SkDebugf("drawAtlas call empty bounds\n");
- return;
- }
-
- viewMatrix.mapRect(&bounds);
-
- // If we don't have AA then we outset for a half pixel in each direction to account for
- // snapping
- if (!paint.isAntiAlias()) {
- bounds.outset(0.5f, 0.5f);
- }
-
- SkAutoTMalloc<GrColor> colorStorage;
- GrColor* vertCols = NULL;
- if (colors) {
- colorStorage.reset(vertCount);
- vertCols = colorStorage.get();
-
- int paintAlpha = GrColorUnpackA(paint.getColor());
-
- // need to convert byte order and from non-PM to PM
- for (int i = 0; i < spriteCount; ++i) {
- SkColor color = colors[i];
- if (paintAlpha != 255) {
- color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paintAlpha));
- }
- GrColor grColor = SkColor2GrColor(color);
-
- vertCols[0] = vertCols[1] = vertCols[2] = vertCols[3] = grColor;
- vertCols += 4;
- }
- }
-
- verts = vertStorage.get();
- texs = verts + vertCount;
- vertCols = colorStorage.get();
-
GrDrawAtlasBatch::Geometry geometry;
geometry.fColor = paint.getColor();
- SkAutoTUnref<GrBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, verts, vertCount,
- vertCols, texs, bounds));
+ SkAutoTUnref<GrBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount,
+ xform, texRect, colors));
fDrawTarget->drawBatch(pipelineBuilder, batch);
}
« no previous file with comments | « no previous file | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698