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

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

Issue 1506823004: Remove drawPathsFromRange from GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: formatting Created 5 years 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/GrDrawPathBatch.h ('k') | src/gpu/batches/GrStencilAndCoverPathRenderer.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 "GrDrawPathBatch.h" 8 #include "GrDrawPathBatch.h"
9 9
10 SkString GrDrawPathBatch::dumpInfo() const { 10 SkString GrDrawPathBatch::dumpInfo() const {
(...skipping 24 matching lines...) Expand all
35 SkString string; 35 SkString string;
36 string.printf("RANGE: 0x%p COUNTS: [", *fDraws.head()); 36 string.printf("RANGE: 0x%p COUNTS: [", *fDraws.head());
37 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { 37 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) {
38 string.appendf("%d ,", (*iter.get())->count()); 38 string.appendf("%d ,", (*iter.get())->count());
39 } 39 }
40 string.remove(string.size() - 2, 2); 40 string.remove(string.size() - 2, 2);
41 string.append("]"); 41 string.append("]");
42 return string; 42 return string;
43 } 43 }
44 44
45 bool GrDrawPathRangeBatch::isWinding() const {
46 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa ce;
47 bool isWinding = kInvert_StencilOp != this->stencilSettings().passOp(pathFac e);
48 if (isWinding) {
49 // Double check that it is in fact winding.
50 SkASSERT(kIncClamp_StencilOp == this->stencilSettings().passOp(pathFace) );
51 SkASSERT(kIncClamp_StencilOp == this->stencilSettings().failOp(pathFace) );
52 SkASSERT(0x1 != this->stencilSettings().writeMask(pathFace));
53 SkASSERT(!this->stencilSettings().isTwoSided());
54 }
55 return isWinding;
56 }
57
58 GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkM atrix& localMatrix, 45 GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkM atrix& localMatrix,
59 GrColor color, GrPathRange* range, Gr PathRangeDraw* draw, 46 GrColor color, GrPathRendering::FillT ype fill,
47 GrPathRange* range, GrPathRangeDraw* draw,
60 const SkRect& bounds) 48 const SkRect& bounds)
61 : INHERITED(ClassID(), viewMatrix, color) 49 : INHERITED(ClassID(), viewMatrix, color, fill)
62 , fPathRange(range) 50 , fPathRange(range)
63 , fLocalMatrix(localMatrix) { 51 , fLocalMatrix(localMatrix) {
64 SkDEBUGCODE(draw->fUsedInBatch = true;) 52 SkDEBUGCODE(draw->fUsedInBatch = true;)
65 fDraws.addToHead(SkRef(draw)); 53 fDraws.addToHead(SkRef(draw));
66 fTotalPathCount = draw->count(); 54 fTotalPathCount = draw->count();
67 fBounds = bounds; 55 fBounds = bounds;
68 } 56 }
69 57
70 bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { 58 bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
71 GrDrawPathRangeBatch* that = t->cast<GrDrawPathRangeBatch>(); 59 GrDrawPathRangeBatch* that = t->cast<GrDrawPathRangeBatch>();
(...skipping 11 matching lines...) Expand all
83 !fLocalMatrix.cheapEqualTo(that->fLocalMatrix)) { 71 !fLocalMatrix.cheapEqualTo(that->fLocalMatrix)) {
84 return false; 72 return false;
85 } 73 }
86 // TODO: Check some other things here. (winding, opaque, pathProc color, vm, ...) 74 // TODO: Check some other things here. (winding, opaque, pathProc color, vm, ...)
87 // Try to combine this call with the previous DrawPaths. We do this by stenc iling all the 75 // Try to combine this call with the previous DrawPaths. We do this by stenc iling all the
88 // paths together and then covering them in a single pass. This is not equiv alent to two 76 // paths together and then covering them in a single pass. This is not equiv alent to two
89 // separate draw calls, so we can only do it if there is no blending (no ove rlap would also 77 // separate draw calls, so we can only do it if there is no blending (no ove rlap would also
90 // work). Note that it's also possible for overlapping paths to cancel each other's winding 78 // work). Note that it's also possible for overlapping paths to cancel each other's winding
91 // numbers, and we only partially account for this by not allowing even/odd paths to be 79 // numbers, and we only partially account for this by not allowing even/odd paths to be
92 // combined. (Glyphs in the same font tend to wind the same direction so it works out OK.) 80 // combined. (Glyphs in the same font tend to wind the same direction so it works out OK.)
93 if (!this->isWinding() || 81 if (GrPathRendering::kWinding_FillType != this->fillType() ||
94 this->stencilSettings() != that->stencilSettings() || 82 this->stencilSettings() != that->stencilSettings() ||
95 this->overrides().willColorBlendWithDst()) { 83 this->overrides().willColorBlendWithDst()) {
96 return false; 84 return false;
97 } 85 }
98 SkASSERT(!that->overrides().willColorBlendWithDst()); 86 SkASSERT(!that->overrides().willColorBlendWithDst());
99 fTotalPathCount += that->fTotalPathCount; 87 fTotalPathCount += that->fTotalPathCount;
100 while (GrPathRangeDraw** head = that->fDraws.head()) { 88 while (GrPathRangeDraw** head = that->fDraws.head()) {
101 fDraws.addToTail(*head); 89 fDraws.addToTail(*head);
102 // We're stealing that's refs, so pop without unreffing. 90 // We're stealing that's refs, so pop without unreffing.
103 that->fDraws.popHead(); 91 that->fDraws.popHead();
(...skipping 30 matching lines...) Expand all
134 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t)); 122 memcpy(indices, (*iter.get())->indices(), cnt * sizeof(uint16_t));
135 indices += cnt; 123 indices += cnt;
136 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform * sizeof(float)); 124 memcpy(transforms, (*iter.get())->transforms(), cnt * floatsPerTransform * sizeof(float));
137 transforms += cnt * floatsPerTransform; 125 transforms += cnt * floatsPerTransform;
138 } 126 }
139 SkASSERT(indices - indexStorage.get() == fTotalPathCount); 127 SkASSERT(indices - indexStorage.get() == fTotalPathCount);
140 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), indexStorag e.get(), 128 state->gpu()->pathRendering()->drawPaths(args, fPathRange.get(), indexStorag e.get(),
141 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType, 129 GrPathRange::kU16_PathIndexType, transformStorage.get(), transformType,
142 fTotalPathCount); 130 fTotalPathCount);
143 } 131 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawPathBatch.h ('k') | src/gpu/batches/GrStencilAndCoverPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698