Clean up GrSurfaceContext's relationship with GrRecordingContext
GrSurfaceContext was explicitly holding a lot of things it could just get from its GrRecordingContext. Change-Id: Ia2e9708d71318dc0c101d56aadf5ae797230bc75 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/194360 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
b70990eda4
commit
0d075de863
@ -9,6 +9,10 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrClip.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrRect.h"
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "Resources.h"
|
||||
#include "SkColorMatrixFilter.h"
|
||||
#include "SkFont.h"
|
||||
|
@ -150,14 +150,12 @@ void GrDrawingManager::OpListDAG::cleanup(const GrCaps* caps) {
|
||||
GrDrawingManager::GrDrawingManager(GrRecordingContext* context,
|
||||
const GrPathRendererChain::Options& optionsForPathRendererChain,
|
||||
const GrTextContext::Options& optionsForTextContext,
|
||||
GrSingleOwner* singleOwner,
|
||||
bool explicitlyAllocating,
|
||||
GrContextOptions::Enable sortOpLists,
|
||||
GrContextOptions::Enable reduceOpListSplitting)
|
||||
: fContext(context)
|
||||
, fOptionsForPathRendererChain(optionsForPathRendererChain)
|
||||
, fOptionsForTextContext(optionsForTextContext)
|
||||
, fSingleOwner(singleOwner)
|
||||
, fDAG(explicitlyAllocating, sortOpLists)
|
||||
, fTextContext(nullptr)
|
||||
, fPathRendererChain(nullptr)
|
||||
@ -770,14 +768,13 @@ sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetProxy> rtp(sk_ref_sp(sProxy->asRenderTargetProxy()));
|
||||
sk_sp<GrRenderTargetProxy> renderTargetProxy(sk_ref_sp(sProxy->asRenderTargetProxy()));
|
||||
|
||||
return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(
|
||||
fContext, this, std::move(rtp),
|
||||
return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext,
|
||||
std::move(renderTargetProxy),
|
||||
std::move(colorSpace),
|
||||
surfaceProps,
|
||||
fContext->priv().auditTrail(),
|
||||
fSingleOwner, managedOpList));
|
||||
managedOpList));
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
|
||||
@ -798,8 +795,7 @@ sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProx
|
||||
|
||||
sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
|
||||
|
||||
return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy),
|
||||
std::move(colorSpace),
|
||||
fContext->priv().auditTrail(),
|
||||
fSingleOwner));
|
||||
return sk_sp<GrTextureContext>(new GrTextureContext(fContext,
|
||||
std::move(textureProxy),
|
||||
std::move(colorSpace)));
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ class GrOpFlushState;
|
||||
class GrRecordingContext;
|
||||
class GrRenderTargetContext;
|
||||
class GrRenderTargetProxy;
|
||||
class GrSingleOWner;
|
||||
class GrRenderTargetOpList;
|
||||
class GrSoftwarePathRenderer;
|
||||
class GrTextureContext;
|
||||
@ -138,7 +137,7 @@ private:
|
||||
};
|
||||
|
||||
GrDrawingManager(GrRecordingContext*, const GrPathRendererChain::Options&,
|
||||
const GrTextContext::Options&, GrSingleOwner*,
|
||||
const GrTextContext::Options&,
|
||||
bool explicitlyAllocating, GrContextOptions::Enable sortRenderTargets,
|
||||
GrContextOptions::Enable reduceOpListSplitting);
|
||||
|
||||
@ -171,8 +170,6 @@ private:
|
||||
// This cache is used by both the vertex and index pools. It reuses memory across multiple
|
||||
// flushes.
|
||||
sk_sp<GrBufferAllocPool::CpuBufferCache> fCpuBufferCache;
|
||||
// In debug builds we guard against improper thread handling
|
||||
GrSingleOwner* fSingleOwner;
|
||||
|
||||
OpListDAG fDAG;
|
||||
GrOpList* fActiveOpList = nullptr;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "GrRecordingContext.h"
|
||||
|
||||
#include "GrCaps.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawingManager.h"
|
||||
#include "GrMemoryPool.h"
|
||||
#include "GrProxyProvider.h"
|
||||
@ -92,7 +93,6 @@ bool GrRecordingContext::init(sk_sp<const GrCaps> caps, sk_sp<GrSkSLFPFactoryCac
|
||||
fDrawingManager.reset(new GrDrawingManager(this,
|
||||
prcOptions,
|
||||
textContextOptions,
|
||||
this->singleOwner(),
|
||||
this->explicitlyAllocateGPUResources(),
|
||||
this->options().fSortRenderTargets,
|
||||
this->options().fReduceOpListSplitting));
|
||||
|
@ -160,15 +160,11 @@ private:
|
||||
// stack. When this occurs with a closed GrOpList, a new one will be allocated
|
||||
// when the renderTargetContext attempts to use it (via getOpList).
|
||||
GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
|
||||
GrDrawingManager* drawingMgr,
|
||||
sk_sp<GrRenderTargetProxy> rtp,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
GrAuditTrail* auditTrail,
|
||||
GrSingleOwner* singleOwner,
|
||||
bool managedOpList)
|
||||
: GrSurfaceContext(context, drawingMgr, rtp->config(), std::move(colorSpace), auditTrail,
|
||||
singleOwner)
|
||||
: GrSurfaceContext(context, rtp->config(), std::move(colorSpace))
|
||||
, fRenderTargetProxy(std::move(rtp))
|
||||
, fOpList(sk_ref_sp(fRenderTargetProxy->getLastRenderTargetOpList()))
|
||||
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define GrRenderTargetContext_DEFINED
|
||||
|
||||
#include "../private/GrRenderTargetProxy.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrPaint.h"
|
||||
#include "GrSurfaceContext.h"
|
||||
#include "GrTypesPriv.h"
|
||||
@ -28,6 +27,7 @@ class GrCoverageCountingPathRenderer;
|
||||
class GrDrawingManager;
|
||||
class GrDrawOp;
|
||||
class GrFixedClip;
|
||||
class GrOp;
|
||||
class GrRenderTarget;
|
||||
class GrRenderTargetContextPriv;
|
||||
class GrRenderTargetOpList;
|
||||
@ -456,9 +456,9 @@ public:
|
||||
bool isWrapped_ForTesting() const;
|
||||
|
||||
protected:
|
||||
GrRenderTargetContext(GrRecordingContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>,
|
||||
sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*,
|
||||
GrSingleOwner*, bool managedOpList = true);
|
||||
GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>,
|
||||
sk_sp<SkColorSpace>, const SkSurfaceProps*,
|
||||
bool managedOpList = true);
|
||||
|
||||
SkDEBUGCODE(void validate() const override;)
|
||||
|
||||
|
@ -23,27 +23,36 @@
|
||||
// stack. When this occurs with a closed GrOpList, a new one will be allocated
|
||||
// when the renderTargetContext attempts to use it (via getOpList).
|
||||
GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
|
||||
GrDrawingManager* drawingMgr,
|
||||
GrPixelConfig config,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrAuditTrail* auditTrail,
|
||||
GrSingleOwner* singleOwner)
|
||||
sk_sp<SkColorSpace> colorSpace)
|
||||
: fContext(context)
|
||||
, fAuditTrail(auditTrail)
|
||||
, fColorSpaceInfo(std::move(colorSpace), config)
|
||||
, fDrawingManager(drawingMgr)
|
||||
#ifdef SK_DEBUG
|
||||
, fSingleOwner(singleOwner)
|
||||
#endif
|
||||
{
|
||||
, fColorSpaceInfo(std::move(colorSpace), config) {
|
||||
}
|
||||
|
||||
GrAuditTrail* GrSurfaceContext::auditTrail() {
|
||||
return fContext->priv().auditTrail();
|
||||
}
|
||||
|
||||
GrDrawingManager* GrSurfaceContext::drawingManager() {
|
||||
return fContext->priv().drawingManager();
|
||||
}
|
||||
|
||||
const GrDrawingManager* GrSurfaceContext::drawingManager() const {
|
||||
return fContext->priv().drawingManager();
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
GrSingleOwner* GrSurfaceContext::singleOwner() {
|
||||
return fContext->priv().singleOwner();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool GrSurfaceContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer,
|
||||
size_t dstRowBytes, int x, int y, uint32_t flags) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_FALSE_IF_ABANDONED
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrSurfaceContext::readPixels");
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::readPixels");
|
||||
|
||||
// TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
|
||||
if (kUnpremul_SkAlphaType == dstInfo.alphaType() &&
|
||||
@ -70,7 +79,7 @@ bool GrSurfaceContext::writePixels(const SkImageInfo& srcInfo, const void* srcBu
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_FALSE_IF_ABANDONED
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrSurfaceContext::writePixels");
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::writePixels");
|
||||
|
||||
if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
|
||||
flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
|
||||
@ -94,7 +103,7 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_FALSE_IF_ABANDONED
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrSurfaceContext::copy");
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::copy");
|
||||
|
||||
if (!fContext->priv().caps()->canCopySurface(this->asSurfaceProxy(), src, srcRect,
|
||||
dstPoint)) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
class GrAuditTrail;
|
||||
class GrContext;
|
||||
class GrDrawingManager;
|
||||
class GrOpList;
|
||||
class GrRecordingContext;
|
||||
@ -103,7 +102,7 @@ public:
|
||||
|
||||
virtual GrRenderTargetContext* asRenderTargetContext() { return nullptr; }
|
||||
|
||||
GrAuditTrail* auditTrail() { return fAuditTrail; }
|
||||
GrAuditTrail* auditTrail();
|
||||
|
||||
// Provides access to functions that aren't part of the public API.
|
||||
GrSurfaceContextPriv surfPriv();
|
||||
@ -112,28 +111,21 @@ public:
|
||||
protected:
|
||||
friend class GrSurfaceContextPriv;
|
||||
|
||||
GrSurfaceContext(GrRecordingContext*, GrDrawingManager*, GrPixelConfig, sk_sp<SkColorSpace>,
|
||||
GrAuditTrail*, GrSingleOwner*);
|
||||
GrSurfaceContext(GrRecordingContext*, GrPixelConfig, sk_sp<SkColorSpace>);
|
||||
|
||||
GrDrawingManager* drawingManager() { return fDrawingManager; }
|
||||
const GrDrawingManager* drawingManager() const { return fDrawingManager; }
|
||||
GrDrawingManager* drawingManager();
|
||||
const GrDrawingManager* drawingManager() const;
|
||||
|
||||
virtual GrOpList* getOpList() = 0;
|
||||
SkDEBUGCODE(virtual void validate() const = 0;)
|
||||
|
||||
SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; })
|
||||
SkDEBUGCODE(GrSingleOwner* singleOwner();)
|
||||
|
||||
GrRecordingContext* fContext;
|
||||
GrAuditTrail* fAuditTrail;
|
||||
|
||||
private:
|
||||
GrColorSpaceInfo fColorSpaceInfo;
|
||||
|
||||
GrDrawingManager* fDrawingManager;
|
||||
|
||||
// In debug builds we guard against improper thread handling
|
||||
SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
|
@ -18,13 +18,9 @@
|
||||
#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
|
||||
|
||||
GrTextureContext::GrTextureContext(GrRecordingContext* context,
|
||||
GrDrawingManager* drawingMgr,
|
||||
sk_sp<GrTextureProxy> textureProxy,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrAuditTrail* auditTrail,
|
||||
GrSingleOwner* singleOwner)
|
||||
: GrSurfaceContext(context, drawingMgr, textureProxy->config(), std::move(colorSpace),
|
||||
auditTrail, singleOwner)
|
||||
sk_sp<SkColorSpace> colorSpace)
|
||||
: GrSurfaceContext(context, textureProxy->config(), std::move(colorSpace))
|
||||
, fTextureProxy(std::move(textureProxy))
|
||||
, fOpList(sk_ref_sp(fTextureProxy->getLastTextureOpList())) {
|
||||
SkDEBUGCODE(this->validate();)
|
||||
|
@ -39,8 +39,7 @@ public:
|
||||
sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
|
||||
|
||||
protected:
|
||||
GrTextureContext(GrRecordingContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
|
||||
sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
|
||||
GrTextureContext(GrRecordingContext*, sk_sp<GrTextureProxy>, sk_sp<SkColorSpace>);
|
||||
|
||||
SkDEBUGCODE(void validate() const override;)
|
||||
|
||||
|
@ -15,6 +15,7 @@ uniform half blurRadius;
|
||||
@header {
|
||||
#include "GrCaps.h"
|
||||
#include "GrClip.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrPaint.h"
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrRecordingContext.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "GrCaps.h"
|
||||
#include "GrClip.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrPaint.h"
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrRecordingContext.h"
|
||||
|
@ -89,7 +89,7 @@ void GrRenderTargetContextPriv::testingOnly_addDrawOp(
|
||||
return;
|
||||
}
|
||||
SkDEBUGCODE(fRenderTargetContext->validate());
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->auditTrail(),
|
||||
"GrRenderTargetContext::testingOnly_addDrawOp");
|
||||
fRenderTargetContext->addDrawOp(clip, std::move(op), willAddFn);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user