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

Side by Side Diff: src/gpu/batches/GrBWFillRectBatch.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 unified diff | Download patch
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrBWFillRectBatch.h" 8 #include "GrBWFillRectBatch.h"
9 9
10 #include "GrBatchTarget.h" 10 #include "GrBatchFlushState.h"
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrDefaultGeoProcFactory.h" 12 #include "GrDefaultGeoProcFactory.h"
13 #include "GrPrimitiveProcessor.h" 13 #include "GrPrimitiveProcessor.h"
14 #include "GrVertexBatch.h" 14 #include "GrVertexBatch.h"
15 15
16 class GrBatchTarget; 16 class GrBatchFlushState;
17 class SkMatrix; 17 class SkMatrix;
18 struct SkRect; 18 struct SkRect;
19 19
20 class BWFillRectBatch : public GrVertexBatch { 20 class BWFillRectBatch : public GrVertexBatch {
21 public: 21 public:
22 struct Geometry { 22 struct Geometry {
23 SkMatrix fViewMatrix; 23 SkMatrix fViewMatrix;
24 SkRect fRect; 24 SkRect fRect;
25 SkRect fLocalRect; 25 SkRect fLocalRect;
26 SkMatrix fLocalMatrix; 26 SkMatrix fLocalMatrix;
(...skipping 24 matching lines...) Expand all
51 } 51 }
52 init.getOverrideColorIfSet(&fGeoData[0].fColor); 52 init.getOverrideColorIfSet(&fGeoData[0].fColor);
53 53
54 // setup batch properties 54 // setup batch properties
55 fBatch.fColorIgnored = !init.readsColor(); 55 fBatch.fColorIgnored = !init.readsColor();
56 fBatch.fColor = fGeoData[0].fColor; 56 fBatch.fColor = fGeoData[0].fColor;
57 fBatch.fUsesLocalCoords = init.readsLocalCoords(); 57 fBatch.fUsesLocalCoords = init.readsLocalCoords();
58 fBatch.fCoverageIgnored = !init.readsCoverage(); 58 fBatch.fCoverageIgnored = !init.readsCoverage();
59 } 59 }
60 60
61 void generateGeometry(GrBatchTarget* batchTarget) override { 61 void onPrepareDraws(Target* target) override {
62 SkAutoTUnref<const GrGeometryProcessor> gp(this->createRectGP()); 62 SkAutoTUnref<const GrGeometryProcessor> gp(this->createRectGP());
63 if (!gp) { 63 if (!gp) {
64 SkDebugf("Could not create GrGeometryProcessor\n"); 64 SkDebugf("Could not create GrGeometryProcessor\n");
65 return; 65 return;
66 } 66 }
67 67
68 batchTarget->initDraw(gp, this->pipeline()); 68 target->initDraw(gp, this->pipeline());
69 69
70 int instanceCount = fGeoData.count(); 70 int instanceCount = fGeoData.count();
71 size_t vertexStride = gp->getVertexStride(); 71 size_t vertexStride = gp->getVertexStride();
72 SkASSERT(this->hasLocalRect() ? 72 SkASSERT(this->hasLocalRect() ?
73 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLo calCoordAttr) : 73 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLo calCoordAttr) :
74 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr)); 74 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr));
75 QuadHelper helper; 75 QuadHelper helper;
76 void* vertices = helper.init(batchTarget, vertexStride, instanceCount); 76 void* vertices = helper.init(target, vertexStride, instanceCount);
77 77
78 if (!vertices) { 78 if (!vertices) {
79 return; 79 return;
80 } 80 }
81 81
82 for (int i = 0; i < instanceCount; i++) { 82 for (int i = 0; i < instanceCount; i++) {
83 const Geometry& geom = fGeoData[i]; 83 const Geometry& geom = fGeoData[i];
84 84
85 intptr_t offset = reinterpret_cast<intptr_t>(vertices) + 85 intptr_t offset = reinterpret_cast<intptr_t>(vertices) +
86 kVerticesPerQuad * i * vertexStride; 86 kVerticesPerQuad * i * vertexStride;
(...skipping 16 matching lines...) Expand all
103 } 103 }
104 104
105 static const int kColorOffset = sizeof(SkPoint); 105 static const int kColorOffset = sizeof(SkPoint);
106 GrColor* vertColor = reinterpret_cast<GrColor*>(offset + kColorOffse t); 106 GrColor* vertColor = reinterpret_cast<GrColor*>(offset + kColorOffse t);
107 for (int j = 0; j < 4; ++j) { 107 for (int j = 0; j < 4; ++j) {
108 *vertColor = geom.fColor; 108 *vertColor = geom.fColor;
109 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride); 109 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
110 } 110 }
111 } 111 }
112 112
113 helper.issueDraw(batchTarget); 113 helper.recordDraw(target);
114 } 114 }
115 115
116 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 116 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
117 117
118 private: 118 private:
119 BWFillRectBatch(const Geometry& geometry) { 119 BWFillRectBatch(const Geometry& geometry) {
120 this->initClassID<BWFillRectBatch>(); 120 this->initClassID<BWFillRectBatch>();
121 fGeoData.push_back(geometry); 121 fGeoData.push_back(geometry);
122 122
123 fBounds = geometry.fRect; 123 fBounds = geometry.fRect;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 geometry.fHasLocalMatrix = random->nextBool(); 260 geometry.fHasLocalMatrix = random->nextBool();
261 if (geometry.fHasLocalMatrix) { 261 if (geometry.fHasLocalMatrix) {
262 geometry.fLocalMatrix = GrTest::TestMatrix(random); 262 geometry.fLocalMatrix = GrTest::TestMatrix(random);
263 } 263 }
264 264
265 return BWFillRectBatch::Create(geometry); 265 return BWFillRectBatch::Create(geometry);
266 } 266 }
267 267
268 #endif 268 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698