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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrContext.h" |
| 12 | #include "src/gpu/GrSurfaceContext.h" |
| 13 | #include "src/gpu/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 | bc42944 | 2019-02-20 08:26:03 -0500 | [diff] [blame] | 21 | class GrSkSLFPFactoryCache; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 22 | class GrSurfaceProxy; |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 23 | class GrTextureContext; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 24 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 25 | class SkDeferredDisplayList; |
Robert Phillips | bc42944 | 2019-02-20 08:26:03 -0500 | [diff] [blame] | 26 | class SkTaskGroup; |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 27 | |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 28 | /** Class that adds methods to GrContext that are only intended for use internal to Skia. |
| 29 | This class is purely a privileged window into GrContext. It should never have additional |
| 30 | data members or virtual methods. */ |
| 31 | class GrContextPriv { |
| 32 | public: |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 33 | |
| 34 | // from GrContext_Base |
Robert Phillips | fd0d970 | 2019-02-01 10:19:42 -0500 | [diff] [blame] | 35 | uint32_t contextID() const { return fContext->contextID(); } |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 36 | |
Robert Phillips | fe0963c | 2019-02-07 13:25:07 -0500 | [diff] [blame] | 37 | bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); } |
| 38 | |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 39 | const GrContextOptions& options() const { return fContext->options(); } |
| 40 | |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 41 | const GrCaps* caps() const { return fContext->caps(); } |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 42 | sk_sp<const GrCaps> refCaps() const; |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 43 | |
| 44 | sk_sp<GrSkSLFPFactoryCache> fpFactoryCache(); |
| 45 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 46 | GrImageContext* asImageContext() { return fContext->asImageContext(); } |
| 47 | GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); } |
| 48 | GrContext* asDirectContext() { return fContext->asDirectContext(); } |
| 49 | |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 50 | // from GrImageContext |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 51 | GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); } |
| 52 | const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); } |
| 53 | |
Robert Phillips | 6a6de56 | 2019-02-15 15:19:15 -0500 | [diff] [blame] | 54 | bool abandoned() const { return fContext->abandoned(); } |
| 55 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 56 | /** This is only useful for debug purposes */ |
| 57 | SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } ) |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 58 | |
| 59 | // from GrRecordingContext |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 60 | GrDrawingManager* drawingManager() { return fContext->drawingManager(); } |
| 61 | |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 62 | sk_sp<GrOpMemoryPool> refOpMemoryPool(); |
| 63 | GrOpMemoryPool* opMemoryPool() { return fContext->opMemoryPool(); } |
| 64 | |
Herb Derby | a00da61 | 2019-03-04 17:10:01 -0500 | [diff] [blame] | 65 | GrStrikeCache* getGrStrikeCache() { return fContext->getGrStrikeCache(); } |
Robert Phillips | 2184fb7 | 2019-02-21 16:11:41 -0500 | [diff] [blame] | 66 | GrTextBlobCache* getTextBlobCache() { return fContext->getTextBlobCache(); } |
| 67 | |
Robert Phillips | c5058a6 | 2019-02-15 12:52:59 -0500 | [diff] [blame] | 68 | /** |
| 69 | * Registers an object for flush-related callbacks. (See GrOnFlushCallbackObject.) |
| 70 | * |
| 71 | * NOTE: the drawing manager tracks this object as a raw pointer; it is up to the caller to |
| 72 | * ensure its lifetime is tied to that of the context. |
| 73 | */ |
| 74 | void addOnFlushCallbackObject(GrOnFlushCallbackObject*); |
| 75 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 76 | std::unique_ptr<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>, |
| 77 | GrColorType, |
| 78 | SkAlphaType, |
| 79 | sk_sp<SkColorSpace> = nullptr, |
| 80 | const SkSurfaceProps* = nullptr); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 81 | |
Brian Salomon | 947efe2 | 2019-07-16 15:36:11 -0400 | [diff] [blame] | 82 | /** Create a new texture context backed by a deferred-style GrTextureProxy. */ |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 83 | std::unique_ptr<GrTextureContext> makeDeferredTextureContext( |
Brian Salomon | 947efe2 | 2019-07-16 15:36:11 -0400 | [diff] [blame] | 84 | SkBackingFit, |
| 85 | int width, |
| 86 | int height, |
| 87 | GrColorType, |
| 88 | SkAlphaType, |
| 89 | sk_sp<SkColorSpace>, |
| 90 | GrMipMapped = GrMipMapped::kNo, |
| 91 | GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin, |
| 92 | SkBudgeted = SkBudgeted::kYes, |
| 93 | GrProtected = GrProtected::kNo); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 94 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 95 | /* |
| 96 | * Create a new render target context backed by a deferred-style |
| 97 | * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for |
| 98 | * renderTargetContexts created via this entry point. |
| 99 | */ |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 100 | std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 101 | SkBackingFit fit, |
| 102 | int width, |
| 103 | int height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 104 | GrColorType, |
| 105 | sk_sp<SkColorSpace> colorSpace, |
| 106 | int sampleCnt = 1, |
| 107 | GrMipMapped = GrMipMapped::kNo, |
| 108 | GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| 109 | const SkSurfaceProps* surfaceProps = nullptr, |
| 110 | SkBudgeted = SkBudgeted::kYes, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 111 | GrProtected isProtected = GrProtected::kNo); |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 112 | |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 113 | /* |
| 114 | * This method will attempt to create a renderTargetContext that has, at least, the number of |
| 115 | * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be |
| 116 | * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). |
| 117 | * SRGB-ness will be preserved. |
| 118 | */ |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 119 | std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 120 | SkBackingFit fit, |
| 121 | int width, |
| 122 | int height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 123 | GrColorType, |
| 124 | sk_sp<SkColorSpace> colorSpace, |
| 125 | int sampleCnt = 1, |
| 126 | GrMipMapped = GrMipMapped::kNo, |
| 127 | GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| 128 | const SkSurfaceProps* surfaceProps = nullptr, |
| 129 | SkBudgeted budgeted = SkBudgeted::kYes); |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 130 | |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 131 | GrAuditTrail* auditTrail() { return fContext->auditTrail(); } |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 132 | |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 133 | /** |
| 134 | * Create a GrContext without a resource cache |
| 135 | */ |
Kevin Lubick | b5502b2 | 2018-03-12 10:17:06 -0400 | [diff] [blame] | 136 | static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&); |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 137 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 138 | std::unique_ptr<GrTextureContext> makeBackendTextureContext(const GrBackendTexture&, |
| 139 | GrSurfaceOrigin, |
| 140 | GrColorType, |
| 141 | SkAlphaType, |
| 142 | sk_sp<SkColorSpace>); |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 143 | |
Greg Daniel | 8ce7991 | 2019-02-05 10:08:43 -0500 | [diff] [blame] | 144 | // These match the definitions in SkSurface & GrSurface.h, for whence they came |
| 145 | typedef void* ReleaseContext; |
| 146 | typedef void (*ReleaseProc)(ReleaseContext); |
| 147 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 148 | std::unique_ptr<GrRenderTargetContext> makeBackendTextureRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 149 | const GrBackendTexture& tex, |
| 150 | GrSurfaceOrigin origin, |
| 151 | int sampleCnt, |
| 152 | GrColorType, |
| 153 | sk_sp<SkColorSpace> colorSpace, |
| 154 | const SkSurfaceProps* = nullptr, |
| 155 | ReleaseProc = nullptr, |
| 156 | ReleaseContext = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 157 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 158 | std::unique_ptr<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 159 | const GrBackendRenderTarget&, |
| 160 | GrSurfaceOrigin origin, |
| 161 | GrColorType, |
| 162 | sk_sp<SkColorSpace> colorSpace, |
| 163 | const SkSurfaceProps* = nullptr, |
| 164 | ReleaseProc = nullptr, |
| 165 | ReleaseContext = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 166 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 167 | std::unique_ptr<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 168 | const GrBackendTexture& tex, |
| 169 | GrSurfaceOrigin origin, |
| 170 | int sampleCnt, |
| 171 | GrColorType, |
| 172 | sk_sp<SkColorSpace> colorSpace, |
| 173 | const SkSurfaceProps* = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 174 | |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 175 | std::unique_ptr<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext( |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 176 | const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr); |
| 177 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 178 | /** |
Brian Salomon | f9a1fdf | 2019-05-09 10:30:12 -0400 | [diff] [blame] | 179 | * Finalizes all pending reads and writes to the surfaces and also performs an MSAA resolves |
| 180 | * if necessary. The GrSurfaceProxy array is treated as a hint. If it is supplied the context |
| 181 | * will guarantee that the draws required for those proxies are flushed but it could do more. |
| 182 | * If no array is provided then all current work will be flushed. |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 183 | * |
| 184 | * It is not necessary to call this before reading the render target via Skia/GrContext. |
| 185 | * GrContext will detect when it must perform a resolve before reading pixels back from the |
| 186 | * surface or using it as a texture. |
| 187 | */ |
Brian Salomon | f9a1fdf | 2019-05-09 10:30:12 -0400 | [diff] [blame] | 188 | GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy*[], int numProxies, const GrFlushInfo&); |
| 189 | |
| 190 | /** Version of above that flushes for a single proxy and uses a default GrFlushInfo. Null is |
| 191 | * allowed. */ |
Greg Daniel | 4aa13e7 | 2019-04-15 14:42:20 -0400 | [diff] [blame] | 192 | void flushSurface(GrSurfaceProxy*); |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 193 | |
Greg Daniel | 6eb8c24 | 2019-06-05 10:22:24 -0400 | [diff] [blame] | 194 | /** |
| 195 | * Returns true if createPMToUPMEffect and createUPMToPMEffect will succeed. In other words, |
| 196 | * did we find a pair of round-trip preserving conversion effects? |
| 197 | */ |
| 198 | bool validPMUPMConversionExists(); |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 199 | |
| 200 | /** |
Greg Daniel | 6eb8c24 | 2019-06-05 10:22:24 -0400 | [diff] [blame] | 201 | * These functions create premul <-> unpremul effects, using the specialized round-trip effects |
| 202 | * from GrConfigConversionEffect. |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 203 | */ |
Greg Daniel | 6eb8c24 | 2019-06-05 10:22:24 -0400 | [diff] [blame] | 204 | std::unique_ptr<GrFragmentProcessor> createPMToUPMEffect(std::unique_ptr<GrFragmentProcessor>); |
| 205 | std::unique_ptr<GrFragmentProcessor> createUPMToPMEffect(std::unique_ptr<GrFragmentProcessor>); |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 206 | |
Brian Osman | 5127998 | 2017-08-23 10:12:00 -0400 | [diff] [blame] | 207 | SkTaskGroup* getTaskGroup() { return fContext->fTaskGroup.get(); } |
| 208 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 209 | GrResourceProvider* resourceProvider() { return fContext->fResourceProvider; } |
| 210 | const GrResourceProvider* resourceProvider() const { return fContext->fResourceProvider; } |
| 211 | |
| 212 | GrResourceCache* getResourceCache() { return fContext->fResourceCache; } |
| 213 | |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 214 | GrGpu* getGpu() { return fContext->fGpu.get(); } |
| 215 | const GrGpu* getGpu() const { return fContext->fGpu.get(); } |
| 216 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 217 | // This accessor should only ever be called by the GrOpFlushState. |
Robert Phillips | 5a66efb | 2018-03-07 15:13:18 -0500 | [diff] [blame] | 218 | GrAtlasManager* getAtlasManager() { |
| 219 | return fContext->onGetAtlasManager(); |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 220 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 221 | |
Chris Dalton | 6b49810 | 2019-08-01 14:14:52 -0600 | [diff] [blame] | 222 | void moveRenderTasksToDDL(SkDeferredDisplayList*); |
| 223 | void copyRenderTasksFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest); |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 224 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 225 | GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; } |
Brian Osman | 5e7fbfd | 2019-05-03 13:13:35 -0400 | [diff] [blame] | 226 | GrContextOptions::ShaderErrorHandler* getShaderErrorHandler() const { |
| 227 | return fContext->fShaderErrorHandler; |
| 228 | } |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 229 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 230 | #if GR_TEST_UTILS |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 231 | /** Reset GPU stats */ |
| 232 | void resetGpuStats() const ; |
| 233 | |
| 234 | /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ |
| 235 | void dumpCacheStats(SkString*) const; |
| 236 | void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const; |
| 237 | void printCacheStats() const; |
| 238 | |
| 239 | /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ |
| 240 | void dumpGpuStats(SkString*) const; |
| 241 | void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const; |
| 242 | void printGpuStats() const; |
| 243 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 244 | /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge. |
| 245 | this is for testing only */ |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 246 | void testingOnly_setTextBlobCacheLimit(size_t bytes); |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 247 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 248 | /** Get pointer to atlas texture for given mask format. Note that this wraps an |
| 249 | actively mutating texture in an SkImage. This could yield unexpected results |
| 250 | if it gets cached or used more generally. */ |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 251 | sk_sp<SkImage> testingOnly_getFontAtlasImage(GrMaskFormat format, unsigned int index = 0); |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 252 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 253 | /** |
| 254 | * Purge all the unlocked resources from the cache. |
| 255 | * This entry point is mainly meant for timing texture uploads |
| 256 | * and is not defined in normal builds of Skia. |
| 257 | */ |
| 258 | void testingOnly_purgeAllUnlockedResources(); |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 259 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 260 | void testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject*); |
| 261 | #endif |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 262 | |
Robert Phillips | cb1adb4 | 2019-06-10 15:09:34 -0400 | [diff] [blame] | 263 | // If possible, create a backend texture initialized with the provided pixmap data. The client |
| 264 | // should ensure that the returned backend texture is valid. |
| 265 | // If successful, the created backend texture will be compatible with the provided |
| 266 | // pixmap(s). |
| 267 | // If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired |
| 268 | // the data for all the mipmap levels must be provided. |
Robert Phillips | da2e67a | 2019-07-01 15:04:06 -0400 | [diff] [blame] | 269 | GrBackendTexture createBackendTexture(const SkPixmap srcData[], int numLevels, |
| 270 | GrRenderable, GrProtected); |
Robert Phillips | cb1adb4 | 2019-06-10 15:09:34 -0400 | [diff] [blame] | 271 | |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 272 | private: |
| 273 | explicit GrContextPriv(GrContext* context) : fContext(context) {} |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 274 | GrContextPriv(const GrContextPriv&); // unimpl |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 275 | GrContextPriv& operator=(const GrContextPriv&); // unimpl |
| 276 | |
| 277 | // No taking addresses of this type. |
| 278 | const GrContextPriv* operator&() const; |
| 279 | GrContextPriv* operator&(); |
| 280 | |
| 281 | GrContext* fContext; |
| 282 | |
| 283 | friend class GrContext; // to construct/copy this type. |
| 284 | }; |
| 285 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 286 | inline GrContextPriv GrContext::priv() { return GrContextPriv(this); } |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 287 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 288 | inline const GrContextPriv GrContext::priv() const { |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 289 | return GrContextPriv(const_cast<GrContext*>(this)); |
| 290 | } |
| 291 | |
| 292 | #endif |