Debian Codegraph @

src/gpu/ganesh/ops/GrOp.cpp

raw
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/core/SkTraceEvent.h"
9 #include "src/gpu/ganesh/ops/GrOp.h"
10
11 std::atomic<uint32_t> GrOp::gCurrOpClassID {GrOp::kIllegalOpID + 1};
12 std::atomic<uint32_t> GrOp::gCurrOpUniqueID{GrOp::kIllegalOpID + 1};
13
14 GrOp::GrOp(uint32_t classID) : fClassID(classID) {
15 SkASSERT(classID == SkToU32(fClassID));
16 SkASSERT(classID);
17 SkDEBUGCODE(fBoundsFlags = kUninitialized_BoundsFlag);
18 }
19
20 GrOp::CombineResult GrOp::combineIfPossible(GrOp* that, SkArenaAlloc* alloc, const GrCaps& caps) {
21 SkASSERT(this != that);
22 if (this->classID() != that->classID()) {
23 return CombineResult::kCannotCombine;
24 }
25 auto result = this->onCombineIfPossible(that, alloc, caps);
26 if (result == CombineResult::kMerged) {
27 this->joinBounds(*that);
28 }
29 return result;
30 }
31
32 void GrOp::chainConcat(GrOp::Owner next) {
33 SkASSERT(next);
34 SkASSERT(this->classID() == next->classID());
35 SkASSERT(this->isChainTail());
36 SkASSERT(next->isChainHead());
37 fNextInChain = std::move(next);
38 fNextInChain->fPrevInChain = this;
39 }
40
41 GrOp::Owner GrOp::cutChain() {
42 if (fNextInChain) {
43 fNextInChain->fPrevInChain = nullptr;
44 return std::move(fNextInChain);
45 }
46 return nullptr;
47 }
48
49 void GrOp::prePrepare(GrRecordingContext* context, const GrSurfaceProxyView& dstView,
50 GrAppliedClip* clip, const GrDstProxyView& dstProxyView,
51 GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp) {
52 TRACE_EVENT0_ALWAYS("skia.gpu", TRACE_STR_STATIC(name()));
53 this->onPrePrepare(context, dstView, clip, dstProxyView, renderPassXferBarriers,
54 colorLoadOp);
55 }
56
57 void GrOp::prepare(GrOpFlushState* state) {
58 TRACE_EVENT0_ALWAYS("skia.gpu", TRACE_STR_STATIC(name()));
59 this->onPrepare(state);
60 }
61
62 void GrOp::execute(GrOpFlushState* state, const SkRect& chainBounds) {
63 TRACE_EVENT0_ALWAYS("skia.gpu", TRACE_STR_STATIC(name()));
64 this->onExecute(state, chainBounds);
65 }
66
67 #ifdef SK_DEBUG
68 void GrOp::validateChain(GrOp* expectedTail) const {
69 SkASSERT(this->isChainHead());
70 uint32_t classID = this->classID();
71 const GrOp* op = this;
72 while (op) {
73 SkASSERT(op == this || (op->prevInChain() && op->prevInChain()->nextInChain() == op));
74 SkASSERT(classID == op->classID());
75 if (op->nextInChain()) {
76 SkASSERT(op->nextInChain()->prevInChain() == op);
77 SkASSERT(op != expectedTail);
78 } else {
79 SkASSERT(!expectedTail || op == expectedTail);
80 }
81 op = op->nextInChain();
82 }
83 }
84 #endif