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

Side by Side Diff: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp

Issue 1831133004: Revert of Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAAFillRectBatch.cpp » ('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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAADistanceFieldPathRenderer.h" 9 #include "GrAADistanceFieldPathRenderer.h"
10 10
11 #include "GrBatchFlushState.h" 11 #include "GrBatchFlushState.h"
12 #include "GrBatchTest.h" 12 #include "GrBatchTest.h"
13 #include "GrBuffer.h"
14 #include "GrContext.h" 13 #include "GrContext.h"
15 #include "GrPipelineBuilder.h" 14 #include "GrPipelineBuilder.h"
16 #include "GrResourceProvider.h" 15 #include "GrResourceProvider.h"
17 #include "GrSurfacePriv.h" 16 #include "GrSurfacePriv.h"
18 #include "GrSWMaskHelper.h" 17 #include "GrSWMaskHelper.h"
19 #include "GrTexturePriv.h" 18 #include "GrTexturePriv.h"
19 #include "GrVertexBuffer.h"
20 #include "batches/GrVertexBatch.h" 20 #include "batches/GrVertexBatch.h"
21 #include "effects/GrDistanceFieldGeoProc.h" 21 #include "effects/GrDistanceFieldGeoProc.h"
22 22
23 #include "SkDistanceFieldGen.h" 23 #include "SkDistanceFieldGen.h"
24 #include "SkRTConf.h" 24 #include "SkRTConf.h"
25 25
26 #define ATLAS_TEXTURE_WIDTH 2048 26 #define ATLAS_TEXTURE_WIDTH 2048
27 #define ATLAS_TEXTURE_HEIGHT 2048 27 #define ATLAS_TEXTURE_HEIGHT 2048
28 #define PLOT_WIDTH 512 28 #define PLOT_WIDTH 512
29 #define PLOT_HEIGHT 256 29 #define PLOT_HEIGHT 256
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 171 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
172 172
173 // setup batch properties 173 // setup batch properties
174 fBatch.fColorIgnored = !overrides.readsColor(); 174 fBatch.fColorIgnored = !overrides.readsColor();
175 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 175 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
176 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 176 fBatch.fCoverageIgnored = !overrides.readsCoverage();
177 } 177 }
178 178
179 struct FlushInfo { 179 struct FlushInfo {
180 SkAutoTUnref<const GrBuffer> fVertexBuffer; 180 SkAutoTUnref<const GrVertexBuffer> fVertexBuffer;
181 SkAutoTUnref<const GrBuffer> fIndexBuffer; 181 SkAutoTUnref<const GrIndexBuffer> fIndexBuffer;
182 int fVertexOffset; 182 int fVertexOffset;
183 int fInstancesToFlush; 183 int fInstancesToFlush;
184 }; 184 };
185 185
186 void onPrepareDraws(Target* target) const override { 186 void onPrepareDraws(Target* target) const override {
187 int instanceCount = fGeoData.count(); 187 int instanceCount = fGeoData.count();
188 188
189 SkMatrix invert; 189 SkMatrix invert;
190 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 190 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
191 SkDebugf("Could not invert viewmatrix\n"); 191 SkDebugf("Could not invert viewmatrix\n");
(...skipping 18 matching lines...) Expand all
210 this->usesLocalCoords())); 210 this->usesLocalCoords()));
211 211
212 target->initDraw(dfProcessor); 212 target->initDraw(dfProcessor);
213 213
214 FlushInfo flushInfo; 214 FlushInfo flushInfo;
215 215
216 // allocate vertices 216 // allocate vertices
217 size_t vertexStride = dfProcessor->getVertexStride(); 217 size_t vertexStride = dfProcessor->getVertexStride();
218 SkASSERT(vertexStride == 2 * sizeof(SkPoint) + sizeof(GrColor)); 218 SkASSERT(vertexStride == 2 * sizeof(SkPoint) + sizeof(GrColor));
219 219
220 const GrBuffer* vertexBuffer; 220 const GrVertexBuffer* vertexBuffer;
221 void* vertices = target->makeVertexSpace(vertexStride, 221 void* vertices = target->makeVertexSpace(vertexStride,
222 kVerticesPerQuad * instanceCoun t, 222 kVerticesPerQuad * instanceCoun t,
223 &vertexBuffer, 223 &vertexBuffer,
224 &flushInfo.fVertexOffset); 224 &flushInfo.fVertexOffset);
225 flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); 225 flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
226 flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuf fer()); 226 flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuf fer());
227 if (!vertices || !flushInfo.fIndexBuffer) { 227 if (!vertices || !flushInfo.fIndexBuffer) {
228 SkDebugf("Could not allocate vertices\n"); 228 SkDebugf("Could not allocate vertices\n");
229 return; 229 return;
230 } 230 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 SkPoint* textureCoords = (SkPoint*)(offset + sizeof(SkPoint) + sizeof(Gr Color)); 485 SkPoint* textureCoords = (SkPoint*)(offset + sizeof(SkPoint) + sizeof(Gr Color));
486 textureCoords->setRectFan(tx / texture->width(), 486 textureCoords->setRectFan(tx / texture->width(),
487 ty / texture->height(), 487 ty / texture->height(),
488 (tx + pathData->fBounds.width()) / texture->wi dth(), 488 (tx + pathData->fBounds.width()) / texture->wi dth(),
489 (ty + pathData->fBounds.height()) / texture-> height(), 489 (ty + pathData->fBounds.height()) / texture-> height(),
490 vertexStride); 490 vertexStride);
491 } 491 }
492 492
493 void flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const { 493 void flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const {
494 GrMesh mesh; 494 GrMesh mesh;
495 int maxInstancesPerDraw = 495 int maxInstancesPerDraw = flushInfo->fIndexBuffer->maxQuads();
496 static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(u int16_t) / 6);
497 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer, 496 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
498 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad, 497 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
499 kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw); 498 kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
500 target->draw(mesh); 499 target->draw(mesh);
501 flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFl ush; 500 flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFl ush;
502 flushInfo->fInstancesToFlush = 0; 501 flushInfo->fInstancesToFlush = 0;
503 } 502 }
504 503
505 GrColor color() const { return fGeoData[0].fColor; } 504 GrColor color() const { return fGeoData[0].fColor; }
506 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } 505 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 geometry.fAntiAlias = random->nextBool(); 647 geometry.fAntiAlias = random->nextBool();
649 geometry.fGenID = random->nextU(); 648 geometry.fGenID = random->nextU();
650 649
651 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, 650 return AADistanceFieldPathBatch::Create(geometry, viewMatrix,
652 gTestStruct.fAtlas, 651 gTestStruct.fAtlas,
653 &gTestStruct.fPathCache, 652 &gTestStruct.fPathCache,
654 &gTestStruct.fPathList); 653 &gTestStruct.fPathList);
655 } 654 }
656 655
657 #endif 656 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAAFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698