| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 2 | /* |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 10 | #ifndef GrContext_DEFINED |
| 11 | #define GrContext_DEFINED |
| 12 | |
| robertphillips@google.com | 5955202 | 2012-08-31 13:07:37 +0000 | [diff] [blame^] | 13 | #include "GrConfig.h" |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 14 | #include "GrPaint.h" |
| robertphillips@google.com | f6747b0 | 2012-06-12 00:32:28 +0000 | [diff] [blame] | 15 | #include "GrAARectRenderer.h" |
| robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 16 | #include "GrClipData.h" |
| bsalomon@google.com | c287a89 | 2011-08-19 14:49:36 +0000 | [diff] [blame] | 17 | // not strictly needed but requires WK change in LayerTextureUpdaterCanvas to |
| 18 | // remove. |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 19 | #include "GrRenderTarget.h" |
| robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 20 | #include "SkClipStack.h" |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 21 | |
| senorblanco@chromium.org | 3b4dd90 | 2012-03-05 20:41:22 +0000 | [diff] [blame] | 22 | class GrAutoScratchTexture; |
| robertphillips@google.com | a9b0623 | 2012-08-30 11:06:31 +0000 | [diff] [blame] | 23 | class GrCacheKey; |
| bsalomon@google.com | 10e04bf | 2012-03-30 14:35:04 +0000 | [diff] [blame] | 24 | class GrDrawState; |
| bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 25 | class GrDrawTarget; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 26 | class GrFontCache; |
| bsalomon@google.com | 05ef510 | 2011-05-02 21:14:59 +0000 | [diff] [blame] | 27 | class GrGpu; |
| bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 28 | class GrIndexBuffer; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 29 | class GrIndexBufferAllocPool; |
| 30 | class GrInOrderDrawBuffer; |
| bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 31 | class GrPathRenderer; |
| bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 32 | class GrPathRendererChain; |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 33 | class GrResourceEntry; |
| 34 | class GrResourceCache; |
| bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 35 | class GrStencilBuffer; |
| bsalomon@google.com | 583a1e3 | 2011-08-17 13:42:46 +0000 | [diff] [blame] | 36 | class GrVertexBuffer; |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 37 | class GrVertexBufferAllocPool; |
| robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 38 | class GrSoftwarePathRenderer; |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 39 | |
| bsalomon@google.com | 9182610 | 2011-03-21 19:51:57 +0000 | [diff] [blame] | 40 | class GR_API GrContext : public GrRefCnt { |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 41 | public: |
| reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 42 | SK_DECLARE_INST_COUNT(GrContext) |
| 43 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 44 | /** |
| 45 | * Creates a GrContext from within a 3D context. |
| 46 | */ |
| bsalomon@google.com | 05ef510 | 2011-05-02 21:14:59 +0000 | [diff] [blame] | 47 | static GrContext* Create(GrEngine engine, |
| 48 | GrPlatform3DContext context3D); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 49 | |
| bsalomon@google.com | c0af317 | 2012-06-15 14:10:09 +0000 | [diff] [blame] | 50 | /** |
| 51 | * Returns the number of GrContext instances for the current thread. |
| 52 | */ |
| 53 | static int GetThreadInstanceCount(); |
| 54 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 55 | virtual ~GrContext(); |
| 56 | |
| 57 | /** |
| 58 | * The GrContext normally assumes that no outsider is setting state |
| 59 | * within the underlying 3D API's context/device/whatever. This call informs |
| 60 | * the context that the state was modified and it should resend. Shouldn't |
| 61 | * be called frequently for good performance. |
| 62 | */ |
| 63 | void resetContext(); |
| 64 | |
| bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 65 | /** |
| 66 | * Abandons all gpu resources, assumes 3D API state is unknown. Call this |
| 67 | * if you have lost the associated GPU context, and thus internal texture, |
| 68 | * buffer, etc. references/IDs are now invalid. Should be called even when |
| 69 | * GrContext is no longer going to be used for two reasons: |
| 70 | * 1) ~GrContext will not try to free the objects in the 3D API. |
| 71 | * 2) If you've created GrResources that outlive the GrContext they will |
| 72 | * be marked as invalid (GrResource::isValid()) and won't attempt to |
| 73 | * free their underlying resource in the 3D API. |
| 74 | * Content drawn since the last GrContext::flush() may be lost. |
| 75 | */ |
| 76 | void contextLost(); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 77 | |
| 78 | /** |
| junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 79 | * Similar to contextLost, but makes no attempt to reset state. |
| 80 | * Use this method when GrContext destruction is pending, but |
| 81 | * the graphics context is destroyed first. |
| 82 | */ |
| 83 | void contextDestroyed(); |
| 84 | |
| 85 | /** |
| bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 86 | * Frees gpu created by the context. Can be called to reduce GPU memory |
| 87 | * pressure. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 88 | */ |
| bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 89 | void freeGpuResources(); |
| 90 | |
| bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 91 | /** |
| 92 | * Returns the number of bytes of GPU memory hosted by the texture cache. |
| 93 | */ |
| 94 | size_t getGpuTextureCacheBytes() const; |
| 95 | |
| bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 96 | /////////////////////////////////////////////////////////////////////////// |
| 97 | // Textures |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 98 | |
| 99 | /** |
| bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 100 | * Create a new entry, based on the specified key and texture, and return |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 101 | * a "locked" texture. Must call be balanced with an unlockTexture() call. |
| bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 102 | * |
| bsalomon@google.com | b867099 | 2012-07-25 21:27:09 +0000 | [diff] [blame] | 103 | * @param params The tex params used to draw a texture may help determine |
| 104 | * the cache entry used. (e.g. different versions may exist |
| 105 | * for different wrap modes on GPUs with limited NPOT |
| 106 | * texture support). NULL implies clamp wrap modes. |
| bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 107 | * @param desc Description of the texture properties. |
| robertphillips@google.com | 9c2ea84 | 2012-08-13 17:47:59 +0000 | [diff] [blame] | 108 | * @param cacheData Cache-specific properties (e.g., texture gen ID) |
| bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 109 | * @param srcData Pointer to the pixel values. |
| 110 | * @param rowBytes The number of bytes between rows of the texture. Zero |
| 111 | * implies tightly packed rows. |
| 112 | */ |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 113 | GrTexture* createAndLockTexture(const GrTextureParams* params, |
| 114 | const GrTextureDesc& desc, |
| 115 | const GrCacheData& cacheData, |
| 116 | void* srcData, size_t rowBytes); |
| bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 117 | |
| 118 | /** |
| robertphillips@google.com | a9b0623 | 2012-08-30 11:06:31 +0000 | [diff] [blame] | 119 | * Look for a texture that matches 'key' in the cache. If not found, |
| 120 | * return NULL. |
| 121 | */ |
| 122 | GrTexture* findTexture(const GrCacheKey& key); |
| 123 | |
| 124 | /** |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 125 | * Search for an entry based on key and dimensions. If found, "lock" it and |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 126 | * return it. The return value will be NULL if not found. |
| bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 127 | * Must be balanced with an unlockTexture() call. |
| 128 | * |
| bsalomon@google.com | b867099 | 2012-07-25 21:27:09 +0000 | [diff] [blame] | 129 | * @param desc Description of the texture properties. |
| robertphillips@google.com | 9c2ea84 | 2012-08-13 17:47:59 +0000 | [diff] [blame] | 130 | * @param cacheData Cache-specific properties (e.g., texture gen ID) |
| bsalomon@google.com | b867099 | 2012-07-25 21:27:09 +0000 | [diff] [blame] | 131 | * @param params The tex params used to draw a texture may help determine |
| 132 | * the cache entry used. (e.g. different versions may exist |
| 133 | * for different wrap modes on GPUs with limited NPOT |
| 134 | * texture support). NULL implies clamp wrap modes. |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 135 | */ |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 136 | GrTexture* findAndLockTexture(const GrTextureDesc& desc, |
| 137 | const GrCacheData& cacheData, |
| 138 | const GrTextureParams* params); |
| bsalomon@google.com | fb30951 | 2011-11-30 14:13:48 +0000 | [diff] [blame] | 139 | /** |
| 140 | * Determines whether a texture is in the cache. If the texture is found it |
| 141 | * will not be locked or returned. This call does not affect the priority of |
| 142 | * the texture for deletion. |
| 143 | */ |
| robertphillips@google.com | 75b3c96 | 2012-06-07 12:08:45 +0000 | [diff] [blame] | 144 | bool isTextureInCache(const GrTextureDesc& desc, |
| robertphillips@google.com | 9c2ea84 | 2012-08-13 17:47:59 +0000 | [diff] [blame] | 145 | const GrCacheData& cacheData, |
| bsalomon@google.com | b867099 | 2012-07-25 21:27:09 +0000 | [diff] [blame] | 146 | const GrTextureParams* params) const; |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 147 | |
| 148 | /** |
| 149 | * Enum that determines how closely a returned scratch texture must match |
| 150 | * a provided GrTextureDesc. |
| 151 | */ |
| 152 | enum ScratchTexMatch { |
| 153 | /** |
| 154 | * Finds a texture that exactly matches the descriptor. |
| 155 | */ |
| 156 | kExact_ScratchTexMatch, |
| 157 | /** |
| 158 | * Finds a texture that approximately matches the descriptor. Will be |
| 159 | * at least as large in width and height as desc specifies. If desc |
| 160 | * specifies that texture is a render target then result will be a |
| 161 | * render target. If desc specifies a render target and doesn't set the |
| 162 | * no stencil flag then result will have a stencil. Format and aa level |
| 163 | * will always match. |
| 164 | */ |
| 165 | kApprox_ScratchTexMatch |
| 166 | }; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 167 | |
| 168 | /** |
| bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 169 | * Returns a texture matching the desc. It's contents are unknown. Subsequent |
| 170 | * requests with the same descriptor are not guaranteed to return the same |
| 171 | * texture. The same texture is guaranteed not be returned again until it is |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 172 | * unlocked. Call must be balanced with an unlockTexture() call. |
| bsalomon@google.com | a39f404 | 2011-04-26 13:18:16 +0000 | [diff] [blame] | 173 | * |
| 174 | * Textures created by createAndLockTexture() hide the complications of |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 175 | * tiling non-power-of-two textures on APIs that don't support this (e.g. |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 176 | * unextended GLES2). Tiling a npot texture created by lockScratchTexture on |
| bsalomon@google.com | a39f404 | 2011-04-26 13:18:16 +0000 | [diff] [blame] | 177 | * such an API will create gaps in the tiling pattern. This includes clamp |
| 178 | * mode. (This may be addressed in a future update.) |
| bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 179 | */ |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 180 | GrTexture* lockScratchTexture(const GrTextureDesc& desc, |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 181 | ScratchTexMatch match); |
| bsalomon@google.com | b5b3168 | 2011-06-16 18:05:35 +0000 | [diff] [blame] | 182 | |
| 183 | /** |
| robertphillips@google.com | a9b0623 | 2012-08-30 11:06:31 +0000 | [diff] [blame] | 184 | * Make a texture un-purgeable in the cache |
| 185 | */ |
| 186 | void lockTexture(GrTexture* texture); |
| 187 | |
| 188 | /** |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 189 | * When done with an entry, call unlockTexture(entry) on it, which returns |
| 190 | * it to the cache, where it may be purged. |
| 191 | */ |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 192 | void unlockTexture(GrTexture* texture); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 193 | |
| 194 | /** |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 195 | * Creates a texture that is outside the cache. Does not count against |
| 196 | * cache's budget. |
| 197 | */ |
| robertphillips@google.com | 75b3c96 | 2012-06-07 12:08:45 +0000 | [diff] [blame] | 198 | GrTexture* createUncachedTexture(const GrTextureDesc& desc, |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 199 | void* srcData, |
| 200 | size_t rowBytes); |
| 201 | |
| 202 | /** |
| bsalomon@google.com | b867099 | 2012-07-25 21:27:09 +0000 | [diff] [blame] | 203 | * Returns true if the specified use of an indexed texture is supported. |
| 204 | * Support may depend upon whether the texture params indicate that the |
| 205 | * texture will be tiled. Passing NULL for the texture params indicates |
| 206 | * clamp mode. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 207 | */ |
| bsalomon@google.com | b867099 | 2012-07-25 21:27:09 +0000 | [diff] [blame] | 208 | bool supportsIndex8PixelConfig(const GrTextureParams*, |
| bsalomon@google.com | 1f221a7 | 2011-08-23 20:54:07 +0000 | [diff] [blame] | 209 | int width, |
| 210 | int height) const; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 211 | |
| 212 | /** |
| bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 213 | * Return the current texture cache limits. |
| 214 | * |
| 215 | * @param maxTextures If non-null, returns maximum number of textures that |
| 216 | * can be held in the cache. |
| 217 | * @param maxTextureBytes If non-null, returns maximum number of bytes of |
| 218 | * texture memory that can be held in the cache. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 219 | */ |
| bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 220 | void getTextureCacheLimits(int* maxTextures, size_t* maxTextureBytes) const; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 221 | |
| 222 | /** |
| bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 223 | * Specify the texture cache limits. If the current cache exceeds either |
| 224 | * of these, it will be purged (LRU) to keep the cache within these limits. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 225 | * |
| bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 226 | * @param maxTextures The maximum number of textures that can be held in |
| 227 | * the cache. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 228 | * @param maxTextureBytes The maximum number of bytes of texture memory |
| 229 | * that can be held in the cache. |
| 230 | */ |
| bsalomon@google.com | 07fc0d1 | 2012-06-22 15:15:59 +0000 | [diff] [blame] | 231 | void setTextureCacheLimits(int maxTextures, size_t maxTextureBytes); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 232 | |
| 233 | /** |
| 234 | * Return the max width or height of a texture supported by the current gpu |
| 235 | */ |
| bsalomon@google.com | 9195836 | 2011-06-13 17:58:13 +0000 | [diff] [blame] | 236 | int getMaxTextureSize() const; |
| 237 | |
| 238 | /** |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 239 | * Return the max width or height of a render target supported by the |
| bsalomon@google.com | 9195836 | 2011-06-13 17:58:13 +0000 | [diff] [blame] | 240 | * current gpu |
| 241 | */ |
| 242 | int getMaxRenderTargetSize() const; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 243 | |
| 244 | /////////////////////////////////////////////////////////////////////////// |
| 245 | // Render targets |
| 246 | |
| 247 | /** |
| bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 248 | * Sets the render target. |
| 249 | * @param target the render target to set. (should not be NULL.) |
| 250 | */ |
| 251 | void setRenderTarget(GrRenderTarget* target); |
| 252 | |
| 253 | /** |
| 254 | * Gets the current render target. |
| 255 | * @return the currently bound render target. Should never be NULL. |
| 256 | */ |
| 257 | const GrRenderTarget* getRenderTarget() const; |
| 258 | GrRenderTarget* getRenderTarget(); |
| 259 | |
| robertphillips@google.com | f69a11b | 2012-06-15 13:58:07 +0000 | [diff] [blame] | 260 | GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; } |
| 261 | |
| robertphillips@google.com | 99a5ac0 | 2012-04-10 19:26:38 +0000 | [diff] [blame] | 262 | /** |
| 263 | * Can the provided configuration act as a color render target? |
| 264 | */ |
| 265 | bool isConfigRenderable(GrPixelConfig config) const; |
| 266 | |
| bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 267 | /////////////////////////////////////////////////////////////////////////// |
| 268 | // Platform Surfaces |
| 269 | |
| bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 270 | /** |
| bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 271 | * Wraps an existing texture with a GrTexture object. |
| 272 | * |
| 273 | * OpenGL: if the object is a texture Gr may change its GL texture params |
| 274 | * when it is drawn. |
| 275 | * |
| 276 | * @param desc description of the object to create. |
| 277 | * |
| 278 | * @return GrTexture object or NULL on failure. |
| 279 | */ |
| 280 | GrTexture* createPlatformTexture(const GrPlatformTextureDesc& desc); |
| 281 | |
| 282 | /** |
| 283 | * Wraps an existing render target with a GrRenderTarget object. It is |
| 284 | * similar to createPlatformTexture but can be used to draw into surfaces |
| 285 | * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that |
| 286 | * the client will resolve to a texture). |
| 287 | * |
| 288 | * @param desc description of the object to create. |
| 289 | * |
| 290 | * @return GrTexture object or NULL on failure. |
| 291 | */ |
| 292 | GrRenderTarget* createPlatformRenderTarget( |
| 293 | const GrPlatformRenderTargetDesc& desc); |
| 294 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 295 | /////////////////////////////////////////////////////////////////////////// |
| 296 | // Matrix state |
| 297 | |
| 298 | /** |
| 299 | * Gets the current transformation matrix. |
| 300 | * @return the current matrix. |
| 301 | */ |
| 302 | const GrMatrix& getMatrix() const; |
| 303 | |
| 304 | /** |
| 305 | * Sets the transformation matrix. |
| 306 | * @param m the matrix to set. |
| 307 | */ |
| 308 | void setMatrix(const GrMatrix& m); |
| 309 | |
| 310 | /** |
| 311 | * Concats the current matrix. The passed matrix is applied before the |
| 312 | * current matrix. |
| 313 | * @param m the matrix to concat. |
| 314 | */ |
| 315 | void concatMatrix(const GrMatrix& m) const; |
| 316 | |
| 317 | |
| 318 | /////////////////////////////////////////////////////////////////////////// |
| 319 | // Clip state |
| 320 | /** |
| 321 | * Gets the current clip. |
| 322 | * @return the current clip. |
| 323 | */ |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 324 | const GrClipData* getClip() const; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 325 | |
| 326 | /** |
| 327 | * Sets the clip. |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 328 | * @param clipData the clip to set. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 329 | */ |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 330 | void setClip(const GrClipData* clipData); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 331 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 332 | /////////////////////////////////////////////////////////////////////////// |
| 333 | // Draws |
| 334 | |
| 335 | /** |
| bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 336 | * Clear the entire or rect of the render target, ignoring any clips. |
| 337 | * @param rect the rect to clear or the whole thing if rect is NULL. |
| 338 | * @param color the color to clear to. |
| robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 339 | * @param target if non-NULL, the render target to clear otherwise clear |
| 340 | * the current render target |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 341 | */ |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 342 | void clear(const GrIRect* rect, GrColor color, |
| robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 343 | GrRenderTarget* target = NULL); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 344 | |
| 345 | /** |
| 346 | * Draw everywhere (respecting the clip) with the paint. |
| 347 | */ |
| 348 | void drawPaint(const GrPaint& paint); |
| 349 | |
| 350 | /** |
| 351 | * Draw the rect using a paint. |
| 352 | * @param paint describes how to color pixels. |
| 353 | * @param strokeWidth If strokeWidth < 0, then the rect is filled, else |
| 354 | * the rect is mitered stroked based on strokeWidth. If |
| 355 | * strokeWidth == 0, then the stroke is always a single |
| 356 | * pixel thick. |
| 357 | * @param matrix Optional matrix applied to the rect. Applied before |
| 358 | * context's matrix or the paint's matrix. |
| 359 | * The rects coords are used to access the paint (through texture matrix) |
| 360 | */ |
| 361 | void drawRect(const GrPaint& paint, |
| 362 | const GrRect&, |
| 363 | GrScalar strokeWidth = -1, |
| 364 | const GrMatrix* matrix = NULL); |
| 365 | |
| 366 | /** |
| 367 | * Maps a rect of paint coordinates onto the a rect of destination |
| 368 | * coordinates. Each rect can optionally be transformed. The srcRect |
| 369 | * is stretched over the dstRect. The dstRect is transformed by the |
| 370 | * context's matrix and the srcRect is transformed by the paint's matrix. |
| 371 | * Additional optional matrices can be provided by parameters. |
| 372 | * |
| 373 | * @param paint describes how to color pixels. |
| 374 | * @param dstRect the destination rect to draw. |
| 375 | * @param srcRect rect of paint coordinates to be mapped onto dstRect |
| 376 | * @param dstMatrix Optional matrix to transform dstRect. Applied before |
| 377 | * context's matrix. |
| 378 | * @param srcMatrix Optional matrix to transform srcRect Applied before |
| 379 | * paint's matrix. |
| 380 | */ |
| 381 | void drawRectToRect(const GrPaint& paint, |
| 382 | const GrRect& dstRect, |
| 383 | const GrRect& srcRect, |
| 384 | const GrMatrix* dstMatrix = NULL, |
| 385 | const GrMatrix* srcMatrix = NULL); |
| 386 | |
| 387 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 388 | * Draws a path. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 389 | * |
| 390 | * @param paint describes how to color pixels. |
| reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 391 | * @param path the path to draw |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 392 | * @param fill the path filling rule to use. |
| 393 | * @param translate optional additional translation applied to the |
| 394 | * path. |
| 395 | */ |
| bsalomon@google.com | 8d033a1 | 2012-04-27 15:52:53 +0000 | [diff] [blame] | 396 | void drawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill, |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 397 | const GrPoint* translate = NULL); |
| reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 398 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 399 | /** |
| 400 | * Draws vertices with a paint. |
| 401 | * |
| 402 | * @param paint describes how to color pixels. |
| 403 | * @param primitiveType primitives type to draw. |
| 404 | * @param vertexCount number of vertices. |
| 405 | * @param positions array of vertex positions, required. |
| 406 | * @param texCoords optional array of texture coordinates used |
| 407 | * to access the paint. |
| 408 | * @param colors optional array of per-vertex colors, supercedes |
| 409 | * the paint's color field. |
| 410 | * @param indices optional array of indices. If NULL vertices |
| 411 | * are drawn non-indexed. |
| 412 | * @param indexCount if indices is non-null then this is the |
| 413 | * number of indices. |
| 414 | */ |
| 415 | void drawVertices(const GrPaint& paint, |
| 416 | GrPrimitiveType primitiveType, |
| 417 | int vertexCount, |
| 418 | const GrPoint positions[], |
| 419 | const GrPoint texs[], |
| 420 | const GrColor colors[], |
| 421 | const uint16_t indices[], |
| 422 | int indexCount); |
| 423 | |
| bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 424 | /** |
| 425 | * Draws an oval. |
| 426 | * |
| 427 | * @param paint describes how to color pixels. |
| 428 | * @param rect the bounding rect of the oval. |
| 429 | * @param strokeWidth if strokeWidth < 0, then the oval is filled, else |
| 430 | * the rect is stroked based on strokeWidth. If |
| 431 | * strokeWidth == 0, then the stroke is always a single |
| 432 | * pixel thick. |
| 433 | */ |
| 434 | void drawOval(const GrPaint& paint, |
| 435 | const GrRect& rect, |
| 436 | SkScalar strokeWidth); |
| 437 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 438 | /////////////////////////////////////////////////////////////////////////// |
| 439 | // Misc. |
| 440 | |
| 441 | /** |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 442 | * Flags that affect flush() behavior. |
| 443 | */ |
| 444 | enum FlushBits { |
| 445 | /** |
| 446 | * A client may want Gr to bind a GrRenderTarget in the 3D API so that |
| 447 | * it can be rendered to directly. However, Gr lazily sets state. Simply |
| 448 | * calling setRenderTarget() followed by flush() without flags may not |
| 449 | * bind the render target. This flag forces the context to bind the last |
| 450 | * set render target in the 3D API. |
| 451 | */ |
| 452 | kForceCurrentRenderTarget_FlushBit = 0x1, |
| 453 | /** |
| 454 | * A client may reach a point where it has partially rendered a frame |
| 455 | * through a GrContext that it knows the user will never see. This flag |
| 456 | * causes the flush to skip submission of deferred content to the 3D API |
| 457 | * during the flush. |
| 458 | */ |
| 459 | kDiscard_FlushBit = 0x2, |
| 460 | }; |
| 461 | |
| 462 | /** |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 463 | * Call to ensure all drawing to the context has been issued to the |
| 464 | * underlying 3D API. |
| bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 465 | * @param flagsBitfield flags that control the flushing behavior. See |
| 466 | * FlushBits. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 467 | */ |
| bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 468 | void flush(int flagsBitfield = 0); |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 469 | |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 470 | /** |
| 471 | * These flags can be used with the read/write pixels functions below. |
| 472 | */ |
| 473 | enum PixelOpsFlags { |
| 474 | /** The GrContext will not be flushed. This means that the read or write may occur before |
| 475 | previous draws have executed. */ |
| 476 | kDontFlush_PixelOpsFlag = 0x1, |
| 477 | /** The src for write or dst read is unpremultiplied. This is only respected if both the |
| 478 | config src and dst configs are an RGBA/BGRA 8888 format. */ |
| 479 | kUnpremul_PixelOpsFlag = 0x2, |
| 480 | }; |
| 481 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 482 | /** |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 483 | * Reads a rectangle of pixels from a render target. |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 484 | * @param target the render target to read from. NULL means the current render target. |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 485 | * @param left left edge of the rectangle to read (inclusive) |
| 486 | * @param top top edge of the rectangle to read (inclusive) |
| 487 | * @param width width of rectangle to read in pixels. |
| 488 | * @param height height of rectangle to read in pixels. |
| 489 | * @param config the pixel config of the destination buffer |
| 490 | * @param buffer memory to read the rectangle into. |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 491 | * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly |
| 492 | * packed. |
| 493 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 494 | * |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 495 | * @return true if the read succeeded, false if not. The read can fail because of an unsupported |
| 496 | * pixel config or because no render target is currently set and NULL was passed for |
| 497 | * target. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 498 | */ |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 499 | bool readRenderTargetPixels(GrRenderTarget* target, |
| 500 | int left, int top, int width, int height, |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 501 | GrPixelConfig config, void* buffer, |
| 502 | size_t rowBytes = 0, |
| 503 | uint32_t pixelOpsFlags = 0); |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 504 | |
| 505 | /** |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 506 | * Copy the src pixels [buffer, rowbytes, pixelconfig] into a render target at the specified |
| 507 | * rectangle. |
| 508 | * @param target the render target to write into. NULL means the current render target. |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 509 | * @param left left edge of the rectangle to write (inclusive) |
| 510 | * @param top top edge of the rectangle to write (inclusive) |
| 511 | * @param width width of rectangle to write in pixels. |
| 512 | * @param height height of rectangle to write in pixels. |
| 513 | * @param config the pixel config of the source buffer |
| 514 | * @param buffer memory to read the rectangle from. |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 515 | * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly |
| 516 | * packed. |
| 517 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 518 | */ |
| 519 | void writeRenderTargetPixels(GrRenderTarget* target, |
| 520 | int left, int top, int width, int height, |
| 521 | GrPixelConfig config, const void* buffer, |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 522 | size_t rowBytes = 0, |
| 523 | uint32_t pixelOpsFlags = 0); |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 524 | |
| 525 | /** |
| 526 | * Reads a rectangle of pixels from a texture. |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 527 | * @param texture the texture to read from. |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 528 | * @param left left edge of the rectangle to read (inclusive) |
| 529 | * @param top top edge of the rectangle to read (inclusive) |
| 530 | * @param width width of rectangle to read in pixels. |
| 531 | * @param height height of rectangle to read in pixels. |
| 532 | * @param config the pixel config of the destination buffer |
| 533 | * @param buffer memory to read the rectangle into. |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 534 | * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly |
| 535 | * packed. |
| 536 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 537 | * |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 538 | * @return true if the read succeeded, false if not. The read can fail because of an unsupported |
| 539 | * pixel config. |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 540 | */ |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 541 | bool readTexturePixels(GrTexture* texture, |
| bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 542 | int left, int top, int width, int height, |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 543 | GrPixelConfig config, void* buffer, |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 544 | size_t rowBytes = 0, |
| 545 | uint32_t pixelOpsFlags = 0); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 546 | |
| 547 | /** |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 548 | * Writes a rectangle of pixels to a texture. |
| 549 | * @param texture the render target to read from. |
| 550 | * @param left left edge of the rectangle to write (inclusive) |
| 551 | * @param top top edge of the rectangle to write (inclusive) |
| 552 | * @param width width of rectangle to write in pixels. |
| 553 | * @param height height of rectangle to write in pixels. |
| 554 | * @param config the pixel config of the source buffer |
| 555 | * @param buffer memory to read pixels from |
| 556 | * @param rowBytes number of bytes bewtween consecutive rows. Zero |
| 557 | * means rows are tightly packed. |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 558 | * @param pixelOpsFlags see PixelOpsFlags enum above. |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 559 | */ |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 560 | void writeTexturePixels(GrTexture* texture, |
| 561 | int left, int top, int width, int height, |
| 562 | GrPixelConfig config, const void* buffer, |
| bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 563 | size_t rowBytes, |
| 564 | uint32_t pixelOpsFlags = 0); |
| 565 | |
| 566 | |
| senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 567 | /** |
| senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 568 | * Copies all texels from one texture to another. |
| 569 | * @param src the texture to copy from. |
| 570 | * @param dst the render target to copy to. |
| 571 | */ |
| 572 | void copyTexture(GrTexture* src, GrRenderTarget* dst); |
| bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 573 | |
| 574 | /** |
| 575 | * Resolves a render target that has MSAA. The intermediate MSAA buffer is |
| 576 | * downsampled to the associated GrTexture (accessible via |
| 577 | * GrRenderTarget::asTexture()). Any pending draws to the render target will |
| 578 | * be executed before the resolve. |
| 579 | * |
| 580 | * This is only necessary when a client wants to access the object directly |
| 581 | * using the underlying graphics API. GrContext will detect when it must |
| 582 | * perform a resolve to a GrTexture used as the source of a draw or before |
| 583 | * reading pixels back from a GrTexture or GrRenderTarget. |
| 584 | */ |
| 585 | void resolveRenderTarget(GrRenderTarget* target); |
| 586 | |
| senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 587 | /** |
| senorblanco@chromium.org | 3b4dd90 | 2012-03-05 20:41:22 +0000 | [diff] [blame] | 588 | * Applies a 2D Gaussian blur to a given texture. |
| 589 | * @param srcTexture The source texture to be blurred. |
| senorblanco@chromium.org | 1e95d71 | 2012-07-18 19:52:53 +0000 | [diff] [blame] | 590 | * @param canClobberSrc If true, srcTexture may be overwritten, and |
| 591 | * may be returned as the result. |
| senorblanco@chromium.org | 3b4dd90 | 2012-03-05 20:41:22 +0000 | [diff] [blame] | 592 | * @param rect The destination rectangle. |
| 593 | * @param sigmaX The blur's standard deviation in X. |
| 594 | * @param sigmaY The blur's standard deviation in Y. |
| senorblanco@chromium.org | 1e95d71 | 2012-07-18 19:52:53 +0000 | [diff] [blame] | 595 | * @return the blurred texture, which may be srcTexture ref'ed, or a |
| 596 | * new texture. It is the caller's responsibility to unref this texture. |
| senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 597 | */ |
| senorblanco@chromium.org | 3b4dd90 | 2012-03-05 20:41:22 +0000 | [diff] [blame] | 598 | GrTexture* gaussianBlur(GrTexture* srcTexture, |
| senorblanco@chromium.org | 1e95d71 | 2012-07-18 19:52:53 +0000 | [diff] [blame] | 599 | bool canClobberSrc, |
| senorblanco@chromium.org | 3b4dd90 | 2012-03-05 20:41:22 +0000 | [diff] [blame] | 600 | const SkRect& rect, |
| 601 | float sigmaX, float sigmaY); |
| 602 | |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 603 | /** |
| bsalomon@google.com | 82aa748 | 2012-08-13 14:22:17 +0000 | [diff] [blame] | 604 | * Zooms a subset of the texture to a larger size with a nice edge. |
| 605 | * The inner rectangle is a simple scaling of the texture by a factor of |
| 606 | * |zoom|. The outer |inset| pixels transition from the background texture |
| 607 | * to the zoomed coordinate system at a rate of |
| 608 | * (distance_to_edge / inset) ^2, producing a rounded lens effect. |
| 609 | * @param srcTexture The source texture to be zoomed. |
| 610 | * @param dstRect The destination rectangle. |
| 611 | * @param srcRect The source rectangle. Must be smaller than |
| 612 | * dstRect |
| 613 | * @param inset Number of pixels to blend along the edges. |
| 614 | * @return the zoomed texture, which is dstTexture. |
| 615 | */ |
| 616 | GrTexture* zoom(GrTexture* srcTexture, |
| 617 | const SkRect& dstRect, const SkRect& srcRect, float inset); |
| 618 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 619 | /////////////////////////////////////////////////////////////////////////// |
| 620 | // Helpers |
| 621 | |
| 622 | class AutoRenderTarget : ::GrNoncopyable { |
| 623 | public: |
| 624 | AutoRenderTarget(GrContext* context, GrRenderTarget* target) { |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 625 | fPrevTarget = context->getRenderTarget(); |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 626 | context->setRenderTarget(target); |
| 627 | fContext = context; |
| 628 | } |
| 629 | AutoRenderTarget(GrContext* context) { |
| 630 | fPrevTarget = context->getRenderTarget(); |
| 631 | fContext = context; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 632 | } |
| 633 | ~AutoRenderTarget() { |
| 634 | if (fContext) { |
| 635 | fContext->setRenderTarget(fPrevTarget); |
| 636 | } |
| 637 | } |
| 638 | private: |
| 639 | GrContext* fContext; |
| 640 | GrRenderTarget* fPrevTarget; |
| 641 | }; |
| 642 | |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 643 | /** |
| 644 | * Save/restore the view-matrix in the context. |
| 645 | */ |
| 646 | class AutoMatrix : GrNoncopyable { |
| 647 | public: |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 648 | enum InitialMatrix { |
| 649 | kPreserve_InitialMatrix, |
| 650 | kIdentity_InitialMatrix, |
| 651 | }; |
| 652 | |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 653 | AutoMatrix() : fContext(NULL) {} |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 654 | |
| 655 | AutoMatrix(GrContext* ctx, InitialMatrix initialState) : fContext(ctx) { |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 656 | fMatrix = ctx->getMatrix(); |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 657 | switch (initialState) { |
| 658 | case kPreserve_InitialMatrix: |
| 659 | break; |
| 660 | case kIdentity_InitialMatrix: |
| 661 | ctx->setMatrix(GrMatrix::I()); |
| 662 | break; |
| 663 | default: |
| 664 | GrCrash("Unexpected initial matrix state"); |
| 665 | } |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 666 | } |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 667 | |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 668 | AutoMatrix(GrContext* ctx, const GrMatrix& matrix) : fContext(ctx) { |
| 669 | fMatrix = ctx->getMatrix(); |
| 670 | ctx->setMatrix(matrix); |
| 671 | } |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 672 | |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 673 | void set(GrContext* ctx) { |
| 674 | if (NULL != fContext) { |
| 675 | fContext->setMatrix(fMatrix); |
| 676 | } |
| 677 | fMatrix = ctx->getMatrix(); |
| 678 | fContext = ctx; |
| 679 | } |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 680 | |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 681 | void set(GrContext* ctx, const GrMatrix& matrix) { |
| 682 | if (NULL != fContext) { |
| 683 | fContext->setMatrix(fMatrix); |
| 684 | } |
| 685 | fMatrix = ctx->getMatrix(); |
| 686 | ctx->setMatrix(matrix); |
| 687 | fContext = ctx; |
| 688 | } |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 689 | |
| robertphillips@google.com | fea85ac | 2012-07-11 18:53:23 +0000 | [diff] [blame] | 690 | ~AutoMatrix() { |
| 691 | if (NULL != fContext) { |
| 692 | fContext->setMatrix(fMatrix); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | private: |
| 697 | GrContext* fContext; |
| 698 | GrMatrix fMatrix; |
| 699 | }; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 700 | |
| robertphillips@google.com | 56c79b1 | 2012-07-11 20:57:46 +0000 | [diff] [blame] | 701 | class AutoClip : GrNoncopyable { |
| 702 | public: |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 703 | // This enum exists to require a caller of the constructor to acknowledge that the clip will |
| 704 | // initially be wide open. It also could be extended if there are other desirable initial |
| 705 | // clip states. |
| 706 | enum InitialClip { |
| 707 | kWideOpen_InitialClip, |
| 708 | }; |
| 709 | |
| 710 | AutoClip(GrContext* context, InitialClip initialState) { |
| 711 | GrAssert(kWideOpen_InitialClip == initialState); |
| 712 | fOldClip = context->getClip(); |
| 713 | fNewClipData.fClipStack = &fNewClipStack; |
| 714 | context->setClip(&fNewClipData); |
| 715 | fContext = context; |
| 716 | } |
| 717 | |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 718 | AutoClip(GrContext* context, const GrRect& newClipRect) |
| robertphillips@google.com | 56c79b1 | 2012-07-11 20:57:46 +0000 | [diff] [blame] | 719 | : fContext(context) |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 720 | , fNewClipStack(newClipRect) { |
| 721 | fNewClipData.fClipStack = &fNewClipStack; |
| 722 | |
| robertphillips@google.com | 56c79b1 | 2012-07-11 20:57:46 +0000 | [diff] [blame] | 723 | fOldClip = fContext->getClip(); |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 724 | fContext->setClip(&fNewClipData); |
| robertphillips@google.com | 56c79b1 | 2012-07-11 20:57:46 +0000 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | ~AutoClip() { |
| 728 | if (NULL != fContext) { |
| 729 | fContext->setClip(fOldClip); |
| 730 | } |
| 731 | } |
| 732 | private: |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 733 | GrContext* fContext; |
| 734 | const GrClipData* fOldClip; |
| 735 | |
| robertphillips@google.com | 641f8b1 | 2012-07-31 19:15:58 +0000 | [diff] [blame] | 736 | SkClipStack fNewClipStack; |
| robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 737 | GrClipData fNewClipData; |
| robertphillips@google.com | 56c79b1 | 2012-07-11 20:57:46 +0000 | [diff] [blame] | 738 | }; |
| 739 | |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 740 | class AutoWideOpenIdentityDraw { |
| 741 | public: |
| 742 | AutoWideOpenIdentityDraw(GrContext* ctx, GrRenderTarget* rt) |
| 743 | : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) |
| 744 | , fAutoRT(ctx, rt) |
| 745 | , fAutoMatrix(ctx, AutoMatrix::kIdentity_InitialMatrix) { |
| 746 | } |
| 747 | private: |
| 748 | AutoClip fAutoClip; |
| 749 | AutoRenderTarget fAutoRT; |
| 750 | AutoMatrix fAutoMatrix; |
| 751 | }; |
| 752 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 753 | /////////////////////////////////////////////////////////////////////////// |
| 754 | // Functions intended for internal use only. |
| 755 | GrGpu* getGpu() { return fGpu; } |
| bsalomon@google.com | 1f221a7 | 2011-08-23 20:54:07 +0000 | [diff] [blame] | 756 | const GrGpu* getGpu() const { return fGpu; } |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 757 | GrFontCache* getFontCache() { return fFontCache; } |
| 758 | GrDrawTarget* getTextTarget(const GrPaint& paint); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 759 | const GrIndexBuffer* getQuadIndexBuffer() const; |
| bsalomon@google.com | 9923c2b | 2012-06-06 18:21:18 +0000 | [diff] [blame] | 760 | |
| bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 761 | /** |
| 762 | * Stencil buffers add themselves to the cache using |
| 763 | * addAndLockStencilBuffer. When a SB's RT-attachment count |
| 764 | * reaches zero the SB unlocks itself using unlockStencilBuffer and is |
| 765 | * eligible for purging. findStencilBuffer is called to check the cache for |
| 766 | * a SB that matching an RT's criteria. If a match is found that has been |
| 767 | * unlocked (its attachment count has reached 0) then it will be relocked. |
| 768 | */ |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 769 | void addAndLockStencilBuffer(GrStencilBuffer* sb); |
| 770 | void unlockStencilBuffer(GrStencilBuffer* sb); |
| bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 771 | GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 772 | |
| robertphillips@google.com | 2c75681 | 2012-05-22 20:28:23 +0000 | [diff] [blame] | 773 | GrPathRenderer* getPathRenderer(const SkPath& path, |
| 774 | GrPathFill fill, |
| 775 | const GrDrawTarget* target, |
| robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 776 | bool antiAlias, |
| 777 | bool allowSW); |
| robertphillips@google.com | 2c75681 | 2012-05-22 20:28:23 +0000 | [diff] [blame] | 778 | |
| robertphillips@google.com | 5955202 | 2012-08-31 13:07:37 +0000 | [diff] [blame^] | 779 | #if GR_CACHE_STATS |
| robertphillips@google.com | 5f9f2f5 | 2012-08-22 10:57:05 +0000 | [diff] [blame] | 780 | void printCacheStats() const; |
| 781 | #endif |
| 782 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 783 | private: |
| bsalomon@google.com | 1d4edd3 | 2012-08-16 18:36:06 +0000 | [diff] [blame] | 784 | // Used to indicate whether a draw should be performed immediately or queued in fDrawBuffer. |
| 785 | enum BufferedDraw { |
| 786 | kYes_BufferedDraw, |
| 787 | kNo_BufferedDraw, |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 788 | }; |
| bsalomon@google.com | 1d4edd3 | 2012-08-16 18:36:06 +0000 | [diff] [blame] | 789 | BufferedDraw fLastDrawWasBuffered; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 790 | |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 791 | GrGpu* fGpu; |
| bsalomon@google.com | 10e04bf | 2012-03-30 14:35:04 +0000 | [diff] [blame] | 792 | GrDrawState* fDrawState; |
| 793 | |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 794 | GrResourceCache* fTextureCache; |
| 795 | GrFontCache* fFontCache; |
| bsalomon@google.com | dfe75bc | 2011-03-25 12:31:16 +0000 | [diff] [blame] | 796 | |
| bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 797 | GrPathRendererChain* fPathRendererChain; |
| robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 798 | GrSoftwarePathRenderer* fSoftwarePathRenderer; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 799 | |
| 800 | GrVertexBufferAllocPool* fDrawBufferVBAllocPool; |
| 801 | GrIndexBufferAllocPool* fDrawBufferIBAllocPool; |
| 802 | GrInOrderDrawBuffer* fDrawBuffer; |
| 803 | |
| robertphillips@google.com | f69a11b | 2012-06-15 13:58:07 +0000 | [diff] [blame] | 804 | GrAARectRenderer* fAARectRenderer; |
| bsalomon@google.com | dfe75bc | 2011-03-25 12:31:16 +0000 | [diff] [blame] | 805 | |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 806 | bool fDidTestPMConversions; |
| 807 | int fPMToUPMConversion; |
| 808 | int fUPMToPMConversion; |
| 809 | |
| robertphillips@google.com | f69a11b | 2012-06-15 13:58:07 +0000 | [diff] [blame] | 810 | GrContext(GrGpu* gpu); |
| bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 811 | |
| bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 812 | void setupDrawBuffer(); |
| 813 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 814 | void flushDrawBuffer(); |
| 815 | |
| bsalomon@google.com | 10e04bf | 2012-03-30 14:35:04 +0000 | [diff] [blame] | 816 | void setPaint(const GrPaint& paint); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 817 | |
| bsalomon@google.com | 07ea2db | 2012-08-17 14:06:49 +0000 | [diff] [blame] | 818 | /// Sets the paint and returns the target to draw into. The paint can be NULL in which case the |
| 819 | /// draw state is left unmodified. |
| 820 | GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw); |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 821 | |
| bsalomon@google.com | 8d033a1 | 2012-04-27 15:52:53 +0000 | [diff] [blame] | 822 | void internalDrawPath(const GrPaint& paint, const SkPath& path, |
| bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 823 | GrPathFill fill, const GrPoint* translate); |
| 824 | |
| robertphillips@google.com | 3319f33 | 2012-08-13 18:00:36 +0000 | [diff] [blame] | 825 | GrTexture* createResizedTexture(const GrTextureDesc& desc, |
| 826 | const GrCacheData& cacheData, |
| 827 | void* srcData, |
| 828 | size_t rowBytes, |
| 829 | bool needsFiltering); |
| 830 | |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 831 | // Needed so GrTexture's returnToCache helper function can call |
| 832 | // addExistingTextureToCache |
| 833 | friend class GrTexture; |
| 834 | |
| 835 | // Add an existing texture to the texture cache. This is intended solely |
| 836 | // for use with textures released from an GrAutoScratchTexture. |
| 837 | void addExistingTextureToCache(GrTexture* texture); |
| reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 838 | |
| bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 839 | GrCustomStage* createPMToUPMEffect(GrTexture* texture, bool swapRAndB); |
| 840 | GrCustomStage* createUPMToPMEffect(GrTexture* texture, bool swapRAndB); |
| 841 | |
| reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 842 | typedef GrRefCnt INHERITED; |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 843 | }; |
| 844 | |
| 845 | /** |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 846 | * Gets and locks a scratch texture from a descriptor using |
| 847 | * either exact or approximate criteria. Unlocks texture in |
| 848 | * the destructor. |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 849 | */ |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 850 | class GrAutoScratchTexture : ::GrNoncopyable { |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 851 | public: |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 852 | GrAutoScratchTexture() |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 853 | : fContext(NULL) |
| 854 | , fTexture(NULL) { |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 855 | } |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 856 | |
| 857 | GrAutoScratchTexture(GrContext* context, |
| 858 | const GrTextureDesc& desc, |
| 859 | GrContext::ScratchTexMatch match = |
| 860 | GrContext::kApprox_ScratchTexMatch) |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 861 | : fContext(NULL) |
| 862 | , fTexture(NULL) { |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 863 | this->set(context, desc, match); |
| 864 | } |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 865 | |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 866 | ~GrAutoScratchTexture() { |
| robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 867 | this->reset(); |
| 868 | } |
| 869 | |
| 870 | void reset() { |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 871 | if (NULL != fContext && NULL != fTexture) { |
| 872 | fContext->unlockTexture(fTexture); |
| 873 | fTexture = NULL; |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 874 | } |
| 875 | } |
| bsalomon@google.com | 8422311 | 2011-07-14 14:45:44 +0000 | [diff] [blame] | 876 | |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 877 | /* |
| 878 | * When detaching a texture we do not unlock it in the texture cache but |
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 879 | * we do set the returnToCache flag. In this way the texture remains |
| 880 | * "locked" in the texture cache until it is freed and recycled in |
| 881 | * GrTexture::internal_dispose. In reality, the texture has been removed |
| 882 | * from the cache (because this is in AutoScratchTexture) and by not |
| 883 | * calling unlockTexture we simply don't re-add it. It will be reattached |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 884 | * in GrTexture::internal_dispose. |
| 885 | * |
| 886 | * Note that the caller is assumed to accept and manage the ref to the |
| 887 | * returned texture. |
| 888 | */ |
| 889 | GrTexture* detach() { |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 890 | GrTexture* temp = fTexture; |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 891 | |
| robertphillips@google.com | 521eaf8 | 2012-08-22 11:03:19 +0000 | [diff] [blame] | 892 | // Conceptually the texture's cache entry loses its ref to the |
| 893 | // texture while the caller of this method gets a ref. |
| 894 | GrAssert(NULL != temp->getCacheEntry()); |
| 895 | |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 896 | fTexture = NULL; |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 897 | |
| 898 | temp->setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit); |
| robertphillips@google.com | 15c0fea | 2012-06-22 12:41:43 +0000 | [diff] [blame] | 899 | return temp; |
| 900 | } |
| 901 | |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 902 | GrTexture* set(GrContext* context, |
| 903 | const GrTextureDesc& desc, |
| 904 | GrContext::ScratchTexMatch match = |
| 905 | GrContext::kApprox_ScratchTexMatch) { |
| robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 906 | this->reset(); |
| 907 | |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 908 | fContext = context; |
| 909 | if (NULL != fContext) { |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 910 | fTexture = fContext->lockScratchTexture(desc, match); |
| 911 | if (NULL == fTexture) { |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 912 | fContext = NULL; |
| 913 | } |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 914 | return fTexture; |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 915 | } else { |
| 916 | return NULL; |
| 917 | } |
| 918 | } |
| 919 | |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 920 | GrTexture* texture() { return fTexture; } |
| 921 | |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 922 | private: |
| bsalomon@google.com | 50398bf | 2011-07-26 20:45:30 +0000 | [diff] [blame] | 923 | GrContext* fContext; |
| robertphillips@google.com | 1f47f4f | 2012-08-16 14:49:16 +0000 | [diff] [blame] | 924 | GrTexture* fTexture; |
| senorblanco@chromium.org | aadd9f8 | 2011-07-12 19:44:51 +0000 | [diff] [blame] | 925 | }; |
| 926 | |
| bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 927 | #endif |