Make a single GrSingleOwner in GrContext

TBR=bsalomon@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1563703004

Review URL: https://codereview.chromium.org/1563703004
This commit is contained in:
joshualitt 2016-01-07 11:32:39 -08:00 committed by Commit bot
parent bfd5f171e6
commit f9bc796e0d
7 changed files with 22 additions and 9 deletions

View File

@ -392,7 +392,9 @@ private:
SkMutex fTestPMConversionsMutex;
// In debug builds we guard against improper thread handling
SkDEBUGCODE(mutable GrSingleOwner fSingleOwner;)
// This guard is passed to the GrDrawingManager and, from there to all the
// GrDrawContexts. It is also passed to the GrTextureProvider and SkGpuDevice.
mutable GrSingleOwner fSingleOwner;
struct CleanUpData {
PFCleanUpFunc fFunc;

View File

@ -283,7 +283,8 @@ private:
SkDEBUGCODE(void validate() const;)
GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps);
GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps,
GrSingleOwner*);
void internalDrawPath(GrPipelineBuilder*,
const SkMatrix& viewMatrix,
@ -309,7 +310,7 @@ private:
SkSurfaceProps fSurfaceProps;
// In debug builds we guard against improper thread handling
SkDEBUGCODE(mutable GrSingleOwner fSingleOwner;)
mutable GrSingleOwner* fSingleOwner;
};
#endif

View File

@ -48,6 +48,8 @@ private:
SkThreadID fOwner; // guarded by fMutex
int fReentranceCount; // guarded by fMutex
};
#else
class GrSingleOwner {}; // Provide a dummy implementation so we can pass pointers to constructors
#endif
#endif

View File

@ -95,7 +95,7 @@ void GrContext::initCommon(const GrContextOptions& options) {
dtOptions.fClipBatchToBounds = options.fClipBatchToBounds;
dtOptions.fDrawBatchBounds = options.fDrawBatchBounds;
dtOptions.fMaxBatchLookback = options.fMaxBatchLookback;
fDrawingManager.reset(new GrDrawingManager(this, dtOptions));
fDrawingManager.reset(new GrDrawingManager(this, dtOptions, &fSingleOwner));
// GrBatchFontCache will eventually replace GrFontCache
fBatchFontCache = new GrBatchFontCache(this);

View File

@ -28,7 +28,7 @@
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingManager->getContext())
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);)
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
#define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return false; }
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nullptr; }
@ -50,12 +50,14 @@ private:
// when the drawContext attempts to use it (via getDrawTarget).
GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr,
GrRenderTarget* rt,
const SkSurfaceProps* surfaceProps)
const SkSurfaceProps* surfaceProps,
GrSingleOwner* singleOwner)
: fDrawingManager(drawingMgr)
, fRenderTarget(rt)
, fDrawTarget(SkSafeRef(rt->getLastDrawTarget()))
, fTextContext(nullptr)
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) {
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
, fSingleOwner(singleOwner) {
SkDEBUGCODE(this->validate();)
}

View File

@ -202,5 +202,5 @@ GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt,
return nullptr;
}
return new GrDrawContext(this, rt, surfaceProps);
return new GrDrawContext(this, rt, surfaceProps, fSingleOwner);
}

View File

@ -16,6 +16,7 @@
class GrContext;
class GrDrawContext;
class GrSingleOWner;
class GrSoftwarePathRenderer;
class GrTextContext;
@ -53,9 +54,11 @@ public:
static bool ProgramUnitTest(GrContext* context, int maxStages);
private:
GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsForDrawTargets)
GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsForDrawTargets,
GrSingleOwner* singleOwner)
: fContext(context)
, fOptionsForDrawTargets(optionsForDrawTargets)
, fSingleOwner(singleOwner)
, fAbandoned(false)
, fNVPRTextContext(nullptr)
, fPathRendererChain(nullptr)
@ -78,6 +81,9 @@ private:
GrContext* fContext;
GrDrawTarget::Options fOptionsForDrawTargets;
// In debug builds we guard against improper thread handling
GrSingleOwner* fSingleOwner;
bool fAbandoned;
SkTDArray<GrDrawTarget*> fDrawTargets;