Revert "Revert "Remove GrPipeline from GrDrawOp.""
This reverts commit c48af934608bbb65650641f66adb51f2102d4274.
Change-Id: I4ba78fd7e5a7d406b88223ca6f7245c029b60f76
Reviewed-on: https://skia-review.googlesource.com/9981
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index ab744f3..c44c341 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -8,9 +8,11 @@
#ifndef GrRenderTargetOpList_DEFINED
#define GrRenderTargetOpList_DEFINED
+#include "GrAppliedClip.h"
#include "GrOpList.h"
-#include "GrPrimitiveProcessor.h"
#include "GrPathRendering.h"
+#include "GrPrimitiveProcessor.h"
+#include "SkArenaAlloc.h"
#include "SkClipStack.h"
#include "SkMatrix.h"
#include "SkStringUtils.h"
@@ -22,12 +24,14 @@
class GrAuditTrail;
class GrClearOp;
class GrCaps;
-class GrClip;
class GrOp;
class GrPipelineBuilder;
class GrRenderTargetProxy;
class GrRenderTargetOpList final : public GrOpList {
+private:
+ using DstTexture = GrXferProcessor::DstTexture;
+
public:
/** Options for GrRenderTargetOpList behavior. */
struct Options {
@@ -68,7 +72,13 @@
const GrCaps* caps() const { return fGpu->caps(); }
uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) {
- this->recordOp(std::move(op), renderTargetContext);
+ this->recordOp(std::move(op), renderTargetContext, nullptr, nullptr);
+ return this->uniqueID();
+ }
+ uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext,
+ GrAppliedClip&& clip, const DstTexture& dstTexture) {
+ this->recordOp(std::move(op), renderTargetContext, clip.doesClip() ? &clip : nullptr,
+ &dstTexture);
return this->uniqueID();
}
@@ -107,23 +117,34 @@
private:
friend class GrRenderTargetContextPriv; // for clearStencilClip and stencil clip state.
+ struct RecordedOp {
+ RecordedOp(std::unique_ptr<GrOp> op, GrRenderTarget* rt, const GrAppliedClip* appliedClip,
+ const DstTexture* dstTexture)
+ : fOp(std::move(op)), fRenderTarget(rt), fAppliedClip(appliedClip) {
+ if (dstTexture) {
+ fDstTexture = *dstTexture;
+ }
+ }
+ std::unique_ptr<GrOp> fOp;
+ // TODO: These ops will all to target the same render target and this won't be needed.
+ GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
+ DstTexture fDstTexture;
+ const GrAppliedClip* fAppliedClip;
+ };
+
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
// returns the input op.
- GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*);
+ GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, GrAppliedClip* = nullptr,
+ const DstTexture* = nullptr);
void forwardCombine();
// Used only via GrRenderTargetContextPriv.
void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTargetContext*);
- struct RecordedOp {
- RecordedOp(std::unique_ptr<GrOp> op, GrRenderTarget* rt)
- : fOp(std::move(op)), fRenderTarget(rt) {}
- std::unique_ptr<GrOp> fOp;
- // TODO: These ops will all to target the same render target and this won't be needed.
- GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
- };
- SkSTArray<256, RecordedOp, true> fRecordedOps;
+ // If this returns true then b has been merged into a's op.
+ bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip,
+ const DstTexture* bDstTexture);
GrClearOp* fLastFullClearOp = nullptr;
GrGpuResource::UniqueID fLastFullClearRenderTargetID = GrGpuResource::UniqueID::InvalidID();
@@ -139,6 +160,11 @@
int32_t fLastClipStackGenID;
SkIRect fLastDevClipBounds;
+ SkSTArray<256, RecordedOp, true> fRecordedOps;
+
+ char fClipAllocatorStorage[4096];
+ SkArenaAlloc fClipAllocator;
+
typedef GrOpList INHERITED;
};