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 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 76 | sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>, |
| 77 | sk_sp<SkColorSpace> = nullptr, |
| 78 | const SkSurfaceProps* = nullptr); |
| 79 | |
| 80 | sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrBackendFormat&, |
| 81 | const GrSurfaceDesc&, |
| 82 | GrSurfaceOrigin, |
| 83 | GrMipMapped, |
| 84 | SkBackingFit, |
| 85 | SkBudgeted, |
| 86 | sk_sp<SkColorSpace> colorSpace = nullptr, |
| 87 | const SkSurfaceProps* = nullptr); |
| 88 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 89 | /* |
| 90 | * Create a new render target context backed by a deferred-style |
| 91 | * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for |
| 92 | * renderTargetContexts created via this entry point. |
| 93 | */ |
| 94 | sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext( |
| 95 | const GrBackendFormat& format, |
| 96 | SkBackingFit fit, |
| 97 | int width, int height, |
| 98 | GrPixelConfig config, |
| 99 | sk_sp<SkColorSpace> colorSpace, |
| 100 | int sampleCnt = 1, |
| 101 | GrMipMapped = GrMipMapped::kNo, |
| 102 | GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| 103 | const SkSurfaceProps* surfaceProps = nullptr, |
| 104 | SkBudgeted = SkBudgeted::kYes); |
| 105 | |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 106 | /* |
| 107 | * This method will attempt to create a renderTargetContext that has, at least, the number of |
| 108 | * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be |
| 109 | * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). |
| 110 | * SRGB-ness will be preserved. |
| 111 | */ |
| 112 | sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback( |
| 113 | const GrBackendFormat& format, |
| 114 | SkBackingFit fit, |
| 115 | int width, int height, |
| 116 | GrPixelConfig config, |
| 117 | sk_sp<SkColorSpace> colorSpace, |
| 118 | int sampleCnt = 1, |
| 119 | GrMipMapped = GrMipMapped::kNo, |
| 120 | GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| 121 | const SkSurfaceProps* surfaceProps = nullptr, |
| 122 | SkBudgeted budgeted = SkBudgeted::kYes); |
| 123 | |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 124 | GrAuditTrail* auditTrail() { return fContext->auditTrail(); } |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 125 | |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 126 | /** |
| 127 | * Create a GrContext without a resource cache |
| 128 | */ |
Kevin Lubick | b5502b2 | 2018-03-12 10:17:06 -0400 | [diff] [blame] | 129 | static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&); |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 130 | |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 131 | sk_sp<GrTextureContext> makeBackendTextureContext(const GrBackendTexture& tex, |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 132 | GrSurfaceOrigin origin, |
Brian Osman | c1e3705 | 2017-03-09 14:19:20 -0500 | [diff] [blame] | 133 | sk_sp<SkColorSpace> colorSpace); |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 134 | |
Greg Daniel | 8ce7991 | 2019-02-05 10:08:43 -0500 | [diff] [blame] | 135 | // These match the definitions in SkSurface & GrSurface.h, for whence they came |
| 136 | typedef void* ReleaseContext; |
| 137 | typedef void (*ReleaseProc)(ReleaseContext); |
| 138 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 139 | sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext( |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 140 | const GrBackendTexture& tex, |
| 141 | GrSurfaceOrigin origin, |
| 142 | int sampleCnt, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 143 | sk_sp<SkColorSpace> colorSpace, |
Greg Daniel | 8ce7991 | 2019-02-05 10:08:43 -0500 | [diff] [blame] | 144 | const SkSurfaceProps* = nullptr, |
| 145 | ReleaseProc = nullptr, |
| 146 | ReleaseContext = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 147 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 148 | sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext( |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 149 | const GrBackendRenderTarget&, |
| 150 | GrSurfaceOrigin origin, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 151 | sk_sp<SkColorSpace> colorSpace, |
Greg Daniel | 8ce7991 | 2019-02-05 10:08:43 -0500 | [diff] [blame] | 152 | const SkSurfaceProps* = nullptr, |
| 153 | ReleaseProc = nullptr, |
| 154 | ReleaseContext = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 155 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 156 | sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext( |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 157 | const GrBackendTexture& tex, |
| 158 | GrSurfaceOrigin origin, |
| 159 | int sampleCnt, |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 160 | sk_sp<SkColorSpace> colorSpace, |
| 161 | const SkSurfaceProps* = nullptr); |
| 162 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 163 | sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext( |
| 164 | const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr); |
| 165 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 166 | /** |
Brian Salomon | f9a1fdf | 2019-05-09 10:30:12 -0400 | [diff] [blame] | 167 | * Finalizes all pending reads and writes to the surfaces and also performs an MSAA resolves |
| 168 | * if necessary. The GrSurfaceProxy array is treated as a hint. If it is supplied the context |
| 169 | * will guarantee that the draws required for those proxies are flushed but it could do more. |
| 170 | * If no array is provided then all current work will be flushed. |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 171 | * |
| 172 | * It is not necessary to call this before reading the render target via Skia/GrContext. |
| 173 | * GrContext will detect when it must perform a resolve before reading pixels back from the |
| 174 | * surface or using it as a texture. |
| 175 | */ |
Brian Salomon | f9a1fdf | 2019-05-09 10:30:12 -0400 | [diff] [blame] | 176 | GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy*[], int numProxies, const GrFlushInfo&); |
| 177 | |
| 178 | /** Version of above that flushes for a single proxy and uses a default GrFlushInfo. Null is |
| 179 | * allowed. */ |
Greg Daniel | 4aa13e7 | 2019-04-15 14:42:20 -0400 | [diff] [blame] | 180 | void flushSurface(GrSurfaceProxy*); |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 181 | |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 182 | /** |
| 183 | * These flags can be used with the read/write pixels functions below. |
| 184 | */ |
| 185 | enum PixelOpsFlags { |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 186 | /** The src for write or dst read is unpremultiplied. This is only respected if both the |
| 187 | config src and dst configs are an RGBA/BGRA 8888 format. */ |
| 188 | kUnpremul_PixelOpsFlag = 0x4, |
| 189 | }; |
| 190 | |
| 191 | /** |
Brian Salomon | d494f6e | 2018-06-01 14:13:43 -0400 | [diff] [blame] | 192 | * Reads a rectangle of pixels from a surface. |
Brian Salomon | 19eaf2d | 2018-03-19 16:06:44 -0400 | [diff] [blame] | 193 | * |
Robert Phillips | f41c22f | 2017-04-18 07:48:58 -0400 | [diff] [blame] | 194 | * @param src the surface context to read from. |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 195 | * @param left left edge of the rectangle to read (inclusive) |
| 196 | * @param top top edge of the rectangle to read (inclusive) |
| 197 | * @param width width of rectangle to read in pixels. |
| 198 | * @param height height of rectangle to read in pixels. |
Brian Salomon | 19eaf2d | 2018-03-19 16:06:44 -0400 | [diff] [blame] | 199 | * @param dstColorType the color type of the destination buffer |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 200 | * @param dstColorSpace color space of the destination buffer |
| 201 | * @param buffer memory to read the rectangle into. |
| 202 | * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly |
| 203 | * packed. |
| 204 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| 205 | * |
| 206 | * @return true if the read succeeded, false if not. The read can fail because of an unsupported |
| 207 | * pixel configs |
| 208 | */ |
Brian Salomon | c320b15 | 2018-02-20 14:05:36 -0500 | [diff] [blame] | 209 | bool readSurfacePixels(GrSurfaceContext* src, int left, int top, int width, int height, |
| 210 | GrColorType dstColorType, SkColorSpace* dstColorSpace, void* buffer, |
| 211 | size_t rowBytes = 0, uint32_t pixelOpsFlags = 0); |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 212 | |
| 213 | /** |
Brian Salomon | d494f6e | 2018-06-01 14:13:43 -0400 | [diff] [blame] | 214 | * Writes a rectangle of pixels to a surface. |
Brian Salomon | 5f33a8c | 2018-02-26 14:32:39 -0500 | [diff] [blame] | 215 | * |
Robert Phillips | f41c22f | 2017-04-18 07:48:58 -0400 | [diff] [blame] | 216 | * @param dst the surface context to write to. |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 217 | * @param left left edge of the rectangle to write (inclusive) |
| 218 | * @param top top edge of the rectangle to write (inclusive) |
| 219 | * @param width width of rectangle to write in pixels. |
| 220 | * @param height height of rectangle to write in pixels. |
Brian Salomon | 5f33a8c | 2018-02-26 14:32:39 -0500 | [diff] [blame] | 221 | * @param srcColorType the color type of the source buffer |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 222 | * @param srcColorSpace color space of the source buffer |
| 223 | * @param buffer memory to read pixels from |
| 224 | * @param rowBytes number of bytes between consecutive rows. Zero |
| 225 | * means rows are tightly packed. |
| 226 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| 227 | * @return true if the write succeeded, false if not. The write can fail because of an |
| 228 | * unsupported combination of surface and src configs. |
| 229 | */ |
Brian Salomon | c320b15 | 2018-02-20 14:05:36 -0500 | [diff] [blame] | 230 | bool writeSurfacePixels(GrSurfaceContext* dst, int left, int top, int width, int height, |
| 231 | GrColorType srcColorType, SkColorSpace* srcColorSpace, |
| 232 | const void* buffer, size_t rowBytes, uint32_t pixelOpsFlags = 0); |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 233 | |
Brian Osman | 5127998 | 2017-08-23 10:12:00 -0400 | [diff] [blame] | 234 | SkTaskGroup* getTaskGroup() { return fContext->fTaskGroup.get(); } |
| 235 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 236 | GrResourceProvider* resourceProvider() { return fContext->fResourceProvider; } |
| 237 | const GrResourceProvider* resourceProvider() const { return fContext->fResourceProvider; } |
| 238 | |
| 239 | GrResourceCache* getResourceCache() { return fContext->fResourceCache; } |
| 240 | |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 241 | GrGpu* getGpu() { return fContext->fGpu.get(); } |
| 242 | const GrGpu* getGpu() const { return fContext->fGpu.get(); } |
| 243 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 244 | // This accessor should only ever be called by the GrOpFlushState. |
Robert Phillips | 5a66efb | 2018-03-07 15:13:18 -0500 | [diff] [blame] | 245 | GrAtlasManager* getAtlasManager() { |
| 246 | return fContext->onGetAtlasManager(); |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 247 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 248 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 249 | void moveOpListsToDDL(SkDeferredDisplayList*); |
| 250 | void copyOpListsFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest); |
| 251 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 252 | GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; } |
Brian Osman | 5e7fbfd | 2019-05-03 13:13:35 -0400 | [diff] [blame] | 253 | GrContextOptions::ShaderErrorHandler* getShaderErrorHandler() const { |
| 254 | return fContext->fShaderErrorHandler; |
| 255 | } |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 256 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 257 | #ifdef SK_ENABLE_DUMP_GPU |
| 258 | /** Returns a string with detailed information about the context & GPU, in JSON format. */ |
| 259 | SkString dump() const; |
| 260 | #endif |
| 261 | |
| 262 | #if GR_TEST_UTILS |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 263 | /** Reset GPU stats */ |
| 264 | void resetGpuStats() const ; |
| 265 | |
| 266 | /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ |
| 267 | void dumpCacheStats(SkString*) const; |
| 268 | void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const; |
| 269 | void printCacheStats() const; |
| 270 | |
| 271 | /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ |
| 272 | void dumpGpuStats(SkString*) const; |
| 273 | void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const; |
| 274 | void printGpuStats() const; |
| 275 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 276 | /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge. |
| 277 | this is for testing only */ |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 278 | void testingOnly_setTextBlobCacheLimit(size_t bytes); |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 279 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 280 | /** Get pointer to atlas texture for given mask format. Note that this wraps an |
| 281 | actively mutating texture in an SkImage. This could yield unexpected results |
| 282 | if it gets cached or used more generally. */ |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 283 | sk_sp<SkImage> testingOnly_getFontAtlasImage(GrMaskFormat format, unsigned int index = 0); |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 284 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 285 | /** |
| 286 | * Purge all the unlocked resources from the cache. |
| 287 | * This entry point is mainly meant for timing texture uploads |
| 288 | * and is not defined in normal builds of Skia. |
| 289 | */ |
| 290 | void testingOnly_purgeAllUnlockedResources(); |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 291 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 292 | void testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject*); |
| 293 | #endif |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 294 | |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 295 | private: |
| 296 | explicit GrContextPriv(GrContext* context) : fContext(context) {} |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 297 | GrContextPriv(const GrContextPriv&); // unimpl |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 298 | GrContextPriv& operator=(const GrContextPriv&); // unimpl |
| 299 | |
| 300 | // No taking addresses of this type. |
| 301 | const GrContextPriv* operator&() const; |
| 302 | GrContextPriv* operator&(); |
| 303 | |
| 304 | GrContext* fContext; |
| 305 | |
| 306 | friend class GrContext; // to construct/copy this type. |
| 307 | }; |
| 308 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 309 | inline GrContextPriv GrContext::priv() { return GrContextPriv(this); } |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 310 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 311 | inline const GrContextPriv GrContext::priv() const { |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 312 | return GrContextPriv(const_cast<GrContext*>(this)); |
| 313 | } |
| 314 | |
| 315 | #endif |