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

Side by Side Diff: src/gpu/batches/GrNonAAStrokeRectBatch.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
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 "GrNonAAStrokeRectBatch.h" 8 #include "GrNonAAStrokeRectBatch.h"
9 9
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bounds->outset(rad, rad); 98 bounds->outset(rad, rad);
99 geo.fViewMatrix.mapRect(&fBounds); 99 geo.fViewMatrix.mapRect(&fBounds);
100 100
101 // If our caller snaps to pixel centers then we have to round out the bo unds 101 // If our caller snaps to pixel centers then we have to round out the bo unds
102 if (snapToPixelCenters) { 102 if (snapToPixelCenters) {
103 bounds->roundOut(); 103 bounds->roundOut();
104 } 104 }
105 } 105 }
106 106
107 void onPrepareDraws(Target* target) const override { 107 void onPrepareDraws(Target* target) const override {
108 SkAutoTUnref<const GrGeometryProcessor> gp; 108 sk_sp<GrGeometryProcessor> gp;
109 { 109 {
110 using namespace GrDefaultGeoProcFactory; 110 using namespace GrDefaultGeoProcFactory;
111 Color color(this->color()); 111 Color color(this->color());
112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : 112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type :
113 Coverage::kNone_Type); 113 Coverage::kNone_Type);
114 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type : 114 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type :
115 LocalCoords::kUnus ed_Type); 115 LocalCoords::kUnus ed_Type);
116 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s, 116 gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, thi s->viewMatrix());
117 this->viewMatrix()));
118 } 117 }
119 118
120 size_t vertexStride = gp->getVertexStride(); 119 size_t vertexStride = gp->getVertexStride();
121 120
122 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); 121 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr));
123 122
124 const Geometry& args = fGeoData[0]; 123 const Geometry& args = fGeoData[0];
125 124
126 int vertexCount = kVertsPerHairlineRect; 125 int vertexCount = kVertsPerHairlineRect;
127 if (args.fStrokeWidth > 0) { 126 if (args.fStrokeWidth > 0) {
(...skipping 22 matching lines...) Expand all
150 primType = kLineStrip_GrPrimitiveType; 149 primType = kLineStrip_GrPrimitiveType;
151 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); 150 vertex[0].set(args.fRect.fLeft, args.fRect.fTop);
152 vertex[1].set(args.fRect.fRight, args.fRect.fTop); 151 vertex[1].set(args.fRect.fRight, args.fRect.fTop);
153 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); 152 vertex[2].set(args.fRect.fRight, args.fRect.fBottom);
154 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); 153 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom);
155 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); 154 vertex[4].set(args.fRect.fLeft, args.fRect.fTop);
156 } 155 }
157 156
158 GrMesh mesh; 157 GrMesh mesh;
159 mesh.init(primType, vertexBuffer, firstVertex, vertexCount); 158 mesh.init(primType, vertexBuffer, firstVertex, vertexCount);
160 target->draw(gp, mesh); 159 target->draw(gp.get(), mesh);
161 } 160 }
162 161
163 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 162 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
164 // Handle any color overrides 163 // Handle any color overrides
165 if (!overrides.readsColor()) { 164 if (!overrides.readsColor()) {
166 fGeoData[0].fColor = GrColor_ILLEGAL; 165 fGeoData[0].fColor = GrColor_ILLEGAL;
167 } 166 }
168 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 167 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
169 168
170 // setup batch properties 169 // setup batch properties
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) { 241 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) {
243 SkMatrix viewMatrix = GrTest::TestMatrix(random); 242 SkMatrix viewMatrix = GrTest::TestMatrix(random);
244 GrColor color = GrRandomColor(random); 243 GrColor color = GrRandomColor(random);
245 SkRect rect = GrTest::TestRect(random); 244 SkRect rect = GrTest::TestRect(random);
246 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f; 245 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f;
247 246
248 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool()); 247 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool());
249 } 248 }
250 249
251 #endif 250 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNonAAFillRectBatch.cpp ('k') | src/gpu/batches/GrStencilAndCoverPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698