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

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 1261083003: Use new API everywhere for GrDefaultGeoProcFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@lccleanup2
Patch Set: tweaks Created 5 years, 4 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/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrRectBatch.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 2015 Google Inc. 3 * Copyright 2015 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 "GrAARectRenderer.h" 9 #include "GrAARectRenderer.h"
10 #include "GrAtlasTextContext.h" 10 #include "GrAtlasTextContext.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 init.getOverrideColorIfSet(&fGeoData[0].fColor); 281 init.getOverrideColorIfSet(&fGeoData[0].fColor);
282 282
283 // setup batch properties 283 // setup batch properties
284 fBatch.fColorIgnored = !init.readsColor(); 284 fBatch.fColorIgnored = !init.readsColor();
285 fBatch.fColor = fGeoData[0].fColor; 285 fBatch.fColor = fGeoData[0].fColor;
286 fBatch.fUsesLocalCoords = init.readsLocalCoords(); 286 fBatch.fUsesLocalCoords = init.readsLocalCoords();
287 fBatch.fCoverageIgnored = !init.readsCoverage(); 287 fBatch.fCoverageIgnored = !init.readsCoverage();
288 } 288 }
289 289
290 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { 290 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override {
291 SkAutoTUnref<const GrGeometryProcessor> gp( 291 SkAutoTUnref<const GrGeometryProcessor> gp;
292 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi on_GPType, 292 {
293 this->color(), 293 using namespace GrDefaultGeoProcFactory;
294 this->usesLocalCoords(), 294 Color color(this->color());
295 this->coverageIgnored(), 295 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type :
296 this->viewMatrix(), 296 Coverage::kNone_Type);
297 SkMatrix::I())); 297 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type :
298 LocalCoords::kUnus ed_Type);
299 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s,
300 this->viewMatrix()));
301 }
298 302
299 batchTarget->initDraw(gp, pipeline); 303 batchTarget->initDraw(gp, pipeline);
300 304
301 size_t vertexStride = gp->getVertexStride(); 305 size_t vertexStride = gp->getVertexStride();
302 306
303 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); 307 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr));
304 308
305 Geometry& args = fGeoData[0]; 309 Geometry& args = fGeoData[0];
306 310
307 int vertexCount = kVertsPerHairlineRect; 311 int vertexCount = kVertsPerHairlineRect;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 localMatrix); 557 localMatrix);
554 } 558 }
555 559
556 static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords, 560 static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
557 bool hasColors, 561 bool hasColors,
558 int* colorOffset, 562 int* colorOffset,
559 int* texOffset, 563 int* texOffset,
560 GrColor color, 564 GrColor color,
561 const SkMatrix& viewMatr ix, 565 const SkMatrix& viewMatr ix,
562 bool coverageIgnored) { 566 bool coverageIgnored) {
567 using namespace GrDefaultGeoProcFactory;
563 *texOffset = -1; 568 *texOffset = -1;
564 *colorOffset = -1; 569 *colorOffset = -1;
565 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; 570 Color gpColor(color);
571 if (hasColors) {
572 gpColor.fType = Color::kAttribute_Type;
573 }
574
575 Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_ Type);
576 LocalCoords localCoords(hasLocalCoords ? LocalCoords::kHasExplicit_Type :
577 LocalCoords::kUsePosition_Type);
566 if (hasLocalCoords && hasColors) { 578 if (hasLocalCoords && hasColors) {
567 *colorOffset = sizeof(SkPoint); 579 *colorOffset = sizeof(SkPoint);
568 *texOffset = sizeof(SkPoint) + sizeof(GrColor); 580 *texOffset = sizeof(SkPoint) + sizeof(GrColor);
569 flags |= GrDefaultGeoProcFactory::kColor_GPType |
570 GrDefaultGeoProcFactory::kLocalCoord_GPType;
571 } else if (hasLocalCoords) { 581 } else if (hasLocalCoords) {
572 *texOffset = sizeof(SkPoint); 582 *texOffset = sizeof(SkPoint);
573 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType;
574 } else if (hasColors) { 583 } else if (hasColors) {
575 *colorOffset = sizeof(SkPoint); 584 *colorOffset = sizeof(SkPoint);
576 flags |= GrDefaultGeoProcFactory::kColor_GPType;
577 } 585 }
578 return GrDefaultGeoProcFactory::Create(flags, color, hasLocalCoords, coverag eIgnored, 586 return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewM atrix);
579 viewMatrix, SkMatrix::I());
580 } 587 }
581 588
582 class DrawVerticesBatch : public GrBatch { 589 class DrawVerticesBatch : public GrBatch {
583 public: 590 public:
584 struct Geometry { 591 struct Geometry {
585 GrColor fColor; 592 GrColor fColor;
586 SkTDArray<SkPoint> fPositions; 593 SkTDArray<SkPoint> fPositions;
587 SkTDArray<uint16_t> fIndices; 594 SkTDArray<uint16_t> fIndices;
588 SkTDArray<GrColor> fColors; 595 SkTDArray<GrColor> fColors;
589 SkTDArray<SkPoint> fLocalCoords; 596 SkTDArray<SkPoint> fLocalCoords;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 return DrawVerticesBatch::Create(geometry, type, viewMatrix, 1334 return DrawVerticesBatch::Create(geometry, type, viewMatrix,
1328 positions.begin(), vertexCount, 1335 positions.begin(), vertexCount,
1329 indices.begin(), hasIndices ? vertexCount : 0, 1336 indices.begin(), hasIndices ? vertexCount : 0,
1330 colors.begin(), 1337 colors.begin(),
1331 texCoords.begin(), 1338 texCoords.begin(),
1332 bounds); 1339 bounds);
1333 } 1340 }
1334 1341
1335 #endif 1342 #endif
1336 1343
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698