robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrContextPriv_DEFINED |
| 9 | #define GrContextPriv_DEFINED |
| 10 | |
| 11 | #include "GrContext.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 12 | #include "GrSurfaceContext.h" |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 13 | #include "text/GrAtlasManager.h" |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 14 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 15 | class GrBackendFormat; |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 16 | class GrBackendRenderTarget; |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 17 | class GrOpMemoryPool; |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 18 | class GrOnFlushCallbackObject; |
Greg Daniel | d85f97d | 2017-03-07 13:37:21 -0500 | [diff] [blame] | 19 | class GrSemaphore; |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 20 | class GrSkSLFPFactory; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 21 | class GrSurfaceProxy; |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 22 | class GrTextureContext; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 23 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 24 | class SkDeferredDisplayList; |
| 25 | |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 26 | /** Class that adds methods to GrContext that are only intended for use internal to Skia. |
| 27 | This class is purely a privileged window into GrContext. It should never have additional |
| 28 | data members or virtual methods. */ |
| 29 | class GrContextPriv { |
| 30 | public: |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 31 | /** |
| 32 | * Create a GrContext without a resource cache |
| 33 | */ |
Kevin Lubick | b5502b2 | 2018-03-12 10:17:06 -0400 | [diff] [blame] | 34 | static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&); |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 35 | |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 36 | const GrCaps* caps() const { return fContext->fCaps.get(); } |
| 37 | |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 38 | sk_sp<GrOpMemoryPool> refOpMemoryPool(); |
| 39 | GrOpMemoryPool* opMemoryPool(); |
| 40 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 41 | GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); } |
csmartdalton | bde96c6 | 2016-08-31 12:54:46 -0700 | [diff] [blame] | 42 | |
Robert Phillips | d5f9cdd | 2018-01-31 09:29:48 -0500 | [diff] [blame] | 43 | sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>, |
| 44 | sk_sp<SkColorSpace> = nullptr, |
| 45 | const SkSurfaceProps* = nullptr); |
Robert Phillips | 31c2608 | 2016-12-14 15:12:15 -0500 | [diff] [blame] | 46 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 47 | sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrBackendFormat&, |
| 48 | const GrSurfaceDesc&, |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 49 | GrSurfaceOrigin, |
Greg Daniel | 65c7f66 | 2017-10-30 13:39:09 -0400 | [diff] [blame] | 50 | GrMipMapped, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 51 | SkBackingFit, |
Brian Salomon | 366093f | 2018-02-13 09:25:22 -0500 | [diff] [blame] | 52 | SkBudgeted, |
| 53 | sk_sp<SkColorSpace> colorSpace = nullptr, |
| 54 | const SkSurfaceProps* = nullptr); |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 55 | |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 56 | sk_sp<GrTextureContext> makeBackendTextureContext(const GrBackendTexture& tex, |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 57 | GrSurfaceOrigin origin, |
Brian Osman | c1e3705 | 2017-03-09 14:19:20 -0500 | [diff] [blame] | 58 | sk_sp<SkColorSpace> colorSpace); |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 59 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 60 | sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext( |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 61 | const GrBackendTexture& tex, |
| 62 | GrSurfaceOrigin origin, |
| 63 | int sampleCnt, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 64 | sk_sp<SkColorSpace> colorSpace, |
Brian Osman | c1e3705 | 2017-03-09 14:19:20 -0500 | [diff] [blame] | 65 | const SkSurfaceProps* = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 66 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 67 | sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext( |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 68 | const GrBackendRenderTarget&, |
| 69 | GrSurfaceOrigin origin, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 70 | sk_sp<SkColorSpace> colorSpace, |
| 71 | const SkSurfaceProps* = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 72 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 73 | sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext( |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 74 | const GrBackendTexture& tex, |
| 75 | GrSurfaceOrigin origin, |
| 76 | int sampleCnt, |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 77 | sk_sp<SkColorSpace> colorSpace, |
| 78 | const SkSurfaceProps* = nullptr); |
| 79 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 80 | sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext( |
| 81 | const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr); |
| 82 | |
Brian Osman | 46da1cc | 2017-02-14 14:15:48 -0500 | [diff] [blame] | 83 | bool disableGpuYUVConversion() const { return fContext->fDisableGpuYUVConversion; } |
Brian Osman | 8a83ca4 | 2018-02-12 14:32:17 -0500 | [diff] [blame] | 84 | bool sharpenMipmappedTextures() const { return fContext->fSharpenMipmappedTextures; } |
Brian Osman | 46da1cc | 2017-02-14 14:15:48 -0500 | [diff] [blame] | 85 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 86 | /** |
| 87 | * Call to ensure all drawing to the context has been issued to the |
| 88 | * underlying 3D API. |
| 89 | * The 'proxy' parameter is a hint. If it is supplied the context will guarantee that |
| 90 | * the draws required for that proxy are flushed but it could do more. If no 'proxy' is |
| 91 | * provided then all current work will be flushed. |
| 92 | */ |
| 93 | void flush(GrSurfaceProxy*); |
| 94 | |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 95 | /** |
| 96 | * Registers an object for flush-related callbacks. (See GrOnFlushCallbackObject.) |
| 97 | * |
| 98 | * NOTE: the drawing manager tracks this object as a raw pointer; it is up to the caller to |
| 99 | * ensure its lifetime is tied to that of the context. |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 100 | */ |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 101 | void addOnFlushCallbackObject(GrOnFlushCallbackObject*); |
| 102 | |
| 103 | void testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject*); |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 104 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 105 | /** |
| 106 | * After this returns any pending writes to the surface will have been issued to the |
| 107 | * backend 3D API. |
| 108 | */ |
| 109 | void flushSurfaceWrites(GrSurfaceProxy*); |
| 110 | |
| 111 | /** |
| 112 | * After this returns any pending reads or writes to the surface will have been issued to the |
| 113 | * backend 3D API. |
| 114 | */ |
| 115 | void flushSurfaceIO(GrSurfaceProxy*); |
| 116 | |
| 117 | /** |
| 118 | * Finalizes all pending reads and writes to the surface and also performs an MSAA resolve |
| 119 | * if necessary. |
| 120 | * |
| 121 | * It is not necessary to call this before reading the render target via Skia/GrContext. |
| 122 | * GrContext will detect when it must perform a resolve before reading pixels back from the |
| 123 | * surface or using it as a texture. |
| 124 | */ |
| 125 | void prepareSurfaceForExternalIO(GrSurfaceProxy*); |
| 126 | |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 127 | /** |
| 128 | * These flags can be used with the read/write pixels functions below. |
| 129 | */ |
| 130 | enum PixelOpsFlags { |
| 131 | /** The GrContext will not be flushed before the surface read or write. This means that |
| 132 | the read or write may occur before previous draws have executed. */ |
| 133 | kDontFlush_PixelOpsFlag = 0x1, |
| 134 | /** Any surface writes should be flushed to the backend 3D API after the surface operation |
| 135 | is complete */ |
| 136 | kFlushWrites_PixelOp = 0x2, |
| 137 | /** The src for write or dst read is unpremultiplied. This is only respected if both the |
| 138 | config src and dst configs are an RGBA/BGRA 8888 format. */ |
| 139 | kUnpremul_PixelOpsFlag = 0x4, |
| 140 | }; |
| 141 | |
| 142 | /** |
Brian Salomon | d494f6e | 2018-06-01 14:13:43 -0400 | [diff] [blame] | 143 | * Reads a rectangle of pixels from a surface. |
Brian Salomon | 19eaf2d | 2018-03-19 16:06:44 -0400 | [diff] [blame] | 144 | * |
Robert Phillips | f41c22f | 2017-04-18 07:48:58 -0400 | [diff] [blame] | 145 | * @param src the surface context to read from. |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 146 | * @param left left edge of the rectangle to read (inclusive) |
| 147 | * @param top top edge of the rectangle to read (inclusive) |
| 148 | * @param width width of rectangle to read in pixels. |
| 149 | * @param height height of rectangle to read in pixels. |
Brian Salomon | 19eaf2d | 2018-03-19 16:06:44 -0400 | [diff] [blame] | 150 | * @param dstColorType the color type of the destination buffer |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 151 | * @param dstColorSpace color space of the destination buffer |
| 152 | * @param buffer memory to read the rectangle into. |
| 153 | * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly |
| 154 | * packed. |
| 155 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| 156 | * |
| 157 | * @return true if the read succeeded, false if not. The read can fail because of an unsupported |
| 158 | * pixel configs |
| 159 | */ |
Brian Salomon | c320b15 | 2018-02-20 14:05:36 -0500 | [diff] [blame] | 160 | bool readSurfacePixels(GrSurfaceContext* src, int left, int top, int width, int height, |
| 161 | GrColorType dstColorType, SkColorSpace* dstColorSpace, void* buffer, |
| 162 | size_t rowBytes = 0, uint32_t pixelOpsFlags = 0); |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 163 | |
| 164 | /** |
Brian Salomon | d494f6e | 2018-06-01 14:13:43 -0400 | [diff] [blame] | 165 | * Writes a rectangle of pixels to a surface. |
Brian Salomon | 5f33a8c | 2018-02-26 14:32:39 -0500 | [diff] [blame] | 166 | * |
Robert Phillips | f41c22f | 2017-04-18 07:48:58 -0400 | [diff] [blame] | 167 | * @param dst the surface context to write to. |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 168 | * @param left left edge of the rectangle to write (inclusive) |
| 169 | * @param top top edge of the rectangle to write (inclusive) |
| 170 | * @param width width of rectangle to write in pixels. |
| 171 | * @param height height of rectangle to write in pixels. |
Brian Salomon | 5f33a8c | 2018-02-26 14:32:39 -0500 | [diff] [blame] | 172 | * @param srcColorType the color type of the source buffer |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 173 | * @param srcColorSpace color space of the source buffer |
| 174 | * @param buffer memory to read pixels from |
| 175 | * @param rowBytes number of bytes between consecutive rows. Zero |
| 176 | * means rows are tightly packed. |
| 177 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| 178 | * @return true if the write succeeded, false if not. The write can fail because of an |
| 179 | * unsupported combination of surface and src configs. |
| 180 | */ |
Brian Salomon | c320b15 | 2018-02-20 14:05:36 -0500 | [diff] [blame] | 181 | bool writeSurfacePixels(GrSurfaceContext* dst, int left, int top, int width, int height, |
| 182 | GrColorType srcColorType, SkColorSpace* srcColorSpace, |
| 183 | const void* buffer, size_t rowBytes, uint32_t pixelOpsFlags = 0); |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 184 | |
Greg Daniel | bdf12ad | 2018-10-12 09:31:11 -0400 | [diff] [blame] | 185 | GrBackendApi getBackend() const { return fContext->fBackend; } |
Greg Daniel | fc978fd | 2017-04-13 09:54:12 -0400 | [diff] [blame] | 186 | |
Brian Osman | 5127998 | 2017-08-23 10:12:00 -0400 | [diff] [blame] | 187 | SkTaskGroup* getTaskGroup() { return fContext->fTaskGroup.get(); } |
| 188 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 189 | GrProxyProvider* proxyProvider() { return fContext->fProxyProvider; } |
| 190 | const GrProxyProvider* proxyProvider() const { return fContext->fProxyProvider; } |
| 191 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 192 | GrResourceProvider* resourceProvider() { return fContext->fResourceProvider; } |
| 193 | const GrResourceProvider* resourceProvider() const { return fContext->fResourceProvider; } |
| 194 | |
| 195 | GrResourceCache* getResourceCache() { return fContext->fResourceCache; } |
| 196 | |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 197 | GrGpu* getGpu() { return fContext->fGpu.get(); } |
| 198 | const GrGpu* getGpu() const { return fContext->fGpu.get(); } |
| 199 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 200 | GrGlyphCache* getGlyphCache() { return fContext->fGlyphCache; } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 201 | GrTextBlobCache* getTextBlobCache() { return fContext->fTextBlobCache.get(); } |
Robert Phillips | 1056eb8 | 2018-03-01 14:16:41 -0500 | [diff] [blame] | 202 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 203 | // This accessor should only ever be called by the GrOpFlushState. |
Robert Phillips | 5a66efb | 2018-03-07 15:13:18 -0500 | [diff] [blame] | 204 | GrAtlasManager* getAtlasManager() { |
| 205 | return fContext->onGetAtlasManager(); |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 206 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 207 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 208 | void moveOpListsToDDL(SkDeferredDisplayList*); |
| 209 | void copyOpListsFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest); |
| 210 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 211 | /** |
| 212 | * Purge all the unlocked resources from the cache. |
| 213 | * This entry point is mainly meant for timing texture uploads |
| 214 | * and is not defined in normal builds of Skia. |
| 215 | */ |
| 216 | void purgeAllUnlockedResources_ForTesting(); |
| 217 | |
| 218 | |
| 219 | /* |
| 220 | * Create a new render target context backed by a deferred-style |
| 221 | * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for |
| 222 | * renderTargetContexts created via this entry point. |
| 223 | */ |
| 224 | sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 225 | const GrBackendFormat& format, |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 226 | SkBackingFit fit, |
| 227 | int width, int height, |
| 228 | GrPixelConfig config, |
| 229 | sk_sp<SkColorSpace> colorSpace, |
| 230 | int sampleCnt = 1, |
| 231 | GrMipMapped = GrMipMapped::kNo, |
| 232 | GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| 233 | const SkSurfaceProps* surfaceProps = nullptr, |
| 234 | SkBudgeted = SkBudgeted::kYes); |
| 235 | /* |
| 236 | * This method will attempt to create a renderTargetContext that has, at least, the number of |
| 237 | * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be |
| 238 | * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). |
| 239 | * SRGB-ness will be preserved. |
| 240 | */ |
| 241 | sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 242 | const GrBackendFormat& format, |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 243 | SkBackingFit fit, |
| 244 | int width, int height, |
| 245 | GrPixelConfig config, |
| 246 | sk_sp<SkColorSpace> colorSpace, |
| 247 | int sampleCnt = 1, |
| 248 | GrMipMapped = GrMipMapped::kNo, |
| 249 | GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| 250 | const SkSurfaceProps* surfaceProps = nullptr, |
| 251 | SkBudgeted budgeted = SkBudgeted::kYes); |
| 252 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 253 | /** Reset GPU stats */ |
| 254 | void resetGpuStats() const ; |
| 255 | |
| 256 | /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ |
| 257 | void dumpCacheStats(SkString*) const; |
| 258 | void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const; |
| 259 | void printCacheStats() const; |
| 260 | |
| 261 | /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ |
| 262 | void dumpGpuStats(SkString*) const; |
| 263 | void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const; |
| 264 | void printGpuStats() const; |
| 265 | |
| 266 | /** Returns a string with detailed information about the context & GPU, in JSON format. */ |
| 267 | SkString dump() const; |
| 268 | |
| 269 | /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge. |
| 270 | this is for testing only */ |
| 271 | void setTextBlobCacheLimit_ForTesting(size_t bytes); |
| 272 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 273 | /** Get pointer to atlas texture for given mask format. Note that this wraps an |
| 274 | actively mutating texture in an SkImage. This could yield unexpected results |
| 275 | if it gets cached or used more generally. */ |
| 276 | sk_sp<SkImage> getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index = 0); |
| 277 | |
| 278 | GrAuditTrail* getAuditTrail() { return &fContext->fAuditTrail; } |
| 279 | |
| 280 | GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; } |
| 281 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 282 | sk_sp<GrSkSLFPFactoryCache> getFPFactoryCache() { |
| 283 | return fContext->fFPFactoryCache; |
| 284 | } |
| 285 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 286 | /** This is only useful for debug purposes */ |
| 287 | SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fContext->fSingleOwner; } ) |
| 288 | |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 289 | private: |
| 290 | explicit GrContextPriv(GrContext* context) : fContext(context) {} |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 291 | GrContextPriv(const GrContextPriv&); // unimpl |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 292 | GrContextPriv& operator=(const GrContextPriv&); // unimpl |
| 293 | |
| 294 | // No taking addresses of this type. |
| 295 | const GrContextPriv* operator&() const; |
| 296 | GrContextPriv* operator&(); |
| 297 | |
| 298 | GrContext* fContext; |
| 299 | |
| 300 | friend class GrContext; // to construct/copy this type. |
| 301 | }; |
| 302 | |
| 303 | inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); } |
| 304 | |
| 305 | inline const GrContextPriv GrContext::contextPriv () const { |
| 306 | return GrContextPriv(const_cast<GrContext*>(this)); |
| 307 | } |
| 308 | |
| 309 | #endif |