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

Side by Side Diff: src/gpu/batches/GrNinePatch.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/GrMSAAPathRenderer.cpp ('k') | src/gpu/batches/GrNonAAFillRectBatch.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"
11 #include "GrDefaultGeoProcFactory.h" 11 #include "GrDefaultGeoProcFactory.h"
12 #include "GrResourceProvider.h" 12 #include "GrResourceProvider.h"
13 #include "GrVertexBatch.h" 13 #include "GrVertexBatch.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkNinePatchIter.h" 15 #include "SkNinePatchIter.h"
16 #include "SkRect.h" 16 #include "SkRect.h"
17 17
18 static const GrGeometryProcessor* create_gp(bool readsCoverage) { 18 static sk_sp<GrGeometryProcessor> create_gp(bool readsCoverage) {
19 using namespace GrDefaultGeoProcFactory; 19 using namespace GrDefaultGeoProcFactory;
20 Color color(Color::kAttribute_Type); 20 Color color(Color::kAttribute_Type);
21 Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Ty pe); 21 Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Ty pe);
22 LocalCoords localCoords(LocalCoords::kHasExplicit_Type); 22 LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
23 return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatri x::I()); 23 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix: :I());
24 } 24 }
25 25
26 class GrNonAANinePatchBatch : public GrVertexBatch { 26 class GrNonAANinePatchBatch : public GrVertexBatch {
27 public: 27 public:
28 DEFINE_BATCH_CLASS_ID 28 DEFINE_BATCH_CLASS_ID
29 29
30 static const int kVertsPerRect = 4; 30 static const int kVertsPerRect = 4;
31 static const int kIndicesPerRect = 6; 31 static const int kIndicesPerRect = 6;
32 static const int kRectsPerInstance = 9; // We could skip empty rects 32 static const int kRectsPerInstance = 9; // We could skip empty rects
33 33
(...skipping 44 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 } 82 }
83 83
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 sk_sp<GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage()));
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 size_t vertexStride = gp->getVertexStride(); 94 size_t vertexStride = gp->getVertexStride();
95 int instanceCount = fGeoData.count(); 95 int instanceCount = fGeoData.count();
96 96
97 SkAutoTUnref<const GrBuffer> indexBuffer( 97 SkAutoTUnref<const GrBuffer> indexBuffer(
98 target->resourceProvider()->refQuadIndexBuffer()); 98 target->resourceProvider()->refQuadIndexBuffer());
(...skipping 30 matching lines...) Expand all
129 129
130 static const int kColorOffset = sizeof(SkPoint); 130 static const int kColorOffset = sizeof(SkPoint);
131 GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOf fset); 131 GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOf fset);
132 for (int j = 0; j < 4; ++j) { 132 for (int j = 0; j < 4; ++j) {
133 *vertColor = geo.fColor; 133 *vertColor = geo.fColor;
134 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride) ; 134 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride) ;
135 } 135 }
136 verts += kVertsPerRect * vertexStride; 136 verts += kVertsPerRect * vertexStride;
137 } 137 }
138 } 138 }
139 helper.recordDraw(target, gp); 139 helper.recordDraw(target, gp.get());
140 } 140 }
141 141
142 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 142 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
143 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 143 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
144 fOverrides = overrides; 144 fOverrides = overrides;
145 } 145 }
146 146
147 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 147 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
148 GrNonAANinePatchBatch* that = t->cast<GrNonAANinePatchBatch>(); 148 GrNonAANinePatchBatch* that = t->cast<GrNonAANinePatchBatch>();
149 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
172 172
173 typedef GrVertexBatch INHERITED; 173 typedef GrVertexBatch INHERITED;
174 }; 174 };
175 175
176 namespace GrNinePatch { 176 namespace GrNinePatch {
177 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,
178 const SkIRect& center, const SkRect& dst) { 178 const SkIRect& center, const SkRect& dst) {
179 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst); 179 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst);
180 } 180 }
181 }; 181 };
OLDNEW
« no previous file with comments | « src/gpu/batches/GrMSAAPathRenderer.cpp ('k') | src/gpu/batches/GrNonAAFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698