Plumb sk_sp through the GrOpList class hierarchy
This is preparing the ground for having proxies be atomically reffed
Change-Id: Ice48c41120d4ec10a758f696a69028b6363e8a7e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207762
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/private/GrOpList.h b/include/private/GrOpList.h
index 72ef07e..14c58a6 100644
--- a/include/private/GrOpList.h
+++ b/include/private/GrOpList.h
@@ -30,7 +30,7 @@
class GrOpList : public SkRefCnt {
public:
- GrOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>, GrSurfaceProxy*, GrAuditTrail*);
+ GrOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>, sk_sp<GrSurfaceProxy>, GrAuditTrail*);
~GrOpList() override;
// These four methods are invoked at flush time
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 7904d75..3cd1e51 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -604,7 +604,7 @@
}
#endif
-sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(GrRenderTargetProxy* rtp,
+sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetProxy> rtp,
bool managedOpList) {
SkDEBUGCODE(this->validate());
SkASSERT(fContext);
@@ -654,7 +654,7 @@
return opList;
}
-sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(GrTextureProxy* textureProxy) {
+sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(sk_sp<GrTextureProxy> textureProxy) {
SkDEBUGCODE(this->validate());
SkASSERT(fContext);
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index d3b8ac1..c927983 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -46,12 +46,10 @@
bool managedOpList = true);
sk_sp<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>, sk_sp<SkColorSpace>);
- // The caller automatically gets a ref on the returned opList. It must
- // be balanced by an unref call.
// A managed opList is controlled by the drawing manager (i.e., sorted & flushed with the
- // other). An unmanaged one is created and used by the onFlushCallback.
- sk_sp<GrRenderTargetOpList> newRTOpList(GrRenderTargetProxy* rtp, bool managedOpList);
- sk_sp<GrTextureOpList> newTextureOpList(GrTextureProxy* textureProxy);
+ // others). An unmanaged one is created and used by the onFlushCallback.
+ sk_sp<GrRenderTargetOpList> newRTOpList(sk_sp<GrRenderTargetProxy>, bool managedOpList);
+ sk_sp<GrTextureOpList> newTextureOpList(sk_sp<GrTextureProxy>);
GrRecordingContext* getContext() { return fContext; }
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index 4c20a24..e2a4c5c 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -25,13 +25,13 @@
}
GrOpList::GrOpList(GrResourceProvider* resourceProvider, sk_sp<GrOpMemoryPool> opMemoryPool,
- GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail)
+ sk_sp<GrSurfaceProxy> surfaceProxy, GrAuditTrail* auditTrail)
: fOpMemoryPool(std::move(opMemoryPool))
, fAuditTrail(auditTrail)
, fUniqueID(CreateUniqueID())
, fFlags(0) {
SkASSERT(fOpMemoryPool);
- fTarget.setProxy(sk_ref_sp(surfaceProxy), kWrite_GrIOType);
+ fTarget.setProxy(std::move(surfaceProxy), kWrite_GrIOType);
fTarget.get()->setLastOpList(this);
if (resourceProvider && !resourceProvider->explicitlyAllocateGPUResources()) {
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 73368ff..a53dd84 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -238,7 +238,7 @@
SkDEBUGCODE(this->validate();)
if (!fOpList || fOpList->isClosed()) {
- fOpList = this->drawingManager()->newRTOpList(fRenderTargetProxy.get(), fManagedOpList);
+ fOpList = this->drawingManager()->newRTOpList(fRenderTargetProxy, fManagedOpList);
}
return fOpList.get();
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index f66fec9..96c8f25 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -350,9 +350,9 @@
GrRenderTargetOpList::GrRenderTargetOpList(GrResourceProvider* resourceProvider,
sk_sp<GrOpMemoryPool> opMemoryPool,
- GrRenderTargetProxy* proxy,
+ sk_sp<GrRenderTargetProxy> proxy,
GrAuditTrail* auditTrail)
- : INHERITED(resourceProvider, std::move(opMemoryPool), proxy, auditTrail)
+ : INHERITED(resourceProvider, std::move(opMemoryPool), std::move(proxy), auditTrail)
, fLastClipStackGenID(SK_InvalidUniqueID)
SkDEBUGCODE(, fNumClips(0)) {
}
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 44cc39f..e5442c1 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -34,7 +34,7 @@
public:
GrRenderTargetOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>,
- GrRenderTargetProxy*, GrAuditTrail*);
+ sk_sp<GrRenderTargetProxy>, GrAuditTrail*);
~GrRenderTargetOpList() override;
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index 0b396e1..fb0e124 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -58,7 +58,7 @@
SkDEBUGCODE(this->validate();)
if (!fOpList || fOpList->isClosed()) {
- fOpList = this->drawingManager()->newTextureOpList(fTextureProxy.get());
+ fOpList = this->drawingManager()->newTextureOpList(fTextureProxy);
}
return fOpList.get();
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
index 1b18c09..23bd58e 100644
--- a/src/gpu/GrTextureOpList.cpp
+++ b/src/gpu/GrTextureOpList.cpp
@@ -23,7 +23,7 @@
GrTextureOpList::GrTextureOpList(GrResourceProvider* resourceProvider,
sk_sp<GrOpMemoryPool> opMemoryPool,
- GrTextureProxy* proxy,
+ sk_sp<GrTextureProxy> proxy,
GrAuditTrail* auditTrail)
: INHERITED(resourceProvider, std::move(opMemoryPool), proxy, auditTrail) {
SkASSERT(fOpMemoryPool);
diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h
index 839b863..b162460 100644
--- a/src/gpu/GrTextureOpList.h
+++ b/src/gpu/GrTextureOpList.h
@@ -23,7 +23,8 @@
class GrTextureOpList final : public GrOpList {
public:
- GrTextureOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>, GrTextureProxy*, GrAuditTrail*);
+ GrTextureOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>,
+ sk_sp<GrTextureProxy>, GrAuditTrail*);
~GrTextureOpList() override;
/**
diff --git a/tests/OpChainTest.cpp b/tests/OpChainTest.cpp
index 27c7dbe..91f72b8 100644
--- a/tests/OpChainTest.cpp
+++ b/tests/OpChainTest.cpp
@@ -208,7 +208,7 @@
&tracker);
GrRenderTargetOpList opList(context->priv().resourceProvider(),
sk_ref_sp(context->priv().opMemoryPool()),
- proxy->asRenderTargetProxy(),
+ sk_ref_sp(proxy->asRenderTargetProxy()),
context->priv().auditTrail());
// This assumes the particular values of kRanges.
std::fill_n(result, result_width(), -1);