blob: 93b292d6ad47231552778998dcf3ee52b5330e13 [file] [log] [blame]
bsalomon@google.com27847de2011-02-22 20:59:41 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
bsalomon@google.com27847de2011-02-22 20:59:41 +00006 */
7
8#ifndef GrContext_DEFINED
9#define GrContext_DEFINED
10
robertphillipscaef3452015-11-11 13:18:11 -080011#include "GrCaps.h"
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +000012#include "GrColor.h"
rmistry@google.comfbfcd562012-08-23 18:09:54 +000013#include "GrRenderTarget.h"
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +000014#include "SkMatrix.h"
egdaniele61c4112014-06-12 10:24:21 -070015#include "SkPathEffect.h"
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +000016#include "SkTypes.h"
joshualitt27a48dc2016-01-08 07:19:47 -080017#include "../private/GrAuditTrail.h"
joshualitt1de610a2016-01-06 08:26:09 -080018#include "../private/GrSingleOwner.h"
bsalomon@google.com27847de2011-02-22 20:59:41 +000019
Brian Salomonf856fd12016-12-16 14:24:34 -050020class GrAtlasGlyphCache;
bsalomon682c2692015-05-22 14:01:46 -070021struct GrContextOptions;
robertphillips4fd74ae2016-08-03 14:26:53 -070022class GrContextPriv;
bsalomon41b952c2016-03-11 06:46:33 -080023class GrContextThreadSafeProxy;
robertphillips77a2e522015-10-17 07:43:27 -070024class GrDrawingManager;
Brian Salomon2ee084e2016-12-16 18:59:19 -050025struct GrDrawOpAtlasConfig;
Brian Osman11052242016-10-27 14:47:55 -040026class GrRenderTargetContext;
joshualittb0a8a372014-09-23 09:50:21 -070027class GrFragmentProcessor;
bsalomon@google.com05ef5102011-05-02 21:14:59 +000028class GrGpu;
bsalomon@google.com583a1e32011-08-17 13:42:46 +000029class GrIndexBuffer;
commit-bot@chromium.org81312832013-03-22 18:34:09 +000030class GrOvalRenderer;
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000031class GrPath;
egdaniel8dd688b2015-01-22 10:16:09 -080032class GrPipelineBuilder;
bsalomon@google.com50398bf2011-07-26 20:45:30 +000033class GrResourceEntry;
bsalomon0ea80f42015-02-11 10:49:59 -080034class GrResourceCache;
bsalomond309e7a2015-04-30 14:18:54 -070035class GrResourceProvider;
Mike Reed84dd8572017-03-08 22:21:00 -050036class GrSamplerParams;
Robert Phillips7ee385e2017-03-30 08:02:11 -040037class GrSurfaceProxy;
joshualittb7133be2015-04-08 09:08:31 -070038class GrTextBlobCache;
kkinnunenc6cb56f2014-06-24 00:12:27 -070039class GrTextContext;
Mike Reed84dd8572017-03-08 22:21:00 -050040class GrTextureProxy;
bsalomon@google.com583a1e32011-08-17 13:42:46 +000041class GrVertexBuffer;
bsalomon6c9cd552016-01-22 07:17:34 -080042class GrSwizzle;
ericrk0a5fa482015-09-15 14:16:10 -070043class SkTraceMemoryDump;
bsalomon@google.com50398bf2011-07-26 20:45:30 +000044
Mike Reed84dd8572017-03-08 22:21:00 -050045class SkImage;
46class SkSurfaceProps;
47
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000048class SK_API GrContext : public SkRefCnt {
bsalomon@google.com27847de2011-02-22 20:59:41 +000049public:
50 /**
bsalomon@google.com16e3dde2012-10-25 18:43:28 +000051 * Creates a GrContext for a backend context.
bsalomon@google.com27847de2011-02-22 20:59:41 +000052 */
bsalomon682c2692015-05-22 14:01:46 -070053 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions& options);
54 static GrContext* Create(GrBackend, GrBackendContext);
bsalomon@google.com27847de2011-02-22 20:59:41 +000055
bsalomon33435572014-11-05 14:47:41 -080056 /**
57 * Only defined in test apps.
58 */
59 static GrContext* CreateMockContext();
60
bsalomon@google.com27847de2011-02-22 20:59:41 +000061 virtual ~GrContext();
62
bungeman6bd52842016-10-27 09:30:08 -070063 sk_sp<GrContextThreadSafeProxy> threadSafeProxy();
bsalomon41b952c2016-03-11 06:46:33 -080064
bsalomon@google.com27847de2011-02-22 20:59:41 +000065 /**
66 * The GrContext normally assumes that no outsider is setting state
67 * within the underlying 3D API's context/device/whatever. This call informs
68 * the context that the state was modified and it should resend. Shouldn't
69 * be called frequently for good performance.
bsalomon@google.com0a208a12013-06-28 18:57:35 +000070 * The flag bits, state, is dpendent on which backend is used by the
71 * context, either GL or D3D (possible in future).
bsalomon@google.com27847de2011-02-22 20:59:41 +000072 */
bsalomon@google.com0a208a12013-06-28 18:57:35 +000073 void resetContext(uint32_t state = kAll_GrBackendState);
bsalomon@google.com27847de2011-02-22 20:59:41 +000074
bsalomon@google.com8fe72472011-03-30 21:26:44 +000075 /**
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000076 * Callback function to allow classes to cleanup on GrContext destruction.
77 * The 'info' field is filled in with the 'info' passed to addCleanUp.
78 */
79 typedef void (*PFCleanUpFunc)(const GrContext* context, void* info);
80
81 /**
82 * Add a function to be called from within GrContext's destructor.
83 * This gives classes a chance to free resources held on a per context basis.
84 * The 'info' parameter will be stored and passed to the callback function.
85 */
86 void addCleanUp(PFCleanUpFunc cleanUp, void* info) {
87 CleanUpData* entry = fCleanUpData.push();
88
89 entry->fFunc = cleanUp;
90 entry->fInfo = info;
91 }
92
93 /**
bsalomon6e2aad42016-04-01 11:54:31 -070094 * Abandons all GPU resources and assumes the underlying backend 3D API context is not longer
95 * usable. Call this if you have lost the associated GPU context, and thus internal texture,
96 * buffer, etc. references/IDs are now invalid. Calling this ensures that the destructors of the
97 * GrContext and any of its created resource objects will not make backend 3D API calls. Content
98 * rendered but not previously flushed may be lost. After this function is called all subsequent
99 * calls on the GrContext will fail or be no-ops.
100 *
101 * The typical use case for this function is that the underlying 3D context was lost and further
102 * API calls may crash.
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000103 */
bsalomon2354f842014-07-28 13:48:36 -0700104 void abandonContext();
junov@google.com53a55842011-06-08 22:55:10 +0000105
bsalomon6e2aad42016-04-01 11:54:31 -0700106 /**
107 * This is similar to abandonContext() however the underlying 3D context is not yet lost and
108 * the GrContext will cleanup all allocated resources before returning. After returning it will
109 * assume that the underlying context may no longer be valid.
110 *
111 * The typical use case for this function is that the client is going to destroy the 3D context
112 * but can't guarantee that GrContext will be destroyed first (perhaps because it may be ref'ed
113 * elsewhere by either the client or Skia objects).
114 */
115 void releaseResourcesAndAbandonContext();
116
commit-bot@chromium.org95c20032014-05-09 14:29:32 +0000117 ///////////////////////////////////////////////////////////////////////////
118 // Resource Cache
119
120 /**
121 * Return the current GPU resource cache limits.
122 *
123 * @param maxResources If non-null, returns maximum number of resources that
124 * can be held in the cache.
125 * @param maxResourceBytes If non-null, returns maximum number of bytes of
126 * video memory that can be held in the cache.
127 */
128 void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const;
commit-bot@chromium.org95c20032014-05-09 14:29:32 +0000129
130 /**
131 * Gets the current GPU resource cache usage.
132 *
133 * @param resourceCount If non-null, returns the number of resources that are held in the
134 * cache.
135 * @param maxResourceBytes If non-null, returns the total number of bytes of video memory held
136 * in the cache.
137 */
138 void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const;
139
commit-bot@chromium.org95c20032014-05-09 14:29:32 +0000140 /**
141 * Specify the GPU resource cache limits. If the current cache exceeds either
142 * of these, it will be purged (LRU) to keep the cache within these limits.
143 *
144 * @param maxResources The maximum number of resources that can be held in
145 * the cache.
146 * @param maxResourceBytes The maximum number of bytes of video memory
147 * that can be held in the cache.
148 */
149 void setResourceCacheLimits(int maxResources, size_t maxResourceBytes);
commit-bot@chromium.org95c20032014-05-09 14:29:32 +0000150
junov@google.com53a55842011-06-08 22:55:10 +0000151 /**
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000152 * Frees GPU created by the context. Can be called to reduce GPU memory
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000153 * pressure.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000154 */
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000155 void freeGpuResources();
156
bsalomon@google.com07fc0d12012-06-22 15:15:59 +0000157 /**
commit-bot@chromium.org95c20032014-05-09 14:29:32 +0000158 * Purge all the unlocked resources from the cache.
159 * This entry point is mainly meant for timing texture uploads
160 * and is not defined in normal builds of Skia.
commit-bot@chromium.orgd8a57af2014-03-19 21:19:16 +0000161 */
commit-bot@chromium.org95c20032014-05-09 14:29:32 +0000162 void purgeAllUnlockedResources();
163
Brian Salomon5e150852017-03-22 14:53:13 -0400164 /**
165 * Purge GPU resources that haven't been used in the past 'ms' milliseconds, regardless of
166 * whether the context is currently under budget.
167 */
168 void purgeResourcesNotUsedInMs(std::chrono::milliseconds ms);
169
bsalomon76228632015-05-29 08:02:10 -0700170 /** Access the context capabilities */
171 const GrCaps* caps() const { return fCaps; }
bsalomon@google.com8a70eef2013-03-19 13:58:55 +0000172
commit-bot@chromium.orgb471a322014-03-10 07:40:03 +0000173 /**
174 * Returns the recommended sample count for a render target when using this
175 * context.
176 *
177 * @param config the configuration of the render target.
178 * @param dpi the display density in dots per inch.
179 *
180 * @return sample count that should be perform well and have good enough
181 * rendering quality for the display. Alternatively returns 0 if
182 * MSAA is not supported or recommended to be used by default.
183 */
184 int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const;
185
Robert Phillipsd83ec042017-04-10 11:10:22 -0400186 /*
187 * Create a new render target context backed by a deferred-style
188 * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
189 * renderTargetContexts created via this entry point.
robertphillipsd4c741e2016-04-28 09:55:15 -0700190 */
robertphillipsd728f0c2016-11-21 11:05:03 -0800191 sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
Robert Phillipsd83ec042017-04-10 11:10:22 -0400192 SkBackingFit fit,
Robert Phillipsc7635fa2016-10-28 13:25:24 -0400193 int width, int height,
194 GrPixelConfig config,
195 sk_sp<SkColorSpace> colorSpace,
196 int sampleCnt = 0,
Robert Phillips40fd7c92017-01-30 08:06:27 -0500197 GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
Robert Phillipsc7635fa2016-10-28 13:25:24 -0400198 const SkSurfaceProps* surfaceProps = nullptr,
199 SkBudgeted = SkBudgeted::kYes);
robertphillips48fde9c2016-09-06 05:20:20 -0700200 /*
Brian Osman11052242016-10-27 14:47:55 -0400201 * This method will attempt to create a renderTargetContext that has, at least, the number of
robertphillips48fde9c2016-09-06 05:20:20 -0700202 * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be
203 * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
204 * SRGB-ness will be preserved.
205 */
robertphillipsd728f0c2016-11-21 11:05:03 -0800206 sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
207 SkBackingFit fit,
208 int width, int height,
209 GrPixelConfig config,
210 sk_sp<SkColorSpace> colorSpace,
211 int sampleCnt = 0,
Robert Phillips40fd7c92017-01-30 08:06:27 -0500212 GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
robertphillipsd728f0c2016-11-21 11:05:03 -0800213 const SkSurfaceProps* surfaceProps = nullptr,
214 SkBudgeted budgeted = SkBudgeted::kYes);
215
bsalomon@google.com27847de2011-02-22 20:59:41 +0000216 ///////////////////////////////////////////////////////////////////////////
217 // Misc.
218
219 /**
220 * Call to ensure all drawing to the context has been issued to the
221 * underlying 3D API.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000222 */
bsalomonb77a9072016-09-07 10:02:04 -0700223 void flush();
robertphillipsea461502015-05-26 11:38:03 -0700224
senorblanco@chromium.org027de5f2011-07-08 18:03:33 +0000225 /**
joshualitt0acd0d32015-05-07 08:23:19 -0700226 * An ID associated with this context, guaranteed to be unique.
227 */
228 uint32_t uniqueID() { return fUniqueID; }
229
bsalomon@google.com27847de2011-02-22 20:59:41 +0000230 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com27847de2011-02-22 20:59:41 +0000231 // Functions intended for internal use only.
232 GrGpu* getGpu() { return fGpu; }
bsalomon@google.com1f221a72011-08-23 20:54:07 +0000233 const GrGpu* getGpu() const { return fGpu; }
Brian Salomonf856fd12016-12-16 14:24:34 -0500234 GrAtlasGlyphCache* getAtlasGlyphCache() { return fAtlasGlyphCache; }
bungeman6bd52842016-10-27 09:30:08 -0700235 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache.get(); }
robertphillips77a2e522015-10-17 07:43:27 -0700236 bool abandoned() const;
bsalomond309e7a2015-04-30 14:18:54 -0700237 GrResourceProvider* resourceProvider() { return fResourceProvider; }
238 const GrResourceProvider* resourceProvider() const { return fResourceProvider; }
bsalomon0ea80f42015-02-11 10:49:59 -0800239 GrResourceCache* getResourceCache() { return fResourceCache; }
bsalomon@google.com9923c2b2012-06-06 18:21:18 +0000240
joshualitte45c81c2015-12-02 09:05:37 -0800241 /** Reset GPU stats */
242 void resetGpuStats() const ;
243
mtkleinb9eb4ac2015-02-02 18:26:03 -0800244 /** Prints cache stats to the string if GR_CACHE_STATS == 1. */
245 void dumpCacheStats(SkString*) const;
joshualittdc5685a2015-12-02 14:08:25 -0800246 void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
robertphillips@google.com5f9f2f52012-08-22 10:57:05 +0000247 void printCacheStats() const;
robertphillips@google.com5f9f2f52012-08-22 10:57:05 +0000248
mtkleinb9eb4ac2015-02-02 18:26:03 -0800249 /** Prints GPU stats to the string if GR_GPU_STATS == 1. */
250 void dumpGpuStats(SkString*) const;
joshualittdc5685a2015-12-02 14:08:25 -0800251 void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
mtkleinb9eb4ac2015-02-02 18:26:03 -0800252 void printGpuStats() const;
robertphillips754f4e92014-09-18 13:52:08 -0700253
joshualitt17d833b2015-08-03 10:17:44 -0700254 /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge.
255 this is for testing only */
256 void setTextBlobCacheLimit_ForTesting(size_t bytes);
257
joshualittda04e0e2015-08-19 08:16:43 -0700258 /** Specify the sizes of the GrAtlasTextContext atlases. The configs pointer below should be
259 to an array of 3 entries */
Brian Salomon2ee084e2016-12-16 18:59:19 -0500260 void setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs);
joshualittda04e0e2015-08-19 08:16:43 -0700261
ericrk0a5fa482015-09-15 14:16:10 -0700262 /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
263 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
264
Robert Phillips33667da2016-12-20 11:05:30 -0500265 /** Get pointer to atlas texture for given mask format. Note that this wraps an
266 actively mutating texture in an SkImage. This could yield unexpected results
267 if it gets cached or used more generally. */
Robert Phillipsc37e6142017-01-20 10:03:25 -0500268 sk_sp<SkImage> getFontAtlasImage_ForTesting(GrMaskFormat format);
jvanverth629162d2015-11-08 08:07:24 -0800269
joshualitt5651ee62016-01-11 10:39:11 -0800270 GrAuditTrail* getAuditTrail() { return &fAuditTrail; }
joshualitt27a48dc2016-01-08 07:19:47 -0800271
joshualittce894002016-01-11 13:29:31 -0800272 /** This is only useful for debug purposes */
273 SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner; } )
274
robertphillips4fd74ae2016-08-03 14:26:53 -0700275 // Provides access to functions that aren't part of the public API.
276 GrContextPriv contextPriv();
277 const GrContextPriv contextPriv() const;
278
bsalomon@google.com27847de2011-02-22 20:59:41 +0000279private:
bsalomon41b952c2016-03-11 06:46:33 -0800280 GrGpu* fGpu;
281 const GrCaps* fCaps;
282 GrResourceCache* fResourceCache;
Brian Osman32342f02017-03-04 08:12:46 -0500283 GrResourceProvider* fResourceProvider;
bsalomond309e7a2015-04-30 14:18:54 -0700284
bungeman6bd52842016-10-27 09:30:08 -0700285 sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy;
bsalomon41b952c2016-03-11 06:46:33 -0800286
Brian Salomonf856fd12016-12-16 14:24:34 -0500287 GrAtlasGlyphCache* fAtlasGlyphCache;
bungeman6bd52842016-10-27 09:30:08 -0700288 std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000289
Brian Osman46da1cc2017-02-14 14:15:48 -0500290 bool fDisableGpuYUVConversion;
bsalomon41b952c2016-03-11 06:46:33 -0800291 bool fDidTestPMConversions;
292 int fPMToUPMConversion;
293 int fUPMToPMConversion;
bsalomon@google.coma04e8e82012-08-27 12:53:13 +0000294
joshualitt1de610a2016-01-06 08:26:09 -0800295 // In debug builds we guard against improper thread handling
joshualittde8dc7e2016-01-08 10:09:13 -0800296 // This guard is passed to the GrDrawingManager and, from there to all the
Brian Osman32342f02017-03-04 08:12:46 -0500297 // GrRenderTargetContexts. It is also passed to the GrResourceProvider and SkGpuDevice.
bsalomon41b952c2016-03-11 06:46:33 -0800298 mutable GrSingleOwner fSingleOwner;
joshualitt1de610a2016-01-06 08:26:09 -0800299
robertphillips@google.comcdb426d2012-09-24 19:33:59 +0000300 struct CleanUpData {
301 PFCleanUpFunc fFunc;
302 void* fInfo;
303 };
304
bsalomon41b952c2016-03-11 06:46:33 -0800305 SkTDArray<CleanUpData> fCleanUpData;
robertphillips@google.com44a91dc2013-07-25 15:32:06 +0000306
bsalomon41b952c2016-03-11 06:46:33 -0800307 const uint32_t fUniqueID;
krajcevski9c6d4d72014-08-12 07:26:25 -0700308
bungeman6bd52842016-10-27 09:30:08 -0700309 std::unique_ptr<GrDrawingManager> fDrawingManager;
robertphillips77a2e522015-10-17 07:43:27 -0700310
bsalomon41b952c2016-03-11 06:46:33 -0800311 GrAuditTrail fAuditTrail;
joshualitt27a48dc2016-01-08 07:19:47 -0800312
Brian Osman11052242016-10-27 14:47:55 -0400313 // TODO: have the GrClipStackClip use renderTargetContexts and rm this friending
robertphillips4fd74ae2016-08-03 14:26:53 -0700314 friend class GrContextPriv;
csmartdaltonc6f411e2016-08-05 22:32:12 -0700315
bsalomon682c2692015-05-22 14:01:46 -0700316 GrContext(); // init must be called after the constructor.
317 bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
robertphillipsea461502015-05-26 11:38:03 -0700318
bsalomon33435572014-11-05 14:47:41 -0800319 void initMockContext();
bsalomon69cfe952015-11-30 13:27:47 -0800320 void initCommon(const GrContextOptions&);
bsalomon@google.com205d4602011-04-25 12:43:45 +0000321
skia.committer@gmail.comcdcb2ce2013-01-29 07:05:52 +0000322 /**
bsalomon@google.comadc65362013-01-28 14:26:09 +0000323 * These functions create premul <-> unpremul effects if it is possible to generate a pair
324 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
bsalomon6c9cd552016-01-22 07:17:34 -0800325 * return NULL. They also can perform a swizzle as part of the draw.
bsalomon@google.comadc65362013-01-28 14:26:09 +0000326 */
Brian Osman60cd57e2017-04-06 10:19:06 -0400327 sk_sp<GrFragmentProcessor> createPMToUPMEffect(sk_sp<GrFragmentProcessor>, GrPixelConfig);
328 sk_sp<GrFragmentProcessor> createUPMToPMEffect(sk_sp<GrFragmentProcessor>, GrPixelConfig);
bsalomon6c6f6582015-09-10 08:12:46 -0700329 /** Called before either of the above two functions to determine the appropriate fragment
Robert Phillips65115a12016-12-13 12:42:19 -0500330 processors for conversions. */
bsalomon6c6f6582015-09-10 08:12:46 -0700331 void testPMConversionsIfNecessary(uint32_t flags);
Brian Osmande1a6052017-03-22 10:57:00 -0400332 /** Returns true if we've determined that createPMtoUPMEffect and createUPMToPMEffect will
333 succeed for the passed in config. Otherwise we fall back to SW conversion. */
334 bool validPMUPMConversionExists(GrPixelConfig) const;
bsalomon@google.coma04e8e82012-08-27 12:53:13 +0000335
commit-bot@chromium.orgcae27fe2013-07-10 10:14:35 +0000336 /**
joshualitt0db6dfa2015-04-10 07:01:30 -0700337 * A callback similar to the above for use by the TextBlobCache
338 * TODO move textblob draw calls below context so we can use the call above.
339 */
340 static void TextBlobCacheOverBudgetCB(void* data);
341
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +0000342 typedef SkRefCnt INHERITED;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000343};
344
bsalomon41b952c2016-03-11 06:46:33 -0800345/**
346 * Can be used to perform actions related to the generating GrContext in a thread safe manner. The
347 * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrContext.
348 */
349class GrContextThreadSafeProxy : public SkRefCnt {
350private:
bungeman6bd52842016-10-27 09:30:08 -0700351 GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID)
352 : fCaps(std::move(caps))
bsalomon41b952c2016-03-11 06:46:33 -0800353 , fContextUniqueID(uniqueID) {}
354
bungeman6bd52842016-10-27 09:30:08 -0700355 sk_sp<const GrCaps> fCaps;
356 uint32_t fContextUniqueID;
bsalomon41b952c2016-03-11 06:46:33 -0800357
358 friend class GrContext;
359 friend class SkImage;
360
361 typedef SkRefCnt INHERITED;
362};
363
bsalomon@google.com27847de2011-02-22 20:59:41 +0000364#endif