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;
SkDEBUGCODE(void validate() const;)
- GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps);
+ GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps,
+ GrSingleOwner*);
void internalDrawPath(GrPipelineBuilder*,
const SkMatrix& viewMatrix,
SkSurfaceProps fSurfaceProps;
// In debug builds we guard against improper thread handling
- SkDEBUGCODE(mutable GrSingleOwner fSingleOwner;)
+ mutable GrSingleOwner* fSingleOwner;
};
#endif
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
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);
#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; }
// 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();)
}
return nullptr;
}
- return new GrDrawContext(this, rt, surfaceProps);
+ return new GrDrawContext(this, rt, surfaceProps, fSingleOwner);
}
class GrContext;
class GrDrawContext;
+class GrSingleOWner;
class GrSoftwarePathRenderer;
class GrTextContext;
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)
GrContext* fContext;
GrDrawTarget::Options fOptionsForDrawTargets;
+ // In debug builds we guard against improper thread handling
+ GrSingleOwner* fSingleOwner;
+
bool fAbandoned;
SkTDArray<GrDrawTarget*> fDrawTargets;