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

Side by Side Diff: src/gpu/batches/GrAAFillRectBatch.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 "GrAAFillRectBatch.h" 8 #include "GrAAFillRectBatch.h"
9 9
10 #include "GrColor.h" 10 #include "GrColor.h"
(...skipping 26 matching lines...) Expand all
37 2, 3, 7, 7, 6, 2, 37 2, 3, 7, 7, 6, 2,
38 3, 0, 4, 4, 7, 3, 38 3, 0, 4, 4, 7, 3,
39 4, 5, 6, 6, 7, 4, 39 4, 5, 6, 6, 7, 4,
40 }; 40 };
41 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect); 41 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect);
42 return resourceProvider->findOrCreateInstancedIndexBuffer(gFillAARectIdx, 42 return resourceProvider->findOrCreateInstancedIndexBuffer(gFillAARectIdx,
43 kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer, kVertsPerAAFillRect , 43 kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer, kVertsPerAAFillRect ,
44 gAAFillRectIndexBufferKey); 44 gAAFillRectIndexBufferKey);
45 } 45 }
46 46
47 static const GrGeometryProcessor* create_fill_rect_gp( 47 static sk_sp<GrGeometryProcessor> create_fill_rect_gp(
48 const SkMatrix& viewMatrix, 48 const SkMatrix& viewMatrix,
49 const GrXPOverridesForBatch& overrides, 49 const GrXPOverridesForBatch& overrides,
50 GrDefaultGeoProcFactory::LocalCoords::Typ e localCoordsType) { 50 GrDefaultGeoProcFactory::LocalCoords::Typ e localCoordsType) {
51 using namespace GrDefaultGeoProcFactory; 51 using namespace GrDefaultGeoProcFactory;
52 52
53 Color color(Color::kAttribute_Type); 53 Color color(Color::kAttribute_Type);
54 Coverage::Type coverageType; 54 Coverage::Type coverageType;
55 // TODO remove coverage if coverage is ignored 55 // TODO remove coverage if coverage is ignored
56 /*if (coverageIgnored) { 56 /*if (coverageIgnored) {
57 coverageType = Coverage::kNone_Type; 57 coverageType = Coverage::kNone_Type;
58 } else*/ if (overrides.canTweakAlphaForCoverage()) { 58 } else*/ if (overrides.canTweakAlphaForCoverage()) {
59 coverageType = Coverage::kSolid_Type; 59 coverageType = Coverage::kSolid_Type;
60 } else { 60 } else {
61 coverageType = Coverage::kAttribute_Type; 61 coverageType = Coverage::kAttribute_Type;
62 } 62 }
63 Coverage coverage(coverageType); 63 Coverage coverage(coverageType);
64 64
65 // We assume the caller has inverted the viewmatrix 65 // We assume the caller has inverted the viewmatrix
66 if (LocalCoords::kHasExplicit_Type == localCoordsType) { 66 if (LocalCoords::kHasExplicit_Type == localCoordsType) {
67 LocalCoords localCoords(localCoordsType); 67 LocalCoords localCoords(localCoordsType);
68 return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkM atrix::I()); 68 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMat rix::I());
69 } else { 69 } else {
70 LocalCoords localCoords(overrides.readsLocalCoords() ? localCoordsType : 70 LocalCoords localCoords(overrides.readsLocalCoords() ? localCoordsType :
71 LocalCoords::kUnu sed_Type); 71 LocalCoords::kUnu sed_Type);
72 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); 72 return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
73 } 73 }
74 } 74 }
75 75
76 static void generate_aa_fill_rect_geometry(intptr_t verts, 76 static void generate_aa_fill_rect_geometry(intptr_t verts,
77 size_t vertexStride, 77 size_t vertexStride,
78 GrColor color, 78 GrColor color,
79 const SkMatrix& viewMatrix, 79 const SkMatrix& viewMatrix,
80 const SkRect& rect, 80 const SkRect& rect,
81 const SkRect& devRect, 81 const SkRect& devRect,
82 const GrXPOverridesForBatch& override s, 82 const GrXPOverridesForBatch& override s,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 static bool CanCombine(const Geometry& mine, const Geometry& theirs, 234 static bool CanCombine(const Geometry& mine, const Geometry& theirs,
235 const GrXPOverridesForBatch& overrides) { 235 const GrXPOverridesForBatch& overrides) {
236 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses 236 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses
237 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix 237 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix
238 // using vertex attributes in these cases, but haven't investigated that 238 // using vertex attributes in these cases, but haven't investigated that
239 return !overrides.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(th eirs.fViewMatrix); 239 return !overrides.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(th eirs.fViewMatrix);
240 } 240 }
241 241
242 static const GrGeometryProcessor* CreateGP(const Geometry& geo, 242 static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
243 const GrXPOverridesForBatch& over rides) { 243 const GrXPOverridesForBatch& over rides) {
244 const GrGeometryProcessor* gp = 244 sk_sp<GrGeometryProcessor> gp =
245 create_fill_rect_gp(geo.fViewMatrix, overrides, 245 create_fill_rect_gp(geo.fViewMatrix, overrides,
246 GrDefaultGeoProcFactory::LocalCoords::kUsePo sition_Type); 246 GrDefaultGeoProcFactory::LocalCoords::kUsePo sition_Type);
247 247
248 SkASSERT(overrides.canTweakAlphaForCoverage() ? 248 SkASSERT(overrides.canTweakAlphaForCoverage() ?
249 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::Positi onColorAttr) : 249 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::Positi onColorAttr) :
250 gp->getVertexStride() == 250 gp->getVertexStride() ==
251 sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAt tr)); 251 sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAt tr));
252 return gp; 252 return gp;
253 } 253 }
254 254
(...skipping 24 matching lines...) Expand all
279 geo.fColor, 279 geo.fColor,
280 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect .fBottom); 280 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect .fBottom);
281 return str; 281 return str;
282 } 282 }
283 283
284 static bool CanCombine(const Geometry& mine, const Geometry& theirs, 284 static bool CanCombine(const Geometry& mine, const Geometry& theirs,
285 const GrXPOverridesForBatch& overrides) { 285 const GrXPOverridesForBatch& overrides) {
286 return true; 286 return true;
287 } 287 }
288 288
289 static const GrGeometryProcessor* CreateGP(const Geometry& geo, 289 static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
290 const GrXPOverridesForBatch& over rides) { 290 const GrXPOverridesForBatch& over rides) {
291 const GrGeometryProcessor* gp = 291 sk_sp<GrGeometryProcessor> gp =
292 create_fill_rect_gp(geo.fViewMatrix, overrides, 292 create_fill_rect_gp(geo.fViewMatrix, overrides,
293 GrDefaultGeoProcFactory::LocalCoords::kHasEx plicit_Type); 293 GrDefaultGeoProcFactory::LocalCoords::kHasEx plicit_Type);
294 294
295 SkASSERT(overrides.canTweakAlphaForCoverage() ? 295 SkASSERT(overrides.canTweakAlphaForCoverage() ?
296 gp->getVertexStride() == 296 gp->getVertexStride() ==
297 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Attr) : 297 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Attr) :
298 gp->getVertexStride() == 298 gp->getVertexStride() ==
299 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Coverage)); 299 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Coverage));
300 return gp; 300 return gp;
301 } 301 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 417 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
418 GrColor color = GrRandomColor(random); 418 GrColor color = GrRandomColor(random);
419 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 419 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
420 SkMatrix localMatrix = GrTest::TestMatrix(random); 420 SkMatrix localMatrix = GrTest::TestMatrix(random);
421 SkRect rect = GrTest::TestRect(random); 421 SkRect rect = GrTest::TestRect(random);
422 SkRect devRect = GrTest::TestRect(random); 422 SkRect devRect = GrTest::TestRect(random);
423 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct); 423 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct);
424 } 424 }
425 425
426 #endif 426 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAADistanceFieldPathRenderer.cpp ('k') | src/gpu/batches/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698