bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * 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.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef GrContext_DEFINED |
| 9 | #define GrContext_DEFINED |
| 10 | |
joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 11 | #include "GrClip.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 12 | #include "GrColor.h" |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 13 | #include "GrPaint.h" |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 14 | #include "GrPathRendererChain.h" |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 15 | #include "GrRenderTarget.h" |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 16 | #include "GrTexture.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 17 | #include "SkMatrix.h" |
egdaniel | e61c411 | 2014-06-12 10:24:21 -0700 | [diff] [blame] | 18 | #include "SkPathEffect.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 19 | #include "SkTypes.h" |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 20 | |
jvanverth@google.com | bfe2b9d | 2013-09-06 16:57:29 +0000 | [diff] [blame] | 21 | class GrAARectRenderer; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 22 | class GrBatchFontCache; |
bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 23 | class GrDrawTarget; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 24 | class GrFragmentProcessor; |
bsalomon@google.com | 05ef510 | 2011-05-02 21:14:59 +0000 | [diff] [blame] | 25 | class GrGpu; |
egdaniel | bbcb38d | 2014-06-19 10:19:29 -0700 | [diff] [blame] | 26 | class GrGpuTraceMarker; |
bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 27 | class GrIndexBuffer; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 28 | class GrIndexBufferAllocPool; |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 29 | class GrLayerCache; |
commit-bot@chromium.org | 8131283 | 2013-03-22 18:34:09 +0000 | [diff] [blame] | 30 | class GrOvalRenderer; |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 31 | class GrPath; |
bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 32 | class GrPathRenderer; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 33 | class GrPipelineBuilder; |
bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 34 | class GrResourceEntry; |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 35 | class GrResourceCache; |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 36 | class GrTestTarget; |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 37 | class GrTextBlobCache; |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 38 | class GrTextContext; |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 39 | class GrTextureParams; |
bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 40 | class GrVertexBuffer; |
bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 41 | class GrVertexBufferAllocPool; |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 42 | class GrStrokeInfo; |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 43 | class GrSoftwarePathRenderer; |
joshualitt | 6e8cd96 | 2015-03-20 10:30:14 -0700 | [diff] [blame] | 44 | class SkGpuDevice; |
bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 45 | |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 46 | class SK_API GrContext : public SkRefCnt { |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 47 | public: |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 48 | SK_DECLARE_INST_COUNT(GrContext) |
| 49 | |
krajcevski | 9c6d4d7 | 2014-08-12 07:26:25 -0700 | [diff] [blame] | 50 | struct Options { |
| 51 | Options() : fDrawPathToCompressedTexture(false) { } |
| 52 | |
| 53 | // EXPERIMENTAL |
| 54 | // May be removed in the future, or may become standard depending |
| 55 | // on the outcomes of a variety of internal tests. |
| 56 | bool fDrawPathToCompressedTexture; |
| 57 | }; |
| 58 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 59 | /** |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 60 | * Creates a GrContext for a backend context. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 61 | */ |
krajcevski | 9c6d4d7 | 2014-08-12 07:26:25 -0700 | [diff] [blame] | 62 | static GrContext* Create(GrBackend, GrBackendContext, const Options* opts = NULL); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 63 | |
bsalomon | 3343557 | 2014-11-05 14:47:41 -0800 | [diff] [blame] | 64 | /** |
| 65 | * Only defined in test apps. |
| 66 | */ |
| 67 | static GrContext* CreateMockContext(); |
| 68 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 69 | virtual ~GrContext(); |
| 70 | |
| 71 | /** |
| 72 | * The GrContext normally assumes that no outsider is setting state |
| 73 | * within the underlying 3D API's context/device/whatever. This call informs |
| 74 | * the context that the state was modified and it should resend. Shouldn't |
| 75 | * be called frequently for good performance. |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 76 | * The flag bits, state, is dpendent on which backend is used by the |
| 77 | * context, either GL or D3D (possible in future). |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 78 | */ |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 79 | void resetContext(uint32_t state = kAll_GrBackendState); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 80 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 81 | /** |
robertphillips@google.com | cdb426d | 2012-09-24 19:33:59 +0000 | [diff] [blame] | 82 | * Callback function to allow classes to cleanup on GrContext destruction. |
| 83 | * The 'info' field is filled in with the 'info' passed to addCleanUp. |
| 84 | */ |
| 85 | typedef void (*PFCleanUpFunc)(const GrContext* context, void* info); |
| 86 | |
| 87 | /** |
| 88 | * Add a function to be called from within GrContext's destructor. |
| 89 | * This gives classes a chance to free resources held on a per context basis. |
| 90 | * The 'info' parameter will be stored and passed to the callback function. |
| 91 | */ |
| 92 | void addCleanUp(PFCleanUpFunc cleanUp, void* info) { |
| 93 | CleanUpData* entry = fCleanUpData.push(); |
| 94 | |
| 95 | entry->fFunc = cleanUp; |
| 96 | entry->fInfo = info; |
| 97 | } |
| 98 | |
| 99 | /** |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 100 | * Abandons all GPU resources and assumes the underlying backend 3D API |
| 101 | * context is not longer usable. Call this if you have lost the associated |
| 102 | * GPU context, and thus internal texture, buffer, etc. references/IDs are |
| 103 | * now invalid. Should be called even when GrContext is no longer going to |
| 104 | * be used for two reasons: |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 105 | * 1) ~GrContext will not try to free the objects in the 3D API. |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 106 | * 2) Any GrGpuResources created by this GrContext that outlive |
| 107 | * will be marked as invalid (GrGpuResource::wasDestroyed()) and |
| 108 | * when they're destroyed no 3D API calls will be made. |
| 109 | * Content drawn since the last GrContext::flush() may be lost. After this |
| 110 | * function is called the only valid action on the GrContext or |
| 111 | * GrGpuResources it created is to destroy them. |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 112 | */ |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 113 | void abandonContext(); |
| 114 | void contextDestroyed() { this->abandonContext(); } // legacy alias |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 115 | |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 116 | /////////////////////////////////////////////////////////////////////////// |
| 117 | // Resource Cache |
| 118 | |
| 119 | /** |
| 120 | * Return the current GPU resource cache limits. |
| 121 | * |
| 122 | * @param maxResources If non-null, returns maximum number of resources that |
| 123 | * can be held in the cache. |
| 124 | * @param maxResourceBytes If non-null, returns maximum number of bytes of |
| 125 | * video memory that can be held in the cache. |
| 126 | */ |
| 127 | void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const; |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Gets the current GPU resource cache usage. |
| 131 | * |
| 132 | * @param resourceCount If non-null, returns the number of resources that are held in the |
| 133 | * cache. |
| 134 | * @param maxResourceBytes If non-null, returns the total number of bytes of video memory held |
| 135 | * in the cache. |
| 136 | */ |
| 137 | void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const; |
| 138 | |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 139 | /** |
| 140 | * Specify the GPU resource cache limits. If the current cache exceeds either |
| 141 | * of these, it will be purged (LRU) to keep the cache within these limits. |
| 142 | * |
| 143 | * @param maxResources The maximum number of resources that can be held in |
| 144 | * the cache. |
| 145 | * @param maxResourceBytes The maximum number of bytes of video memory |
| 146 | * that can be held in the cache. |
| 147 | */ |
| 148 | void setResourceCacheLimits(int maxResources, size_t maxResourceBytes); |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 149 | |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 150 | /** |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 151 | * Frees GPU created by the context. Can be called to reduce GPU memory |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 152 | * pressure. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 153 | */ |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 154 | void freeGpuResources(); |
| 155 | |
bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 156 | /** |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 157 | * This method should be called whenever a GrResource is unreffed or |
| 158 | * switched from exclusive to non-exclusive. This |
| 159 | * gives the resource cache a chance to discard unneeded resources. |
| 160 | * Note: this entry point will be removed once totally ref-driven |
| 161 | * cache maintenance is implemented. |
bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 162 | */ |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 163 | void purgeCache(); |
bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 164 | |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 165 | /** |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 166 | * Purge all the unlocked resources from the cache. |
| 167 | * This entry point is mainly meant for timing texture uploads |
| 168 | * and is not defined in normal builds of Skia. |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 169 | */ |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 170 | void purgeAllUnlockedResources(); |
| 171 | |
bsalomon | f99e961 | 2015-02-19 08:24:16 -0800 | [diff] [blame] | 172 | /** |
| 173 | * Sets a unique key on the resource. Upon key collision this resource takes the place of the |
| 174 | * previous resource that had the key. |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 175 | */ |
bsalomon | f99e961 | 2015-02-19 08:24:16 -0800 | [diff] [blame] | 176 | void addResourceToCache(const GrUniqueKey&, GrGpuResource*); |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 177 | |
| 178 | /** |
| 179 | * Finds a resource in the cache, based on the specified key. This is intended for use in |
| 180 | * conjunction with addResourceToCache(). The return value will be NULL if not found. The |
| 181 | * caller must balance with a call to unref(). |
| 182 | */ |
bsalomon | 8718aaf | 2015-02-19 07:24:21 -0800 | [diff] [blame] | 183 | GrGpuResource* findAndRefCachedResource(const GrUniqueKey&); |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 184 | |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 185 | /** Helper for casting resource to a texture. Caller must be sure that the resource cached |
| 186 | with the key is either NULL or a texture and not another resource type. */ |
bsalomon | 8718aaf | 2015-02-19 07:24:21 -0800 | [diff] [blame] | 187 | GrTexture* findAndRefCachedTexture(const GrUniqueKey& key) { |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 188 | GrGpuResource* resource = this->findAndRefCachedResource(key); |
| 189 | if (resource) { |
| 190 | GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
| 191 | SkASSERT(texture); |
| 192 | return texture; |
| 193 | } |
| 194 | return NULL; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Determines whether a resource is in the cache. If the resource is found it |
| 199 | * will not be locked or returned. This call does not affect the priority of |
| 200 | * the resource for deletion. |
| 201 | */ |
bsalomon | 8718aaf | 2015-02-19 07:24:21 -0800 | [diff] [blame] | 202 | bool isResourceInCache(const GrUniqueKey& key) const; |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 203 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 204 | /////////////////////////////////////////////////////////////////////////// |
| 205 | // Textures |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 206 | |
| 207 | /** |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 208 | * Creates a new texture in the resource cache and returns it. The caller owns a |
bsalomon@google.com | 95ed55a | 2013-01-24 14:46:47 +0000 | [diff] [blame] | 209 | * ref on the returned texture which must be balanced by a call to unref. |
bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 210 | * |
bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 211 | * @param desc Description of the texture properties. |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 212 | * @param budgeted Does the texture count against the resource cache budget? |
| 213 | * @param srcData Pointer to the pixel values (optional). |
bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 214 | * @param rowBytes The number of bytes between rows of the texture. Zero |
krajcevski | 9c0e629 | 2014-06-02 07:38:14 -0700 | [diff] [blame] | 215 | * implies tightly packed rows. For compressed pixel configs, this |
| 216 | * field is ignored. |
bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 217 | */ |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 218 | GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, const void* srcData, |
| 219 | size_t rowBytes); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 220 | |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 221 | GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted) { |
| 222 | return this->createTexture(desc, budgeted, NULL, 0); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 223 | } |
| 224 | |
bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 225 | /** |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 226 | * DEPRECATED: use createTexture(). |
bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 227 | */ |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 228 | GrTexture* createUncachedTexture(const GrSurfaceDesc& desc, void* srcData, size_t rowBytes) { |
| 229 | return this->createTexture(desc, false, srcData, rowBytes); |
| 230 | } |
bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 231 | |
| 232 | /** |
| 233 | * Enum that determines how closely a returned scratch texture must match |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 234 | * a provided GrSurfaceDesc. TODO: Remove this. createTexture() should be used |
| 235 | * for exact match and refScratchTexture() should be replaced with createApproxTexture(). |
bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 236 | */ |
| 237 | enum ScratchTexMatch { |
| 238 | /** |
| 239 | * Finds a texture that exactly matches the descriptor. |
| 240 | */ |
| 241 | kExact_ScratchTexMatch, |
| 242 | /** |
| 243 | * Finds a texture that approximately matches the descriptor. Will be |
| 244 | * at least as large in width and height as desc specifies. If desc |
| 245 | * specifies that texture is a render target then result will be a |
| 246 | * render target. If desc specifies a render target and doesn't set the |
| 247 | * no stencil flag then result will have a stencil. Format and aa level |
| 248 | * will always match. |
| 249 | */ |
| 250 | kApprox_ScratchTexMatch |
| 251 | }; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 252 | |
| 253 | /** |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 254 | * Returns a texture matching the desc. It's contents are unknown. The caller |
bsalomon@google.com | 95ed55a | 2013-01-24 14:46:47 +0000 | [diff] [blame] | 255 | * owns a ref on the returned texture and must balance with a call to unref. |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 256 | * It is guaranteed that the same texture will not be returned in subsequent |
| 257 | * calls until all refs to the texture are dropped. |
bsalomon@google.com | a39f404 | 2011-04-26 13:18:16 +0000 | [diff] [blame] | 258 | * |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 259 | * Textures created by createTexture() hide the complications of |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 260 | * tiling non-power-of-two textures on APIs that don't support this (e.g. |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 261 | * unextended GLES2). NPOT scratch textures are not tilable on such APIs. |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 262 | * |
| 263 | * internalFlag is a temporary workaround until changes in the internal |
| 264 | * architecture are complete. Use the default value. |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 265 | * |
| 266 | * TODO: Once internal flag can be removed, this should be replaced with |
| 267 | * createApproxTexture() and exact textures should be created with |
| 268 | * createTexture(). |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 269 | */ |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 270 | GrTexture* refScratchTexture(const GrSurfaceDesc&, ScratchTexMatch match, |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 271 | bool internalFlag = false); |
robertphillips | dbe6074 | 2014-09-30 06:54:17 -0700 | [diff] [blame] | 272 | |
| 273 | /** |
bsalomon | d2a6f4e | 2015-02-04 10:55:54 -0800 | [diff] [blame] | 274 | * Can the provided configuration act as a texture? |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 275 | */ |
bsalomon | d2a6f4e | 2015-02-04 10:55:54 -0800 | [diff] [blame] | 276 | bool isConfigTexturable(GrPixelConfig) const; |
| 277 | |
| 278 | /** |
| 279 | * Can non-power-of-two textures be used with tile modes other than clamp? |
| 280 | */ |
| 281 | bool npotTextureTileSupport() const; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 282 | |
| 283 | /** |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 284 | * Return the max width or height of a texture supported by the current GPU. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 285 | */ |
bsalomon@google.com | 9195836 | 2011-06-13 17:58:13 +0000 | [diff] [blame] | 286 | int getMaxTextureSize() const; |
| 287 | |
robertphillips@google.com | 44a91dc | 2013-07-25 15:32:06 +0000 | [diff] [blame] | 288 | /** |
skia.committer@gmail.com | 956b310 | 2013-07-26 07:00:58 +0000 | [diff] [blame] | 289 | * Temporarily override the true max texture size. Note: an override |
robertphillips@google.com | 44a91dc | 2013-07-25 15:32:06 +0000 | [diff] [blame] | 290 | * larger then the true max texture size will have no effect. |
| 291 | * This entry point is mainly meant for testing texture size dependent |
| 292 | * features and is only available if defined outside of Skia (see |
| 293 | * bleed GM. |
| 294 | */ |
| 295 | void setMaxTextureSizeOverride(int maxTextureSizeOverride); |
| 296 | |
robertphillips@google.com | 99a5ac0 | 2012-04-10 19:26:38 +0000 | [diff] [blame] | 297 | /** |
| 298 | * Can the provided configuration act as a color render target? |
| 299 | */ |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 300 | bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const; |
robertphillips@google.com | 99a5ac0 | 2012-04-10 19:26:38 +0000 | [diff] [blame] | 301 | |
bsalomon@google.com | 8a70eef | 2013-03-19 13:58:55 +0000 | [diff] [blame] | 302 | /** |
| 303 | * Return the max width or height of a render target supported by the |
| 304 | * current GPU. |
| 305 | */ |
| 306 | int getMaxRenderTargetSize() const; |
| 307 | |
| 308 | /** |
| 309 | * Returns the max sample count for a render target. It will be 0 if MSAA |
| 310 | * is not supported. |
| 311 | */ |
| 312 | int getMaxSampleCount() const; |
| 313 | |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 314 | /** |
| 315 | * Returns the recommended sample count for a render target when using this |
| 316 | * context. |
| 317 | * |
| 318 | * @param config the configuration of the render target. |
| 319 | * @param dpi the display density in dots per inch. |
| 320 | * |
| 321 | * @return sample count that should be perform well and have good enough |
| 322 | * rendering quality for the display. Alternatively returns 0 if |
| 323 | * MSAA is not supported or recommended to be used by default. |
| 324 | */ |
| 325 | int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const; |
| 326 | |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 327 | /////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 328 | // Backend Surfaces |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 329 | |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 330 | /** |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 331 | * Wraps an existing texture with a GrTexture object. |
| 332 | * |
| 333 | * OpenGL: if the object is a texture Gr may change its GL texture params |
| 334 | * when it is drawn. |
| 335 | * |
| 336 | * @param desc description of the object to create. |
| 337 | * |
| 338 | * @return GrTexture object or NULL on failure. |
| 339 | */ |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 340 | GrTexture* wrapBackendTexture(const GrBackendTextureDesc& desc); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 341 | |
| 342 | /** |
| 343 | * Wraps an existing render target with a GrRenderTarget object. It is |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 344 | * similar to wrapBackendTexture but can be used to draw into surfaces |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 345 | * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that |
| 346 | * the client will resolve to a texture). |
| 347 | * |
| 348 | * @param desc description of the object to create. |
| 349 | * |
| 350 | * @return GrTexture object or NULL on failure. |
| 351 | */ |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 352 | GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 353 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 354 | /////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 355 | // Draws |
| 356 | |
| 357 | /** |
bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 358 | * Clear the entire or rect of the render target, ignoring any clips. |
| 359 | * @param rect the rect to clear or the whole thing if rect is NULL. |
| 360 | * @param color the color to clear to. |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 361 | * @param canIgnoreRect allows partial clears to be converted to whole |
| 362 | * clears on platforms for which that is cheap |
bsalomon | 89c6298 | 2014-11-03 12:08:42 -0800 | [diff] [blame] | 363 | * @param target The render target to clear. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 364 | */ |
bsalomon | 89c6298 | 2014-11-03 12:08:42 -0800 | [diff] [blame] | 365 | void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect, GrRenderTarget* target); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 366 | |
| 367 | /** |
| 368 | * Draw everywhere (respecting the clip) with the paint. |
| 369 | */ |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 370 | void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatrix& viewMatrix); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 371 | |
| 372 | /** |
| 373 | * Draw the rect using a paint. |
| 374 | * @param paint describes how to color pixels. |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 375 | * @param viewMatrix transformation matrix |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 376 | * @param strokeInfo the stroke information (width, join, cap), and. |
| 377 | * the dash information (intervals, count, phase). |
| 378 | * If strokeInfo == NULL, then the rect is filled. |
commit-bot@chromium.org | 6006d0f | 2013-11-06 10:08:21 +0000 | [diff] [blame] | 379 | * Otherwise, if stroke width == 0, then the stroke |
skia.committer@gmail.com | 2614418 | 2013-11-07 07:02:19 +0000 | [diff] [blame] | 380 | * is always a single pixel thick, else the rect is |
commit-bot@chromium.org | 6006d0f | 2013-11-06 10:08:21 +0000 | [diff] [blame] | 381 | * mitered/beveled stroked based on stroke width. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 382 | * The rects coords are used to access the paint (through texture matrix) |
| 383 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 384 | void drawRect(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 385 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 386 | const GrPaint& paint, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 387 | const SkMatrix& viewMatrix, |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 388 | const SkRect&, |
bsalomon | 01c8da1 | 2014-08-04 09:21:30 -0700 | [diff] [blame] | 389 | const GrStrokeInfo* strokeInfo = NULL); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 390 | |
| 391 | /** |
joshualitt | 16b2789 | 2014-12-18 07:47:16 -0800 | [diff] [blame] | 392 | * Maps a rectangle of shader coordinates to a rectangle and draws that rectangle |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 393 | * |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 394 | * @param paint describes how to color pixels. |
joshualitt | 16b2789 | 2014-12-18 07:47:16 -0800 | [diff] [blame] | 395 | * @param viewMatrix transformation matrix which applies to rectToDraw |
| 396 | * @param rectToDraw the rectangle to draw |
| 397 | * @param localRect the rectangle of shader coordinates applied to rectToDraw |
| 398 | * @param localMatrix an optional matrix to transform the shader coordinates before applying |
| 399 | * to rectToDraw |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 400 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 401 | void drawNonAARectToRect(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 402 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 403 | const GrPaint& paint, |
joshualitt | 16b2789 | 2014-12-18 07:47:16 -0800 | [diff] [blame] | 404 | const SkMatrix& viewMatrix, |
| 405 | const SkRect& rectToDraw, |
| 406 | const SkRect& localRect, |
| 407 | const SkMatrix* localMatrix = NULL); |
| 408 | |
| 409 | /** |
| 410 | * Draws a non-AA rect with paint and a localMatrix |
| 411 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 412 | void drawNonAARectWithLocalMatrix(GrRenderTarget* rt, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 413 | const GrClip& clip, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 414 | const GrPaint& paint, |
joshualitt | 16b2789 | 2014-12-18 07:47:16 -0800 | [diff] [blame] | 415 | const SkMatrix& viewMatrix, |
| 416 | const SkRect& rect, |
| 417 | const SkMatrix& localMatrix) { |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 418 | this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &localMatrix); |
joshualitt | 16b2789 | 2014-12-18 07:47:16 -0800 | [diff] [blame] | 419 | } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 420 | |
| 421 | /** |
commit-bot@chromium.org | f2bfd54 | 2013-04-25 15:27:00 +0000 | [diff] [blame] | 422 | * Draw a roundrect using a paint. |
| 423 | * |
| 424 | * @param paint describes how to color pixels. |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 425 | * @param viewMatrix transformation matrix |
commit-bot@chromium.org | f2bfd54 | 2013-04-25 15:27:00 +0000 | [diff] [blame] | 426 | * @param rrect the roundrect to draw |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 427 | * @param strokeInfo the stroke information (width, join, cap) and |
| 428 | * the dash information (intervals, count, phase). |
commit-bot@chromium.org | f2bfd54 | 2013-04-25 15:27:00 +0000 | [diff] [blame] | 429 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 430 | void drawRRect(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 431 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 432 | const GrPaint&, |
| 433 | const SkMatrix& viewMatrix, |
| 434 | const SkRRect& rrect, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 435 | const GrStrokeInfo&); |
commit-bot@chromium.org | 0a09d71 | 2014-04-09 21:26:11 +0000 | [diff] [blame] | 436 | |
| 437 | /** |
| 438 | * Shortcut for drawing an SkPath consisting of nested rrects using a paint. |
| 439 | * Does not support stroking. The result is undefined if outer does not contain |
| 440 | * inner. |
| 441 | * |
| 442 | * @param paint describes how to color pixels. |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 443 | * @param viewMatrix transformation matrix |
commit-bot@chromium.org | 0a09d71 | 2014-04-09 21:26:11 +0000 | [diff] [blame] | 444 | * @param outer the outer roundrect |
| 445 | * @param inner the inner roundrect |
| 446 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 447 | void drawDRRect(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 448 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 449 | const GrPaint&, |
| 450 | const SkMatrix& viewMatrix, |
| 451 | const SkRRect& outer, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 452 | const SkRRect& inner); |
commit-bot@chromium.org | 0a09d71 | 2014-04-09 21:26:11 +0000 | [diff] [blame] | 453 | |
commit-bot@chromium.org | f2bfd54 | 2013-04-25 15:27:00 +0000 | [diff] [blame] | 454 | |
| 455 | /** |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 456 | * Draws a path. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 457 | * |
| 458 | * @param paint describes how to color pixels. |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 459 | * @param viewMatrix transformation matrix |
reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 460 | * @param path the path to draw |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 461 | * @param strokeInfo the stroke information (width, join, cap) and |
| 462 | * the dash information (intervals, count, phase). |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 463 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 464 | void drawPath(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 465 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 466 | const GrPaint&, |
| 467 | const SkMatrix& viewMatrix, |
| 468 | const SkPath&, |
| 469 | const GrStrokeInfo&); |
reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 470 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 471 | /** |
| 472 | * Draws vertices with a paint. |
| 473 | * |
| 474 | * @param paint describes how to color pixels. |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 475 | * @param viewMatrix transformation matrix |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 476 | * @param primitiveType primitives type to draw. |
| 477 | * @param vertexCount number of vertices. |
| 478 | * @param positions array of vertex positions, required. |
| 479 | * @param texCoords optional array of texture coordinates used |
| 480 | * to access the paint. |
| 481 | * @param colors optional array of per-vertex colors, supercedes |
| 482 | * the paint's color field. |
| 483 | * @param indices optional array of indices. If NULL vertices |
| 484 | * are drawn non-indexed. |
| 485 | * @param indexCount if indices is non-null then this is the |
| 486 | * number of indices. |
| 487 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 488 | void drawVertices(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 489 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 490 | const GrPaint& paint, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 491 | const SkMatrix& viewMatrix, |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 492 | GrPrimitiveType primitiveType, |
| 493 | int vertexCount, |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 494 | const SkPoint positions[], |
| 495 | const SkPoint texs[], |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 496 | const GrColor colors[], |
| 497 | const uint16_t indices[], |
| 498 | int indexCount); |
| 499 | |
bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 500 | /** |
| 501 | * Draws an oval. |
| 502 | * |
| 503 | * @param paint describes how to color pixels. |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 504 | * @param viewMatrix transformation matrix |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 505 | * @param oval the bounding rect of the oval. |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 506 | * @param strokeInfo the stroke information (width, join, cap) and |
| 507 | * the dash information (intervals, count, phase). |
bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 508 | */ |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 509 | void drawOval(GrRenderTarget*, |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 510 | const GrClip&, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 511 | const GrPaint& paint, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 512 | const SkMatrix& viewMatrix, |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 513 | const SkRect& oval, |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 514 | const GrStrokeInfo& strokeInfo); |
bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 515 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 516 | /////////////////////////////////////////////////////////////////////////// |
| 517 | // Misc. |
| 518 | |
| 519 | /** |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 520 | * Flags that affect flush() behavior. |
| 521 | */ |
| 522 | enum FlushBits { |
| 523 | /** |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 524 | * A client may reach a point where it has partially rendered a frame |
| 525 | * through a GrContext that it knows the user will never see. This flag |
| 526 | * causes the flush to skip submission of deferred content to the 3D API |
| 527 | * during the flush. |
| 528 | */ |
| 529 | kDiscard_FlushBit = 0x2, |
| 530 | }; |
| 531 | |
| 532 | /** |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 533 | * Call to ensure all drawing to the context has been issued to the |
| 534 | * underlying 3D API. |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 535 | * @param flagsBitfield flags that control the flushing behavior. See |
| 536 | * FlushBits. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 537 | */ |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 538 | void flush(int flagsBitfield = 0); |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 539 | |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 540 | /** |
| 541 | * These flags can be used with the read/write pixels functions below. |
| 542 | */ |
| 543 | enum PixelOpsFlags { |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 544 | /** The GrContext will not be flushed before the surface read or write. This means that |
| 545 | the read or write may occur before previous draws have executed. */ |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 546 | kDontFlush_PixelOpsFlag = 0x1, |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 547 | /** Any surface writes should be flushed to the backend 3D API after the surface operation |
| 548 | is complete */ |
| 549 | kFlushWrites_PixelOp = 0x2, |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 550 | /** The src for write or dst read is unpremultiplied. This is only respected if both the |
| 551 | config src and dst configs are an RGBA/BGRA 8888 format. */ |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 552 | kUnpremul_PixelOpsFlag = 0x4, |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 553 | }; |
| 554 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 555 | /** |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 556 | * Reads a rectangle of pixels from a render target. |
bsalomon | 89c6298 | 2014-11-03 12:08:42 -0800 | [diff] [blame] | 557 | * @param target the render target to read from. |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 558 | * @param left left edge of the rectangle to read (inclusive) |
| 559 | * @param top top edge of the rectangle to read (inclusive) |
| 560 | * @param width width of rectangle to read in pixels. |
| 561 | * @param height height of rectangle to read in pixels. |
| 562 | * @param config the pixel config of the destination buffer |
| 563 | * @param buffer memory to read the rectangle into. |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 564 | * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly |
| 565 | * packed. |
| 566 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 567 | * |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 568 | * @return true if the read succeeded, false if not. The read can fail because of an unsupported |
| 569 | * pixel config or because no render target is currently set and NULL was passed for |
| 570 | * target. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 571 | */ |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 572 | bool readRenderTargetPixels(GrRenderTarget* target, |
| 573 | int left, int top, int width, int height, |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 574 | GrPixelConfig config, void* buffer, |
| 575 | size_t rowBytes = 0, |
| 576 | uint32_t pixelOpsFlags = 0); |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 577 | |
| 578 | /** |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 579 | * Writes a rectangle of pixels to a surface. |
| 580 | * @param surface the surface to write to. |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 581 | * @param left left edge of the rectangle to write (inclusive) |
| 582 | * @param top top edge of the rectangle to write (inclusive) |
| 583 | * @param width width of rectangle to write in pixels. |
| 584 | * @param height height of rectangle to write in pixels. |
| 585 | * @param config the pixel config of the source buffer |
| 586 | * @param buffer memory to read pixels from |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 587 | * @param rowBytes number of bytes between consecutive rows. Zero |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 588 | * means rows are tightly packed. |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 589 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 590 | * @return true if the write succeeded, false if not. The write can fail because of an |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 591 | * unsupported combination of surface and src configs. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 592 | */ |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 593 | bool writeSurfacePixels(GrSurface* surface, |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 594 | int left, int top, int width, int height, |
| 595 | GrPixelConfig config, const void* buffer, |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 596 | size_t rowBytes, |
| 597 | uint32_t pixelOpsFlags = 0); |
| 598 | |
senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 599 | /** |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 600 | * Copies a rectangle of texels from src to dst. |
scroggo@google.com | a2a3192 | 2012-12-07 19:14:45 +0000 | [diff] [blame] | 601 | * bounds. |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 602 | * @param dst the surface to copy to. |
| 603 | * @param src the surface to copy from. |
| 604 | * @param srcRect the rectangle of the src that should be copied. |
| 605 | * @param dstPoint the translation applied when writing the srcRect's pixels to the dst. |
| 606 | * @param pixelOpsFlags see PixelOpsFlags enum above. (kUnpremul_PixelOpsFlag is not allowed). |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 607 | */ |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 608 | void copySurface(GrSurface* dst, |
| 609 | GrSurface* src, |
| 610 | const SkIRect& srcRect, |
| 611 | const SkIPoint& dstPoint, |
| 612 | uint32_t pixelOpsFlags = 0); |
| 613 | |
| 614 | /** Helper that copies the whole surface but fails when the two surfaces are not identically |
| 615 | sized. */ |
| 616 | bool copySurface(GrSurface* dst, GrSurface* src) { |
| 617 | if (NULL == dst || NULL == src || dst->width() != src->width() || |
| 618 | dst->height() != src->height()) { |
| 619 | return false; |
| 620 | } |
| 621 | this->copySurface(dst, src, SkIRect::MakeWH(dst->width(), dst->height()), |
| 622 | SkIPoint::Make(0,0)); |
| 623 | return true; |
| 624 | } |
| 625 | |
| 626 | /** |
| 627 | * After this returns any pending writes to the surface will have been issued to the backend 3D API. |
| 628 | */ |
| 629 | void flushSurfaceWrites(GrSurface* surface); |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 630 | |
| 631 | /** |
bsalomon | 87a94eb | 2014-11-03 14:28:32 -0800 | [diff] [blame] | 632 | * Equivalent to flushSurfaceWrites but also performs MSAA resolve if necessary. This call is |
| 633 | * used to make the surface contents available to be read in the backend 3D API, usually for a |
| 634 | * compositing step external to Skia. |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 635 | * |
bsalomon | 87a94eb | 2014-11-03 14:28:32 -0800 | [diff] [blame] | 636 | * It is not necessary to call this before reading the render target via Skia/GrContext. |
| 637 | * GrContext will detect when it must perform a resolve before reading pixels back from the |
| 638 | * surface or using it as a texture. |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 639 | */ |
bsalomon | 87a94eb | 2014-11-03 14:28:32 -0800 | [diff] [blame] | 640 | void prepareSurfaceForExternalRead(GrSurface*); |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 641 | |
| 642 | /** |
| 643 | * Provides a perfomance hint that the render target's contents are allowed |
| 644 | * to become undefined. |
| 645 | */ |
| 646 | void discardRenderTarget(GrRenderTarget*); |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 647 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 648 | /////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 649 | // Functions intended for internal use only. |
| 650 | GrGpu* getGpu() { return fGpu; } |
bsalomon@google.com | 1f221a7 | 2011-08-23 20:54:07 +0000 | [diff] [blame] | 651 | const GrGpu* getGpu() const { return fGpu; } |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 652 | GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; } |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 653 | GrLayerCache* getLayerCache() { return fLayerCache.get(); } |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 654 | GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; } |
bsalomon@google.com | 21c10c5 | 2013-06-13 17:44:07 +0000 | [diff] [blame] | 655 | GrDrawTarget* getTextTarget(); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 656 | const GrIndexBuffer* getQuadIndexBuffer() const; |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 657 | GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; } |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 658 | GrResourceCache* getResourceCache() { return fResourceCache; } |
bsalomon@google.com | 9923c2b | 2012-06-06 18:21:18 +0000 | [diff] [blame] | 659 | |
commit-bot@chromium.org | 78a1078 | 2013-08-21 19:27:48 +0000 | [diff] [blame] | 660 | // Called by tests that draw directly to the context via GrDrawTarget |
| 661 | void getTestTarget(GrTestTarget*); |
| 662 | |
egdaniel | bbcb38d | 2014-06-19 10:19:29 -0700 | [diff] [blame] | 663 | void addGpuTraceMarker(const GrGpuTraceMarker* marker); |
| 664 | void removeGpuTraceMarker(const GrGpuTraceMarker* marker); |
| 665 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 666 | GrPathRenderer* getPathRenderer( |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 667 | const GrDrawTarget* target, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 668 | const GrPipelineBuilder*, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 669 | const SkMatrix& viewMatrix, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 670 | const SkPath& path, |
kkinnunen | 1899651 | 2015-04-26 23:18:49 -0700 | [diff] [blame] | 671 | const GrStrokeInfo& stroke, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 672 | bool allowSW, |
robertphillips@google.com | e79f320 | 2014-02-11 16:30:21 +0000 | [diff] [blame] | 673 | GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 674 | GrPathRendererChain::StencilSupport* stencilSupport = NULL); |
robertphillips@google.com | 2c75681 | 2012-05-22 20:28:23 +0000 | [diff] [blame] | 675 | |
krajcevski | 9c6d4d7 | 2014-08-12 07:26:25 -0700 | [diff] [blame] | 676 | /** |
| 677 | * This returns a copy of the the GrContext::Options that was passed to the |
| 678 | * constructor of this class. |
| 679 | */ |
| 680 | const Options& getOptions() const { return fOptions; } |
| 681 | |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 682 | /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ |
| 683 | void dumpCacheStats(SkString*) const; |
robertphillips@google.com | 5f9f2f5 | 2012-08-22 10:57:05 +0000 | [diff] [blame] | 684 | void printCacheStats() const; |
robertphillips@google.com | 5f9f2f5 | 2012-08-22 10:57:05 +0000 | [diff] [blame] | 685 | |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 686 | /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ |
| 687 | void dumpGpuStats(SkString*) const; |
| 688 | void printGpuStats() const; |
robertphillips | 754f4e9 | 2014-09-18 13:52:08 -0700 | [diff] [blame] | 689 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 690 | private: |
commit-bot@chromium.org | bb6a317 | 2013-05-28 17:25:49 +0000 | [diff] [blame] | 691 | GrGpu* fGpu; |
bsalomon@google.com | 10e04bf | 2012-03-30 14:35:04 +0000 | [diff] [blame] | 692 | |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 693 | GrResourceCache* fResourceCache; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 694 | GrBatchFontCache* fBatchFontCache; |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 695 | SkAutoTDelete<GrLayerCache> fLayerCache; |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 696 | SkAutoTDelete<GrTextBlobCache> fTextBlobCache; |
bsalomon@google.com | dfe75bc | 2011-03-25 12:31:16 +0000 | [diff] [blame] | 697 | |
commit-bot@chromium.org | bb6a317 | 2013-05-28 17:25:49 +0000 | [diff] [blame] | 698 | GrPathRendererChain* fPathRendererChain; |
| 699 | GrSoftwarePathRenderer* fSoftwarePathRenderer; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 700 | |
commit-bot@chromium.org | bb6a317 | 2013-05-28 17:25:49 +0000 | [diff] [blame] | 701 | GrVertexBufferAllocPool* fDrawBufferVBAllocPool; |
| 702 | GrIndexBufferAllocPool* fDrawBufferIBAllocPool; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame^] | 703 | GrDrawTarget* fDrawBuffer; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 704 | |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 705 | // Set by OverbudgetCB() to request that GrContext flush before exiting a draw. |
| 706 | bool fFlushToReduceCacheSize; |
commit-bot@chromium.org | bb6a317 | 2013-05-28 17:25:49 +0000 | [diff] [blame] | 707 | GrAARectRenderer* fAARectRenderer; |
| 708 | GrOvalRenderer* fOvalRenderer; |
bsalomon@google.com | dfe75bc | 2011-03-25 12:31:16 +0000 | [diff] [blame] | 709 | |
commit-bot@chromium.org | bb6a317 | 2013-05-28 17:25:49 +0000 | [diff] [blame] | 710 | bool fDidTestPMConversions; |
| 711 | int fPMToUPMConversion; |
| 712 | int fUPMToPMConversion; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 713 | |
robertphillips@google.com | cdb426d | 2012-09-24 19:33:59 +0000 | [diff] [blame] | 714 | struct CleanUpData { |
| 715 | PFCleanUpFunc fFunc; |
| 716 | void* fInfo; |
| 717 | }; |
| 718 | |
robertphillips@google.com | 44a91dc | 2013-07-25 15:32:06 +0000 | [diff] [blame] | 719 | SkTDArray<CleanUpData> fCleanUpData; |
| 720 | |
skia.committer@gmail.com | 956b310 | 2013-07-26 07:00:58 +0000 | [diff] [blame] | 721 | int fMaxTextureSizeOverride; |
robertphillips@google.com | cdb426d | 2012-09-24 19:33:59 +0000 | [diff] [blame] | 722 | |
krajcevski | 9c6d4d7 | 2014-08-12 07:26:25 -0700 | [diff] [blame] | 723 | const Options fOptions; |
| 724 | |
| 725 | GrContext(const Options&); // init must be called after the constructor. |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 726 | bool init(GrBackend, GrBackendContext); |
bsalomon | 3343557 | 2014-11-05 14:47:41 -0800 | [diff] [blame] | 727 | void initMockContext(); |
| 728 | void initCommon(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 729 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 730 | void setupDrawBuffer(); |
| 731 | |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 732 | class AutoCheckFlush; |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 733 | // Sets the paint and returns the target to draw into. |
| 734 | GrDrawTarget* prepareToDraw(GrPipelineBuilder*, |
| 735 | GrRenderTarget* rt, |
| 736 | const GrClip&, |
| 737 | const GrPaint* paint, |
joshualitt | 25d9c15 | 2015-02-18 12:29:52 -0800 | [diff] [blame] | 738 | const AutoCheckFlush*); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 739 | |
joshualitt | 570d2f8 | 2015-02-25 13:19:48 -0800 | [diff] [blame] | 740 | // A simpler version of the above which just returns the draw target. Clip is *NOT* set |
| 741 | GrDrawTarget* prepareToDraw(); |
| 742 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 743 | void internalDrawPath(GrDrawTarget*, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 744 | GrPipelineBuilder*, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 745 | const SkMatrix& viewMatrix, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 746 | GrColor, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 747 | bool useAA, |
| 748 | const SkPath&, |
| 749 | const GrStrokeInfo&); |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 750 | |
bsalomon | d042358 | 2015-02-06 08:49:24 -0800 | [diff] [blame] | 751 | GrTexture* internalRefScratchTexture(const GrSurfaceDesc&, uint32_t flags); |
robertphillips@google.com | 3319f33 | 2012-08-13 18:00:36 +0000 | [diff] [blame] | 752 | |
skia.committer@gmail.com | cdcb2ce | 2013-01-29 07:05:52 +0000 | [diff] [blame] | 753 | /** |
joshualitt | 6e8cd96 | 2015-03-20 10:30:14 -0700 | [diff] [blame] | 754 | * Creates a new text rendering context that is optimal for the |
| 755 | * render target and the context. Caller assumes the ownership |
| 756 | * of the returned object. The returned object must be deleted |
| 757 | * before the context is destroyed. |
| 758 | * TODO we can possibly bury this behind context, but we need to be able to use the |
| 759 | * drawText_asPaths logic on SkGpuDevice |
| 760 | */ |
| 761 | GrTextContext* createTextContext(GrRenderTarget*, |
| 762 | SkGpuDevice*, |
| 763 | const SkDeviceProperties&, |
| 764 | bool enableDistanceFieldFonts); |
| 765 | |
| 766 | |
| 767 | /** |
bsalomon@google.com | adc6536 | 2013-01-28 14:26:09 +0000 | [diff] [blame] | 768 | * These functions create premul <-> unpremul effects if it is possible to generate a pair |
| 769 | * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they |
| 770 | * return NULL. |
| 771 | */ |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 772 | const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, const SkMatrix&); |
| 773 | const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, const SkMatrix&); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 774 | |
commit-bot@chromium.org | cae27fe | 2013-07-10 10:14:35 +0000 | [diff] [blame] | 775 | /** |
| 776 | * This callback allows the resource cache to callback into the GrContext |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 777 | * when the cache is still over budget after a purge. |
commit-bot@chromium.org | cae27fe | 2013-07-10 10:14:35 +0000 | [diff] [blame] | 778 | */ |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 779 | static void OverBudgetCB(void* data); |
commit-bot@chromium.org | cae27fe | 2013-07-10 10:14:35 +0000 | [diff] [blame] | 780 | |
joshualitt | 0db6dfa | 2015-04-10 07:01:30 -0700 | [diff] [blame] | 781 | /** |
| 782 | * A callback similar to the above for use by the TextBlobCache |
| 783 | * TODO move textblob draw calls below context so we can use the call above. |
| 784 | */ |
| 785 | static void TextBlobCacheOverBudgetCB(void* data); |
| 786 | |
joshualitt | 6e8cd96 | 2015-03-20 10:30:14 -0700 | [diff] [blame] | 787 | // TODO see note on createTextContext |
| 788 | friend class SkGpuDevice; |
| 789 | |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 790 | typedef SkRefCnt INHERITED; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 791 | }; |
| 792 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 793 | #endif |