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

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

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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/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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 84 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
85 85
86 private: 86 private:
87 void onPrepareDraws(Target* target) const override { 87 void onPrepareDraws(Target* target) const override {
88 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov erage())); 88 SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCov erage()));
89 if (!gp) { 89 if (!gp) {
90 SkDebugf("Couldn't create GrGeometryProcessor\n"); 90 SkDebugf("Couldn't create GrGeometryProcessor\n");
91 return; 91 return;
92 } 92 }
93 93
94 target->initDraw(gp);
95
96 size_t vertexStride = gp->getVertexStride(); 94 size_t vertexStride = gp->getVertexStride();
97 int instanceCount = fGeoData.count(); 95 int instanceCount = fGeoData.count();
98 96
99 SkAutoTUnref<const GrBuffer> indexBuffer( 97 SkAutoTUnref<const GrBuffer> indexBuffer(
100 target->resourceProvider()->refQuadIndexBuffer()); 98 target->resourceProvider()->refQuadIndexBuffer());
101 InstancedHelper helper; 99 InstancedHelper helper;
102 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS tride, 100 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS tride,
103 indexBuffer, kVertsPerRect, 101 indexBuffer, kVertsPerRect,
104 kIndicesPerRect, instanceCount * kRectsPerI nstance); 102 kIndicesPerRect, instanceCount * kRectsPerI nstance);
105 if (!vertices || !indexBuffer) { 103 if (!vertices || !indexBuffer) {
(...skipping 25 matching lines...) Expand all
131 129
132 static const int kColorOffset = sizeof(SkPoint); 130 static const int kColorOffset = sizeof(SkPoint);
133 GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOf fset); 131 GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOf fset);
134 for (int j = 0; j < 4; ++j) { 132 for (int j = 0; j < 4; ++j) {
135 *vertColor = geo.fColor; 133 *vertColor = geo.fColor;
136 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride) ; 134 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride) ;
137 } 135 }
138 verts += kVertsPerRect * vertexStride; 136 verts += kVertsPerRect * vertexStride;
139 } 137 }
140 } 138 }
141 helper.recordDraw(target); 139 helper.recordDraw(target, gp);
142 } 140 }
143 141
144 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 142 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
145 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 143 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
146 fOverrides = overrides; 144 fOverrides = overrides;
147 } 145 }
148 146
149 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 147 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
150 GrNonAANinePatchBatch* that = t->cast<GrNonAANinePatchBatch>(); 148 GrNonAANinePatchBatch* that = t->cast<GrNonAANinePatchBatch>();
151 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 149 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
(...skipping 22 matching lines...) Expand all
174 172
175 typedef GrVertexBatch INHERITED; 173 typedef GrVertexBatch INHERITED;
176 }; 174 };
177 175
178 namespace GrNinePatch { 176 namespace GrNinePatch {
179 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid th, int imageHeight, 177 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid th, int imageHeight,
180 const SkIRect& center, const SkRect& dst) { 178 const SkIRect& center, const SkRect& dst) {
181 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst); 179 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst);
182 } 180 }
183 }; 181 };
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