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

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

Issue 1483103003: Make onPrepareDraws const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 5 years 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/GrDrawVerticesBatch.cpp ('k') | src/gpu/batches/GrNonAAStrokeRectBatch.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 * 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 "GrNinePatch.h" 8 #include "GrNinePatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 GrInitInvariantOutput* coverage, 78 GrInitInvariantOutput* coverage,
79 GrBatchToXPOverrides* overrides) const ove rride { 79 GrBatchToXPOverrides* overrides) const ove rride {
80 color->setUnknownFourComponents(); 80 color->setUnknownFourComponents();
81 coverage->setKnownSingleComponent(0xff); 81 coverage->setKnownSingleComponent(0xff);
82 overrides->fUsePLSDstRead = false; 82 overrides->fUsePLSDstRead = false;
83 } 83 }
84 84
85 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 85 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
86 86
87 private: 87 private:
88 void onPrepareDraws(Target* target) override { 88 void onPrepareDraws(Target* target) const override {
89 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov erage())); 89 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov erage()));
90 if (!gp) { 90 if (!gp) {
91 SkDebugf("Couldn't create GrGeometryProcessor\n"); 91 SkDebugf("Couldn't create GrGeometryProcessor\n");
92 return; 92 return;
93 } 93 }
94 94
95 target->initDraw(gp, this->pipeline()); 95 target->initDraw(gp, this->pipeline());
96 96
97 size_t vertexStride = gp->getVertexStride(); 97 size_t vertexStride = gp->getVertexStride();
98 int instanceCount = fGeoData.count(); 98 int instanceCount = fGeoData.count();
99 99
100 SkAutoTUnref<const GrIndexBuffer> indexBuffer( 100 SkAutoTUnref<const GrIndexBuffer> indexBuffer(
101 target->resourceProvider()->refQuadIndexBuffer()); 101 target->resourceProvider()->refQuadIndexBuffer());
102 InstancedHelper helper; 102 InstancedHelper helper;
103 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS tride, 103 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS tride,
104 indexBuffer, kVertsPerRect, 104 indexBuffer, kVertsPerRect,
105 kIndicesPerRect, instanceCount * kRectsPerI nstance); 105 kIndicesPerRect, instanceCount * kRectsPerI nstance);
106 if (!vertices || !indexBuffer) { 106 if (!vertices || !indexBuffer) {
107 SkDebugf("Could not allocate vertices\n"); 107 SkDebugf("Could not allocate vertices\n");
108 return; 108 return;
109 } 109 }
110 110
111 for (int i = 0; i < instanceCount; i++) { 111 for (int i = 0; i < instanceCount; i++) {
112 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + 112 intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
113 i * kRectsPerInstance * kVertsPerRect * vertexStrid e; 113 i * kRectsPerInstance * kVertsPerRect * vertexStrid e;
114 114
115 Geometry& geo = fGeoData[i]; 115 const Geometry& geo = fGeoData[i];
116 SkNinePatchIter iter(fImageWidth, fImageHeight, geo.fCenter, geo.fDs t); 116 SkNinePatchIter iter(fImageWidth, fImageHeight, geo.fCenter, geo.fDs t);
117 117
118 SkRect srcR, dstR; 118 SkRect srcR, dstR;
119 while (iter.next(&srcR, &dstR)) { 119 while (iter.next(&srcR, &dstR)) {
120 SkPoint* positions = reinterpret_cast<SkPoint*>(verts); 120 SkPoint* positions = reinterpret_cast<SkPoint*>(verts);
121 121
122 positions->setRectFan(dstR.fLeft, dstR.fTop, 122 positions->setRectFan(dstR.fLeft, dstR.fTop,
123 dstR.fRight, dstR.fBottom, vertexStride); 123 dstR.fRight, dstR.fBottom, vertexStride);
124 124
125 SkASSERT(!geo.fViewMatrix.hasPerspective()); 125 SkASSERT(!geo.fViewMatrix.hasPerspective());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 typedef GrVertexBatch INHERITED; 176 typedef GrVertexBatch INHERITED;
177 }; 177 };
178 178
179 namespace GrNinePatch { 179 namespace GrNinePatch {
180 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid th, int imageHeight, 180 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid th, int imageHeight,
181 const SkIRect& center, const SkRect& dst) { 181 const SkIRect& center, const SkRect& dst) {
182 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst); 182 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst);
183 } 183 }
184 }; 184 };
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawVerticesBatch.cpp ('k') | src/gpu/batches/GrNonAAStrokeRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698