Skip to content

Commit 641ac7d

Browse files
bsalomonSkia Commit-Bot
authored and
Skia Commit-Bot
committed
Make result of GrOp::combineIfPossible be an enum.
This is to prepare for a third value that requests that ops be linked together so that the first op may do the work for multiple linked ops without actually merging the GrOp objects. Change-Id: Ib6e012a89be5edd054aee69d8475bea612331852 Reviewed-on: https://skia-review.googlesource.com/145522 Commit-Queue: Brian Salomon <[email protected]> Reviewed-by: Brian Osman <[email protected]> Auto-Submit: Brian Salomon <[email protected]>
1 parent 986f64c commit 641ac7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+166
-189
lines changed

bench/VertexColorSpaceBench.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ class Op : public GrMeshDrawOp {
152152
private:
153153
friend class ::GrOpMemoryPool;
154154

155-
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
156-
157155
void onPrepareDraws(Target* target) override {
158156
sk_sp<GrGeometryProcessor> gp(new GP(fMode, fColorSpaceXform));
159157

gm/beziereffects.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ class BezierTestOp : public GrMeshDrawOp {
6060
GrColor color() const { return fColor; }
6161

6262
private:
63-
bool onCombineIfPossible(GrOp* op, const GrCaps& caps) override { return false; }
64-
6563
SkRect fRect;
6664
GrColor fColor;
6765
sk_sp<const GrGeometryProcessor> fGeometryProcessor;

gm/clockwise.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ class ClockwiseTestOp : public GrDrawOp {
108108
RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override {
109109
return RequiresDstTexture::kNo;
110110
}
111-
bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override { return false; }
112111
void onPrepare(GrOpFlushState*) override {}
113112
void onExecute(GrOpFlushState* flushState) override {
114113
SkPoint vertices[4] = {

gm/convexpolyeffect.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class PolyBoundsOp : public GrMeshDrawOp {
9999
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
100100
}
101101

102-
bool onCombineIfPossible(GrOp* op, const GrCaps& caps) override { return false; }
103-
104102
GrColor fColor;
105103
GrProcessorSet fProcessors;
106104
SkRect fRect;

samplecode/SampleCCPRGeometry.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class CCPRGeometryView::DrawCoverageCountOp : public GrDrawOp {
8989
RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override {
9090
return RequiresDstTexture::kNo;
9191
}
92-
bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override { return false; }
9392
void onPrepare(GrOpFlushState*) override {}
9493
void onExecute(GrOpFlushState*) override;
9594

src/atlastext/SkAtlasTextTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptr<Gr
181181
int n = SkTMin(kMaxBatchLookBack, fOps.count());
182182
for (int i = 0; i < n; ++i) {
183183
GrAtlasTextOp* other = fOps.fromBack(i).get();
184-
if (other->combineIfPossible(op.get(), caps)) {
184+
if (other->combineIfPossible(op.get(), caps) == GrOp::CombineResult::kMerged) {
185185
fOpMemoryPool->release(std::move(op));
186186
return;
187187
}

src/gpu/GrRenderTargetOpList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
339339
} else if (a.fDstProxy.proxy()) {
340340
return false;
341341
}
342-
return a.fOp->combineIfPossible(b, caps);
342+
return a.fOp->combineIfPossible(b, caps) == GrOp::CombineResult::kMerged;
343343
}
344344

345345
uint32_t GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,

src/gpu/ccpr/GrCCDrawPathsOp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ GrDrawOp::RequiresDstTexture GrCCDrawPathsOp::finalize(const GrCaps& caps,
117117
return RequiresDstTexture(analysis.requiresDstTexture());
118118
}
119119

120-
bool GrCCDrawPathsOp::onCombineIfPossible(GrOp* op, const GrCaps&) {
120+
GrOp::CombineResult GrCCDrawPathsOp::onCombineIfPossible(GrOp* op, const GrCaps&) {
121121
GrCCDrawPathsOp* that = op->cast<GrCCDrawPathsOp>();
122122
SkASSERT(fOwningPerOpListPaths);
123123
SkASSERT(fNumDraws);
@@ -126,15 +126,15 @@ bool GrCCDrawPathsOp::onCombineIfPossible(GrOp* op, const GrCaps&) {
126126

127127
if (fProcessors != that->fProcessors ||
128128
fViewMatrixIfUsingLocalCoords != that->fViewMatrixIfUsingLocalCoords) {
129-
return false;
129+
return CombineResult::kCannotCombine;
130130
}
131131

132132
fDraws.append(std::move(that->fDraws), &fOwningPerOpListPaths->fAllocator);
133133
this->joinBounds(*that);
134134

135135
SkDEBUGCODE(fNumDraws += that->fNumDraws);
136136
SkDEBUGCODE(that->fNumDraws = 0);
137-
return true;
137+
return CombineResult::kMerged;
138138
}
139139

140140
void GrCCDrawPathsOp::wasRecorded(GrCCPerOpListPaths* owningPerOpListPaths) {

src/gpu/ccpr/GrCCDrawPathsOp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class GrCCDrawPathsOp : public GrDrawOp {
3737
const char* name() const override { return "GrCCDrawPathsOp"; }
3838
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
3939
RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override;
40-
bool onCombineIfPossible(GrOp*, const GrCaps&) override;
40+
CombineResult onCombineIfPossible(GrOp*, const GrCaps&) override;
4141
void visitProxies(const VisitProxyFunc& fn) const override { fProcessors.visitProxies(fn); }
4242
void onPrepare(GrOpFlushState*) override {}
4343

src/gpu/ccpr/GrCCPerFlushResources.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class AtlasOp : public GrDrawOp {
2727
RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override {
2828
return RequiresDstTexture::kNo;
2929
}
30-
bool onCombineIfPossible(GrOp* other, const GrCaps&) override {
30+
CombineResult onCombineIfPossible(GrOp* other, const GrCaps&) override {
3131
SK_ABORT("Only expected one Op per CCPR atlas.");
32-
return true;
32+
return CombineResult::kMerged;
3333
}
3434
void onPrepare(GrOpFlushState*) override {}
3535

src/gpu/ops/GrAAConvexPathRenderer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -943,23 +943,23 @@ class AAConvexPathOp final : public GrMeshDrawOp {
943943
}
944944
}
945945

946-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
946+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
947947
AAConvexPathOp* that = t->cast<AAConvexPathOp>();
948948
if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) {
949-
return false;
949+
return CombineResult::kCannotCombine;
950950
}
951951
if (fHelper.usesLocalCoords() &&
952952
!fPaths[0].fViewMatrix.cheapEqualTo(that->fPaths[0].fViewMatrix)) {
953-
return false;
953+
return CombineResult::kCannotCombine;
954954
}
955955

956956
if (fLinesOnly != that->fLinesOnly) {
957-
return false;
957+
return CombineResult::kCannotCombine;
958958
}
959959

960960
fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin());
961961
this->joinBounds(*that);
962-
return true;
962+
return CombineResult::kMerged;
963963
}
964964

965965
struct PathData {

src/gpu/ops/GrAAFillRectOp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,16 @@ class AAFillRectOp final : public GrMeshDrawOp {
294294
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
295295
}
296296

297-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
297+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
298298
AAFillRectOp* that = t->cast<AAFillRectOp>();
299299
if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) {
300-
return false;
300+
return CombineResult::kCannotCombine;
301301
}
302302

303303
fRectData.push_back_n(that->fRectData.count(), that->fRectData.begin());
304304
fRectCnt += that->fRectCnt;
305305
this->joinBounds(*that);
306-
return true;
306+
return CombineResult::kMerged;
307307
}
308308

309309
struct RectInfo {

src/gpu/ops/GrAAHairLinePathRenderer.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -835,41 +835,41 @@ class AAHairlineOp final : public GrMeshDrawOp {
835835
typedef SkTArray<int, true> IntArray;
836836
typedef SkTArray<float, true> FloatArray;
837837

838-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
838+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
839839
AAHairlineOp* that = t->cast<AAHairlineOp>();
840840

841841
if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) {
842-
return false;
842+
return CombineResult::kCannotCombine;
843843
}
844844

845845
if (this->viewMatrix().hasPerspective() != that->viewMatrix().hasPerspective()) {
846-
return false;
846+
return CombineResult::kCannotCombine;
847847
}
848848

849849
// We go to identity if we don't have perspective
850850
if (this->viewMatrix().hasPerspective() &&
851851
!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
852-
return false;
852+
return CombineResult::kCannotCombine;
853853
}
854854

855855
// TODO we can actually combine hairlines if they are the same color in a kind of bulk
856856
// method but we haven't implemented this yet
857857
// TODO investigate going to vertex color and coverage?
858858
if (this->coverage() != that->coverage()) {
859-
return false;
859+
return CombineResult::kCannotCombine;
860860
}
861861

862862
if (this->color() != that->color()) {
863-
return false;
863+
return CombineResult::kCannotCombine;
864864
}
865865

866866
if (fHelper.usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
867-
return false;
867+
return CombineResult::kCannotCombine;
868868
}
869869

870870
fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin());
871871
this->joinBounds(*that);
872-
return true;
872+
return CombineResult::kMerged;
873873
}
874874

875875
GrColor color() const { return fColor; }

src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ class AAFlatteningConvexPathOp final : public GrMeshDrawOp {
318318
sk_free(indices);
319319
}
320320

321-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
321+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
322322
AAFlatteningConvexPathOp* that = t->cast<AAFlatteningConvexPathOp>();
323323
if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) {
324-
return false;
324+
return CombineResult::kCannotCombine;
325325
}
326326

327327
fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin());
328328
this->joinBounds(*that);
329-
return true;
329+
return CombineResult::kMerged;
330330
}
331331

332332
const SkMatrix& viewMatrix() const { return fPaths[0].fViewMatrix; }

src/gpu/ops/GrAAStrokeRectOp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class AAStrokeRectOp final : public GrMeshDrawOp {
227227
const SkMatrix& viewMatrix() const { return fViewMatrix; }
228228
bool miterStroke() const { return fMiterStroke; }
229229

230-
bool onCombineIfPossible(GrOp* t, const GrCaps&) override;
230+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps&) override;
231231

232232
void generateAAStrokeRectGeometry(void* vertices,
233233
size_t offset,
@@ -405,27 +405,27 @@ sk_sp<const GrBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourc
405405
}
406406
}
407407

408-
bool AAStrokeRectOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
408+
GrOp::CombineResult AAStrokeRectOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
409409
AAStrokeRectOp* that = t->cast<AAStrokeRectOp>();
410410

411411
if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) {
412-
return false;
412+
return CombineResult::kCannotCombine;
413413
}
414414

415415
// TODO combine across miterstroke changes
416416
if (this->miterStroke() != that->miterStroke()) {
417-
return false;
417+
return CombineResult::kCannotCombine;
418418
}
419419

420420
// We apply the viewmatrix to the rect points on the cpu. However, if the pipeline uses
421421
// local coords then we won't be able to combine. TODO: Upload local coords as an attribute.
422422
if (fHelper.usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
423-
return false;
423+
return CombineResult::kCannotCombine;
424424
}
425425

426426
fRects.push_back_n(that->fRects.count(), that->fRects.begin());
427427
this->joinBounds(*that);
428-
return true;
428+
return CombineResult::kMerged;
429429
}
430430

431431
static void setup_scale(int* scale, SkScalar inset) {

src/gpu/ops/GrAtlasTextOp.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,57 +437,56 @@ void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) co
437437
flushInfo->fGlyphsToFlush = 0;
438438
}
439439

440-
bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
440+
GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
441441
GrAtlasTextOp* that = t->cast<GrAtlasTextOp>();
442442
if (fProcessors != that->fProcessors) {
443-
return false;
443+
return CombineResult::kCannotCombine;
444444
}
445445

446446
if (!fCanCombineOnTouchOrOverlap && GrRectsTouchOrOverlap(this->bounds(), that->bounds())) {
447-
return false;
447+
return CombineResult::kCannotCombine;
448448
}
449449

450450
if (fMaskType != that->fMaskType) {
451-
return false;
451+
return CombineResult::kCannotCombine;
452452
}
453453

454454
const SkMatrix& thisFirstMatrix = fGeoData[0].fViewMatrix;
455455
const SkMatrix& thatFirstMatrix = that->fGeoData[0].fViewMatrix;
456456

457457
if (this->usesLocalCoords() && !thisFirstMatrix.cheapEqualTo(thatFirstMatrix)) {
458-
return false;
458+
return CombineResult::kCannotCombine;
459459
}
460460

461461
if (fNeedsGlyphTransform != that->fNeedsGlyphTransform) {
462-
return false;
462+
return CombineResult::kCannotCombine;
463463
}
464464

465465
if (fNeedsGlyphTransform &&
466466
(thisFirstMatrix.hasPerspective() != thatFirstMatrix.hasPerspective())) {
467-
return false;
467+
return CombineResult::kCannotCombine;
468468
}
469469

470470
if (this->usesDistanceFields()) {
471471
if (fDFGPFlags != that->fDFGPFlags) {
472-
return false;
472+
return CombineResult::kCannotCombine;
473473
}
474474

475475
if (fLuminanceColor != that->fLuminanceColor) {
476-
return false;
476+
return CombineResult::kCannotCombine;
477477
}
478478
} else {
479479
if (kColorBitmapMask_MaskType == fMaskType && this->color() != that->color()) {
480-
return false;
480+
return CombineResult::kCannotCombine;
481481
}
482-
483482
}
484483

485484
// Keep the batch vertex buffer size below 32K so we don't have to create a special one
486485
// We use the largest possible vertex size for this
487486
static const int kVertexSize = sizeof(SkPoint) + sizeof(SkColor) + 2 * sizeof(uint16_t);
488487
static const int kMaxGlyphs = 32768 / (kVerticesPerGlyph * kVertexSize);
489488
if (this->fNumGlyphs + that->fNumGlyphs > kMaxGlyphs) {
490-
return false;
489+
return CombineResult::kCannotCombine;
491490
}
492491

493492
fNumGlyphs += that->numGlyphs();
@@ -517,7 +516,7 @@ bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
517516
fGeoCount = newGeoCount;
518517

519518
this->joinBounds(*that);
520-
return true;
519+
return CombineResult::kMerged;
521520
}
522521

523522
// TODO trying to figure out why lcd is so whack

src/gpu/ops/GrAtlasTextOp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class GrAtlasTextOp final : public GrMeshDrawOp {
149149
bool usesLocalCoords() const { return fUsesLocalCoords; }
150150
int numGlyphs() const { return fNumGlyphs; }
151151

152-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
152+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
153153

154154
sk_sp<GrGeometryProcessor> setupDfProcessor(const sk_sp<GrTextureProxy>* proxies,
155155
unsigned int numActiveProxies) const;

src/gpu/ops/GrClearOp.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,23 @@ class GrClearOp final : public GrOp {
6262
this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsZeroArea::kNo);
6363
}
6464

65-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
65+
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
6666
// This could be much more complicated. Currently we look at cases where the new clear
6767
// contains the old clear, or when the new clear is a subset of the old clear and is the
6868
// same color.
6969
GrClearOp* cb = t->cast<GrClearOp>();
7070
if (fClip.windowRectsState() != cb->fClip.windowRectsState()) {
71-
return false;
71+
return CombineResult::kCannotCombine;
7272
}
7373
if (cb->contains(this)) {
7474
fClip = cb->fClip;
7575
this->replaceBounds(*t);
7676
fColor = cb->fColor;
77-
return true;
77+
return CombineResult::kMerged;
7878
} else if (cb->fColor == fColor && this->contains(cb)) {
79-
return true;
79+
return CombineResult::kMerged;
8080
}
81-
return false;
81+
return CombineResult::kCannotCombine;
8282
}
8383

8484
bool contains(const GrClearOp* that) const {

src/gpu/ops/GrClearStencilClipOp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class GrClearStencilClipOp final : public GrOp {
5252
this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
5353
}
5454

55-
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
56-
5755
void onPrepare(GrOpFlushState*) override {}
5856

5957
void onExecute(GrOpFlushState* state) override;

0 commit comments

Comments
 (0)