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

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

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "GrAADistanceFieldPathRenderer.h" 8 #include "GrAADistanceFieldPathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 166 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
167 167
168 // setup batch properties 168 // setup batch properties
169 fBatch.fColorIgnored = !overrides.readsColor(); 169 fBatch.fColorIgnored = !overrides.readsColor();
170 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 170 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
171 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 171 fBatch.fCoverageIgnored = !overrides.readsCoverage();
172 } 172 }
173 173
174 struct FlushInfo { 174 struct FlushInfo {
175 SkAutoTUnref<const GrBuffer> fVertexBuffer; 175 SkAutoTUnref<const GrBuffer> fVertexBuffer;
176 SkAutoTUnref<const GrBuffer> fIndexBuffer; 176 SkAutoTUnref<const GrBuffer> fIndexBuffer;
177 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; 177 sk_sp<GrGeometryProcessor> fGeometryProcessor;
178 int fVertexOffset; 178 int fVertexOffset;
179 int fInstancesToFlush; 179 int fInstancesToFlush;
180 }; 180 };
181 181
182 void onPrepareDraws(Target* target) const override { 182 void onPrepareDraws(Target* target) const override {
183 int instanceCount = fGeoData.count(); 183 int instanceCount = fGeoData.count();
184 184
185 SkMatrix invert; 185 SkMatrix invert;
186 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 186 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
187 SkDebugf("Could not invert viewmatrix\n"); 187 SkDebugf("Could not invert viewmatrix\n");
188 return; 188 return;
189 } 189 }
190 190
191 const SkMatrix& ctm = this->viewMatrix(); 191 const SkMatrix& ctm = this->viewMatrix();
192 uint32_t flags = 0; 192 uint32_t flags = 0;
193 flags |= ctm.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0 ; 193 flags |= ctm.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0 ;
194 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; 194 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
195 flags |= fGammaCorrect ? kGammaCorrect_DistanceFieldEffectFlag : 0; 195 flags |= fGammaCorrect ? kGammaCorrect_DistanceFieldEffectFlag : 0;
196 196
197 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBil erp_FilterMode); 197 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBil erp_FilterMode);
198 198
199 FlushInfo flushInfo; 199 FlushInfo flushInfo;
200 200
201 // Setup GrGeometryProcessor 201 // Setup GrGeometryProcessor
202 GrBatchAtlas* atlas = fAtlas; 202 GrBatchAtlas* atlas = fAtlas;
203 flushInfo.fGeometryProcessor.reset( 203 flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(this->co lor(),
204 GrDistanceFieldPathGeoProc::Create(this->color(), 204 this->vi ewMatrix(),
205 this->viewMatrix(), 205 atlas->g etTexture(),
206 atlas->getTexture(), 206 params,
207 params, 207 flags,
208 flags, 208 this->us esLocalCoords());
209 this->usesLocalCoords()));
210 209
211 // allocate vertices 210 // allocate vertices
212 size_t vertexStride = flushInfo.fGeometryProcessor->getVertexStride(); 211 size_t vertexStride = flushInfo.fGeometryProcessor->getVertexStride();
213 SkASSERT(vertexStride == 2 * sizeof(SkPoint) + sizeof(GrColor)); 212 SkASSERT(vertexStride == 2 * sizeof(SkPoint) + sizeof(GrColor));
214 213
215 const GrBuffer* vertexBuffer; 214 const GrBuffer* vertexBuffer;
216 void* vertices = target->makeVertexSpace(vertexStride, 215 void* vertices = target->makeVertexSpace(vertexStride,
217 kVerticesPerQuad * instanceCoun t, 216 kVerticesPerQuad * instanceCoun t,
218 &vertexBuffer, 217 &vertexBuffer,
219 &flushInfo.fVertexOffset); 218 &flushInfo.fVertexOffset);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 vertexStride); 476 vertexStride);
478 } 477 }
479 478
480 void flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const { 479 void flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const {
481 GrMesh mesh; 480 GrMesh mesh;
482 int maxInstancesPerDraw = 481 int maxInstancesPerDraw =
483 static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(u int16_t) / 6); 482 static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(u int16_t) / 6);
484 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer, 483 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
485 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad, 484 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
486 kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw); 485 kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
487 target->draw(flushInfo->fGeometryProcessor, mesh); 486 target->draw(flushInfo->fGeometryProcessor.get(), mesh);
488 flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFl ush; 487 flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFl ush;
489 flushInfo->fInstancesToFlush = 0; 488 flushInfo->fInstancesToFlush = 0;
490 } 489 }
491 490
492 GrColor color() const { return fGeoData[0].fColor; } 491 GrColor color() const { return fGeoData[0].fColor; }
493 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } 492 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; }
494 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } 493 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
495 494
496 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 495 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
497 AADistanceFieldPathBatch* that = t->cast<AADistanceFieldPathBatch>(); 496 AADistanceFieldPathBatch* that = t->cast<AADistanceFieldPathBatch>();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 geometry.fGenID = random->nextU(); 645 geometry.fGenID = random->nextU();
647 646
648 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, 647 return AADistanceFieldPathBatch::Create(geometry, viewMatrix,
649 gTestStruct.fAtlas, 648 gTestStruct.fAtlas,
650 &gTestStruct.fPathCache, 649 &gTestStruct.fPathCache,
651 &gTestStruct.fPathList, 650 &gTestStruct.fPathList,
652 gammaCorrect); 651 gammaCorrect);
653 } 652 }
654 653
655 #endif 654 #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