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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 1116943004: Move instanced index buffer creation to flush time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix missing assignment of keys to index buffers Created 5 years, 7 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 | « gm/beziereffects.cpp ('k') | gyp/gpu.gypi » ('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 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
11 #include "gm.h" 11 #include "gm.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 14
15 #include "GrBatchTarget.h" 15 #include "GrBatchTarget.h"
16 #include "GrBufferAllocPool.h" 16 #include "GrBufferAllocPool.h"
17 #include "GrContext.h" 17 #include "GrContext.h"
18 #include "GrDefaultGeoProcFactory.h" 18 #include "GrDefaultGeoProcFactory.h"
19 #include "GrPathUtils.h" 19 #include "GrPathUtils.h"
20 #include "GrResourceProvider.h"
20 #include "GrTest.h" 21 #include "GrTest.h"
21 #include "GrTestBatch.h" 22 #include "GrTestBatch.h"
22 #include "SkColorPriv.h" 23 #include "SkColorPriv.h"
23 #include "SkDevice.h" 24 #include "SkDevice.h"
24 #include "SkGeometry.h" 25 #include "SkGeometry.h"
25 #include "SkTLList.h" 26 #include "SkTLList.h"
26 27
27 #include "effects/GrConvexPolyEffect.h" 28 #include "effects/GrConvexPolyEffect.h"
28 29
29 namespace skiagm { 30 namespace skiagm {
(...skipping 15 matching lines...) Expand all
45 : INHERITED(gp, geo.fBounds) 46 : INHERITED(gp, geo.fBounds)
46 , fGeometry(geo) { 47 , fGeometry(geo) {
47 } 48 }
48 49
49 Geometry* geoData(int index) override { 50 Geometry* geoData(int index) override {
50 SkASSERT(0 == index); 51 SkASSERT(0 == index);
51 return &fGeometry; 52 return &fGeometry;
52 } 53 }
53 54
54 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli ne) override { 55 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli ne) override {
56 SkAutoTUnref<const GrIndexBuffer> indexBuffer(
57 batchTarget->resourceProvider()->refQuadIndexBuffer());
58
55 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 59 size_t vertexStride = this->geometryProcessor()->getVertexStride();
56
57 const GrVertexBuffer* vertexBuffer; 60 const GrVertexBuffer* vertexBuffer;
58 int firstVertex; 61 int firstVertex;
59 62
60 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 63 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
61 kVertsPerCubic, 64 kVertsPerCubic,
62 &vertexBuffer, 65 &vertexBuffer,
63 &firstVertex); 66 &firstVertex);
64 67
65 if (!vertices || !batchTarget->quadIndexBuffer()) { 68 if (!vertices || !indexBuffer) {
66 SkDebugf("Could not allocate buffers\n"); 69 SkDebugf("Could not allocate buffers\n");
67 return; 70 return;
68 } 71 }
69 72
70 SkASSERT(vertexStride == sizeof(SkPoint)); 73 SkASSERT(vertexStride == sizeof(SkPoint));
71 SkPoint* verts = reinterpret_cast<SkPoint*>(vertices); 74 SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);
72 75
73 // Make sure any artifacts around the exterior of path are visible by us ing overly 76 // Make sure any artifacts around the exterior of path are visible by us ing overly
74 // conservative bounding geometry. 77 // conservative bounding geometry.
75 fGeometry.fBounds.outset(5.f, 5.f); 78 fGeometry.fBounds.outset(5.f, 5.f);
76 fGeometry.fBounds.toQuad(verts); 79 fGeometry.fBounds.toQuad(verts);
77 80
78 GrDrawTarget::DrawInfo drawInfo; 81 GrDrawTarget::DrawInfo drawInfo;
79 drawInfo.setPrimitiveType(kTriangleFan_GrPrimitiveType); 82 drawInfo.setPrimitiveType(kTriangleFan_GrPrimitiveType);
80 drawInfo.setVertexBuffer(vertexBuffer); 83 drawInfo.setVertexBuffer(vertexBuffer);
81 drawInfo.setStartVertex(firstVertex); 84 drawInfo.setStartVertex(firstVertex);
82 drawInfo.setVertexCount(kVertsPerCubic); 85 drawInfo.setVertexCount(kVertsPerCubic);
83 drawInfo.setStartIndex(0); 86 drawInfo.setStartIndex(0);
84 drawInfo.setIndexCount(kIndicesPerCubic); 87 drawInfo.setIndexCount(kIndicesPerCubic);
85 drawInfo.setIndexBuffer(batchTarget->quadIndexBuffer()); 88 drawInfo.setIndexBuffer(indexBuffer);
86 batchTarget->draw(drawInfo); 89 batchTarget->draw(drawInfo);
87 } 90 }
88 91
89 Geometry fGeometry; 92 Geometry fGeometry;
90 93
91 static const int kVertsPerCubic = 4; 94 static const int kVertsPerCubic = 4;
92 static const int kIndicesPerCubic = 6; 95 static const int kIndicesPerCubic = 6;
93 96
94 typedef GrTestBatch INHERITED; 97 typedef GrTestBatch INHERITED;
95 }; 98 };
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 SkTLList<SkPath> fPaths; 286 SkTLList<SkPath> fPaths;
284 SkTLList<SkRect> fRects; 287 SkTLList<SkRect> fRects;
285 288
286 typedef GM INHERITED; 289 typedef GM INHERITED;
287 }; 290 };
288 291
289 DEF_GM( return SkNEW(ConvexPolyEffect); ) 292 DEF_GM( return SkNEW(ConvexPolyEffect); )
290 } 293 }
291 294
292 #endif 295 #endif
OLDNEW
« no previous file with comments | « gm/beziereffects.cpp ('k') | gyp/gpu.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698