Move auditTrail and opMemoryPool from GrContext to GrRecordingContext
Any context that records ops (i.e., direct and/or DDL) will need these two objects.
Change-Id: Ifd3527c23a4015f7d469ad2222563508cccbd339
Reviewed-on: https://skia-review.googlesource.com/c/190307
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index 5dbbe30..d9d969c 100644
--- a/src/gpu/GrContextPriv.cpp
+++ b/src/gpu/GrContextPriv.cpp
@@ -40,19 +40,7 @@
}
sk_sp<GrOpMemoryPool> GrContextPriv::refOpMemoryPool() {
- if (!fContext->fOpMemoryPool) {
- // DDL TODO: should the size of the memory pool be decreased in DDL mode? CPU-side memory
- // consumed in DDL mode vs. normal mode for a single skp might be a good metric of wasted
- // memory.
- fContext->fOpMemoryPool = sk_sp<GrOpMemoryPool>(new GrOpMemoryPool(16384, 16384));
- }
-
- SkASSERT(fContext->fOpMemoryPool);
- return fContext->fOpMemoryPool;
-}
-
-GrOpMemoryPool* GrContextPriv::opMemoryPool() {
- return this->refOpMemoryPool().get();
+ return fContext->refOpMemoryPool();
}
sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy,
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 9db268b..982656e 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -53,15 +53,16 @@
SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
// from GrRecordingContext
+ sk_sp<GrOpMemoryPool> refOpMemoryPool();
+ GrOpMemoryPool* opMemoryPool() { return fContext->opMemoryPool(); }
+
+ GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
/**
* Create a GrContext without a resource cache
*/
static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&);
- sk_sp<GrOpMemoryPool> refOpMemoryPool();
- GrOpMemoryPool* opMemoryPool();
-
GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); }
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
@@ -264,8 +265,6 @@
const SkSurfaceProps* surfaceProps = nullptr,
SkBudgeted budgeted = SkBudgeted::kYes);
- GrAuditTrail* getAuditTrail() { return &fContext->fAuditTrail; }
-
GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; }
#ifdef SK_ENABLE_DUMP_GPU
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 29c72d1..f63c7e8 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -598,7 +598,7 @@
resourceProvider,
fContext->priv().refOpMemoryPool(),
rtp,
- fContext->priv().getAuditTrail()));
+ fContext->priv().auditTrail()));
SkASSERT(rtp->getLastOpList() == opList.get());
if (managedOpList) {
@@ -638,7 +638,7 @@
sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->priv().resourceProvider(),
fContext->priv().refOpMemoryPool(),
textureProxy,
- fContext->priv().getAuditTrail()));
+ fContext->priv().auditTrail()));
SkASSERT(textureProxy->getLastOpList() == opList.get());
@@ -731,7 +731,7 @@
fContext, this, std::move(rtp),
std::move(colorSpace),
surfaceProps,
- fContext->priv().getAuditTrail(),
+ fContext->priv().auditTrail(),
fSingleOwner, managedOpList));
}
@@ -755,6 +755,6 @@
return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy),
std::move(colorSpace),
- fContext->priv().getAuditTrail(),
+ fContext->priv().auditTrail(),
fSingleOwner));
}
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index 1067950..6edfd65 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -8,6 +8,7 @@
#include "GrRecordingContext.h"
#include "GrCaps.h"
+#include "GrMemoryPool.h"
#include "GrRecordingContextPriv.h"
#include "GrSkSLFPFactoryCache.h"
@@ -19,6 +20,23 @@
GrRecordingContext::~GrRecordingContext() { }
+sk_sp<GrOpMemoryPool> GrRecordingContext::refOpMemoryPool() {
+ if (!fOpMemoryPool) {
+ // DDL TODO: should the size of the memory pool be decreased in DDL mode? CPU-side memory
+ // consumed in DDL mode vs. normal mode for a single skp might be a good metric of wasted
+ // memory.
+ fOpMemoryPool = sk_sp<GrOpMemoryPool>(new GrOpMemoryPool(16384, 16384));
+ }
+
+ SkASSERT(fOpMemoryPool);
+ return fOpMemoryPool;
+}
+
+GrOpMemoryPool* GrRecordingContext::opMemoryPool() {
+ return this->refOpMemoryPool().get();
+}
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<const GrCaps> GrRecordingContextPriv::refCaps() const {
return fContext->refCaps();
@@ -27,3 +45,7 @@
sk_sp<GrSkSLFPFactoryCache> GrRecordingContextPriv::fpFactoryCache() {
return fContext->fpFactoryCache();
}
+
+sk_sp<GrOpMemoryPool> GrRecordingContextPriv::refOpMemoryPool() {
+ return fContext->refOpMemoryPool();
+}
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index 92eadb0..c264eaa 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -39,6 +39,10 @@
SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
// from GrRecordingContext
+ sk_sp<GrOpMemoryPool> refOpMemoryPool();
+ GrOpMemoryPool* opMemoryPool() { return fContext->opMemoryPool(); }
+
+ GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
private:
explicit GrRecordingContextPriv(GrRecordingContext* context) : fContext(context) {}
diff --git a/src/gpu/GrTracing.h b/src/gpu/GrTracing.h
index 82c6f8d..64adf1d 100644
--- a/src/gpu/GrTracing.h
+++ b/src/gpu/GrTracing.h
@@ -16,7 +16,7 @@
* Context level GrTracing macros, classname and op are const char*, context is GrContext
*/
#define GR_CREATE_TRACE_MARKER_CONTEXT(classname, op, context) \
- GR_AUDIT_TRAIL_AUTO_FRAME(context->priv().getAuditTrail(), classname "::" op); \
+ GR_AUDIT_TRAIL_AUTO_FRAME(context->priv().auditTrail(), classname "::" op); \
TRACE_EVENT0("skia.gpu", classname "::" op)
#endif