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