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>
This commit is contained in:
Robert Phillips 2019-02-08 10:29:20 -05:00 committed by Skia Commit-Bot
parent a5ab35cc0e
commit d6841487eb
10 changed files with 50 additions and 33 deletions

View File

@ -11,7 +11,6 @@
#include "SkMatrix.h"
#include "SkPathEffect.h"
#include "SkTypes.h"
#include "../private/GrAuditTrail.h"
#include "../private/GrRecordingContext.h"
#include "GrContextOptions.h"
@ -30,7 +29,6 @@ struct GrGLInterface;
class GrStrikeCache;
class GrGpu;
struct GrMockOptions;
class GrOpMemoryPool;
class GrPath;
class GrRenderTargetContext;
class GrResourceCache;
@ -298,10 +296,7 @@ private:
GrResourceCache* fResourceCache;
GrResourceProvider* fResourceProvider;
// All the GrOp-derived classes use this pool.
sk_sp<GrOpMemoryPool> fOpMemoryPool;
GrStrikeCache* fGlyphCache;
GrStrikeCache* fGlyphCache;
std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bool fDidTestPMConversions;
@ -310,8 +305,6 @@ private:
std::unique_ptr<GrDrawingManager> fDrawingManager;
GrAuditTrail fAuditTrail;
GrContextOptions::PersistentCache* fPersistentCache;
// TODO: have the GrClipStackClip use renderTargetContexts and rm this friending

View File

@ -8,8 +8,10 @@
#ifndef GrRecordingContext_DEFINED
#define GrRecordingContext_DEFINED
#include "GrAuditTrail.h"
#include "GrImageContext.h"
class GrOpMemoryPool;
class GrRecordingContextPriv;
class SK_API GrRecordingContext : public GrImageContext {
@ -25,9 +27,18 @@ protected:
GrRecordingContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
sk_sp<GrOpMemoryPool> refOpMemoryPool();
GrOpMemoryPool* opMemoryPool();
GrAuditTrail* auditTrail() { return &fAuditTrail; }
GrRecordingContext* asRecordingContext() override { return this; }
private:
// All the GrOp-derived classes use this pool.
sk_sp<GrOpMemoryPool> fOpMemoryPool;
GrAuditTrail fAuditTrail;
typedef GrImageContext INHERITED;
};

View File

@ -40,19 +40,7 @@ sk_sp<GrSkSLFPFactoryCache> GrContextPriv::fpFactoryCache() {
}
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,

View File

@ -53,15 +53,16 @@ public:
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 @@ public:
const SkSurfaceProps* surfaceProps = nullptr,
SkBudgeted budgeted = SkBudgeted::kYes);
GrAuditTrail* getAuditTrail() { return &fContext->fAuditTrail; }
GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; }
#ifdef SK_ENABLE_DUMP_GPU

View File

@ -598,7 +598,7 @@ sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(GrRenderTargetProxy* r
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> GrDrawingManager::newTextureOpList(GrTextureProxy* textur
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 @@ sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
fContext, this, std::move(rtp),
std::move(colorSpace),
surfaceProps,
fContext->priv().getAuditTrail(),
fContext->priv().auditTrail(),
fSingleOwner, managedOpList));
}
@ -755,6 +755,6 @@ sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProx
return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy),
std::move(colorSpace),
fContext->priv().getAuditTrail(),
fContext->priv().auditTrail(),
fSingleOwner));
}

View File

@ -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(GrBackendApi backend,
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<const GrCaps> GrRecordingContextPriv::refCaps() const {
sk_sp<GrSkSLFPFactoryCache> GrRecordingContextPriv::fpFactoryCache() {
return fContext->fpFactoryCache();
}
sk_sp<GrOpMemoryPool> GrRecordingContextPriv::refOpMemoryPool() {
return fContext->refOpMemoryPool();
}

View File

@ -39,6 +39,10 @@ public:
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) {}

View File

@ -16,7 +16,7 @@ class GrContext;
* 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

View File

@ -207,7 +207,7 @@ DEF_GPUTEST(OpChainTest, reporter, /*ctxInfo*/) {
GrRenderTargetOpList opList(context->priv().resourceProvider(),
sk_ref_sp(context->priv().opMemoryPool()),
proxy->asRenderTargetProxy(),
context->priv().getAuditTrail());
context->priv().auditTrail());
// This assumes the particular values of kRanges.
std::fill_n(result, result_width(), -1);
std::fill_n(validResult, result_width(), -1);

View File

@ -218,7 +218,7 @@ GrAuditTrail* SkDebugCanvas::getAuditTrail(SkCanvas* canvas) {
GrAuditTrail* at = nullptr;
GrContext* ctx = canvas->getGrContext();
if (ctx) {
at = ctx->priv().getAuditTrail();
at = ctx->priv().auditTrail();
}
return at;
}