Chromium Code Reviews| Index: include/gpu/GrContext.h |
| diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h |
| index 4245b7fa943cc894cb216f609f1e767116264777..ae457d55297ac61f357421c70dd9d96c6e29169c 100644 |
| --- a/include/gpu/GrContext.h |
| +++ b/include/gpu/GrContext.h |
| @@ -24,6 +24,7 @@ |
| struct GrBatchAtlasConfig; |
| class GrBatchFontCache; |
| struct GrContextOptions; |
| +class GrContextThreadSafeProxy; |
| class GrDrawingManager; |
| class GrDrawContext; |
| class GrDrawTarget; |
| @@ -61,6 +62,8 @@ public: |
| virtual ~GrContext(); |
| + GrContextThreadSafeProxy* threadSafeProxy(); |
| + |
| /** |
| * The GrContext normally assumes that no outsider is setting state |
| * within the underlying 3D API's context/device/whatever. This call informs |
| @@ -359,25 +362,27 @@ public: |
| SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner; } ) |
| private: |
| - GrGpu* fGpu; |
| - const GrCaps* fCaps; |
| - GrResourceCache* fResourceCache; |
| + GrGpu* fGpu; |
| + const GrCaps* fCaps; |
| + GrResourceCache* fResourceCache; |
| // this union exists because the inheritance of GrTextureProvider->GrResourceProvider |
| // is in a private header. |
| union { |
| - GrResourceProvider* fResourceProvider; |
| - GrTextureProvider* fTextureProvider; |
| + GrResourceProvider* fResourceProvider; |
| + GrTextureProvider* fTextureProvider; |
| }; |
| - GrBatchFontCache* fBatchFontCache; |
| - SkAutoTDelete<GrLayerCache> fLayerCache; |
| - SkAutoTDelete<GrTextBlobCache> fTextBlobCache; |
| + SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy; |
| + |
| + GrBatchFontCache* fBatchFontCache; |
| + SkAutoTDelete<GrLayerCache> fLayerCache; |
| + SkAutoTDelete<GrTextBlobCache> fTextBlobCache; |
| // Set by OverbudgetCB() to request that GrContext flush before exiting a draw. |
| - bool fFlushToReduceCacheSize; |
| - bool fDidTestPMConversions; |
| - int fPMToUPMConversion; |
| - int fUPMToPMConversion; |
| + bool fFlushToReduceCacheSize; |
| + bool fDidTestPMConversions; |
| + int fPMToUPMConversion; |
| + int fUPMToPMConversion; |
| // The sw backend may call GrContext::readSurfacePixels on multiple threads |
| // We may transfer the responsibilty for using a mutex to the sw backend |
| // when there are fewer code paths that lead to a readSurfacePixels call |
| @@ -388,26 +393,26 @@ private: |
| // readSurfacePixels proceeds to grab it. |
| // TODO: Stop pretending to make GrContext thread-safe for sw rasterization and provide |
| // a mechanism to make a SkPicture safe for multithreaded sw rasterization. |
| - SkMutex fReadPixelsMutex; |
| - SkMutex fTestPMConversionsMutex; |
| + SkMutex fReadPixelsMutex; |
| + SkMutex fTestPMConversionsMutex; |
| // In debug builds we guard against improper thread handling |
| // 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; |
| + mutable GrSingleOwner fSingleOwner; |
| struct CleanUpData { |
| PFCleanUpFunc fFunc; |
| void* fInfo; |
| }; |
| - SkTDArray<CleanUpData> fCleanUpData; |
| + SkTDArray<CleanUpData> fCleanUpData; |
| - const uint32_t fUniqueID; |
| + const uint32_t fUniqueID; |
| - SkAutoTDelete<GrDrawingManager> fDrawingManager; |
| + SkAutoTDelete<GrDrawingManager> fDrawingManager; |
| - GrAuditTrail fAuditTrail; |
| + GrAuditTrail fAuditTrail; |
| // TODO: have the CMM use drawContexts and rm this friending |
| friend class GrClipMaskManager; // the CMM is friended just so it can call 'drawingManager' |
| @@ -452,4 +457,19 @@ private: |
| typedef SkRefCnt INHERITED; |
| }; |
|
robertphillips
2016/03/08 18:43:10
// This class just gives access to the Caps & uniq
bsalomon
2016/03/08 19:49:32
I'd rather not document the implementation, but ad
|
| +class GrContextThreadSafeProxy : public SkRefCnt { |
| +private: |
| + GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID) |
| + : fCaps(SkRef(caps)) |
| + , fContextUniqueID(uniqueID) {} |
| + |
| + SkAutoTUnref<const GrCaps> fCaps; |
| + uint32_t fContextUniqueID; |
| + |
| + friend class GrContext; |
| + friend class SkImage; |
| + |
| + typedef SkRefCnt INHERITED; |
| +}; |
| + |
| #endif |