blob: 9fb47e5b1ea673a8a4238a79f927dea5d5518628 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
bsalomon@google.com27847de2011-02-22 20:59:41 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.com27847de2011-02-22 20:59:41 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
bsalomon@google.com27847de2011-02-22 20:59:41 +000010#ifndef GrContext_DEFINED
11#define GrContext_DEFINED
12
bsalomon@google.com27847de2011-02-22 20:59:41 +000013#include "GrPaint.h"
robertphillips@google.comf6747b02012-06-12 00:32:28 +000014#include "GrAARectRenderer.h"
robertphillips@google.coma2d71482012-08-01 20:08:47 +000015#include "GrClipData.h"
bsalomon@google.comc287a892011-08-19 14:49:36 +000016// not strictly needed but requires WK change in LayerTextureUpdaterCanvas to
17// remove.
18#include "GrRenderTarget.h"
robertphillips@google.coma2d71482012-08-01 20:08:47 +000019#include "SkClipStack.h"
bsalomon@google.com27847de2011-02-22 20:59:41 +000020
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +000021class GrAutoScratchTexture;
bsalomon@google.com10e04bf2012-03-30 14:35:04 +000022class GrDrawState;
bsalomon@google.com583a1e32011-08-17 13:42:46 +000023class GrDrawTarget;
bsalomon@google.com27847de2011-02-22 20:59:41 +000024class GrFontCache;
bsalomon@google.com05ef5102011-05-02 21:14:59 +000025class GrGpu;
bsalomon@google.com583a1e32011-08-17 13:42:46 +000026class GrIndexBuffer;
bsalomon@google.com27847de2011-02-22 20:59:41 +000027class GrIndexBufferAllocPool;
28class GrInOrderDrawBuffer;
bsalomon@google.com583a1e32011-08-17 13:42:46 +000029class GrPathRenderer;
bsalomon@google.com30085192011-08-19 15:42:31 +000030class GrPathRendererChain;
bsalomon@google.com50398bf2011-07-26 20:45:30 +000031class GrResourceEntry;
32class GrResourceCache;
bsalomon@google.com558a75b2011-08-08 17:01:14 +000033class GrStencilBuffer;
bsalomon@google.com583a1e32011-08-17 13:42:46 +000034class GrVertexBuffer;
bsalomon@google.com50398bf2011-07-26 20:45:30 +000035class GrVertexBufferAllocPool;
robertphillips@google.com72176b22012-05-23 13:19:12 +000036class GrSoftwarePathRenderer;
bsalomon@google.com50398bf2011-07-26 20:45:30 +000037
bsalomon@google.com91826102011-03-21 19:51:57 +000038class GR_API GrContext : public GrRefCnt {
bsalomon@google.com27847de2011-02-22 20:59:41 +000039public:
reed@google.comfa35e3d2012-06-26 20:16:17 +000040 SK_DECLARE_INST_COUNT(GrContext)
41
bsalomon@google.com27847de2011-02-22 20:59:41 +000042 /**
43 * Creates a GrContext from within a 3D context.
44 */
bsalomon@google.com05ef5102011-05-02 21:14:59 +000045 static GrContext* Create(GrEngine engine,
46 GrPlatform3DContext context3D);
bsalomon@google.com27847de2011-02-22 20:59:41 +000047
bsalomon@google.comc0af3172012-06-15 14:10:09 +000048 /**
49 * Returns the number of GrContext instances for the current thread.
50 */
51 static int GetThreadInstanceCount();
52
bsalomon@google.com27847de2011-02-22 20:59:41 +000053 virtual ~GrContext();
54
55 /**
56 * The GrContext normally assumes that no outsider is setting state
57 * within the underlying 3D API's context/device/whatever. This call informs
58 * the context that the state was modified and it should resend. Shouldn't
59 * be called frequently for good performance.
60 */
61 void resetContext();
62
bsalomon@google.com8fe72472011-03-30 21:26:44 +000063 /**
64 * Abandons all gpu resources, assumes 3D API state is unknown. Call this
65 * if you have lost the associated GPU context, and thus internal texture,
66 * buffer, etc. references/IDs are now invalid. Should be called even when
67 * GrContext is no longer going to be used for two reasons:
68 * 1) ~GrContext will not try to free the objects in the 3D API.
69 * 2) If you've created GrResources that outlive the GrContext they will
70 * be marked as invalid (GrResource::isValid()) and won't attempt to
71 * free their underlying resource in the 3D API.
72 * Content drawn since the last GrContext::flush() may be lost.
73 */
74 void contextLost();
bsalomon@google.com27847de2011-02-22 20:59:41 +000075
76 /**
junov@google.com53a55842011-06-08 22:55:10 +000077 * Similar to contextLost, but makes no attempt to reset state.
78 * Use this method when GrContext destruction is pending, but
79 * the graphics context is destroyed first.
80 */
81 void contextDestroyed();
82
83 /**
bsalomon@google.com8fe72472011-03-30 21:26:44 +000084 * Frees gpu created by the context. Can be called to reduce GPU memory
85 * pressure.
bsalomon@google.com27847de2011-02-22 20:59:41 +000086 */
bsalomon@google.com8fe72472011-03-30 21:26:44 +000087 void freeGpuResources();
88
bsalomon@google.com07fc0d12012-06-22 15:15:59 +000089 /**
90 * Returns the number of bytes of GPU memory hosted by the texture cache.
91 */
92 size_t getGpuTextureCacheBytes() const;
93
bsalomon@google.com8fe72472011-03-30 21:26:44 +000094 ///////////////////////////////////////////////////////////////////////////
95 // Textures
bsalomon@google.com27847de2011-02-22 20:59:41 +000096
97 /**
bsalomon@google.com1fadb202011-12-12 16:10:08 +000098 * Create a new entry, based on the specified key and texture, and return
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +000099 * a "locked" texture. Must call be balanced with an unlockTexture() call.
bsalomon@google.com1fadb202011-12-12 16:10:08 +0000100 *
bsalomon@google.comb8670992012-07-25 21:27:09 +0000101 * @param params The tex params used to draw a texture may help determine
102 * the cache entry used. (e.g. different versions may exist
103 * for different wrap modes on GPUs with limited NPOT
104 * texture support). NULL implies clamp wrap modes.
bsalomon@google.com1fadb202011-12-12 16:10:08 +0000105 * @param desc Description of the texture properties.
robertphillips@google.com9c2ea842012-08-13 17:47:59 +0000106 * @param cacheData Cache-specific properties (e.g., texture gen ID)
bsalomon@google.com1fadb202011-12-12 16:10:08 +0000107 * @param srcData Pointer to the pixel values.
108 * @param rowBytes The number of bytes between rows of the texture. Zero
109 * implies tightly packed rows.
110 */
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000111 GrTexture* createAndLockTexture(const GrTextureParams* params,
112 const GrTextureDesc& desc,
113 const GrCacheData& cacheData,
114 void* srcData, size_t rowBytes);
bsalomon@google.com1fadb202011-12-12 16:10:08 +0000115
116 /**
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000117 * Search for an entry based on key and dimensions. If found, "lock" it and
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000118 * return it. The return value will be NULL if not found.
bsalomon@google.com1fadb202011-12-12 16:10:08 +0000119 * Must be balanced with an unlockTexture() call.
120 *
bsalomon@google.comb8670992012-07-25 21:27:09 +0000121 * @param desc Description of the texture properties.
robertphillips@google.com9c2ea842012-08-13 17:47:59 +0000122 * @param cacheData Cache-specific properties (e.g., texture gen ID)
bsalomon@google.comb8670992012-07-25 21:27:09 +0000123 * @param params The tex params used to draw a texture may help determine
124 * the cache entry used. (e.g. different versions may exist
125 * for different wrap modes on GPUs with limited NPOT
126 * texture support). NULL implies clamp wrap modes.
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000127 */
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000128 GrTexture* findAndLockTexture(const GrTextureDesc& desc,
129 const GrCacheData& cacheData,
130 const GrTextureParams* params);
bsalomon@google.comfb309512011-11-30 14:13:48 +0000131 /**
132 * Determines whether a texture is in the cache. If the texture is found it
133 * will not be locked or returned. This call does not affect the priority of
134 * the texture for deletion.
135 */
robertphillips@google.com75b3c962012-06-07 12:08:45 +0000136 bool isTextureInCache(const GrTextureDesc& desc,
robertphillips@google.com9c2ea842012-08-13 17:47:59 +0000137 const GrCacheData& cacheData,
bsalomon@google.comb8670992012-07-25 21:27:09 +0000138 const GrTextureParams* params) const;
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000139
140 /**
141 * Enum that determines how closely a returned scratch texture must match
142 * a provided GrTextureDesc.
143 */
144 enum ScratchTexMatch {
145 /**
146 * Finds a texture that exactly matches the descriptor.
147 */
148 kExact_ScratchTexMatch,
149 /**
150 * Finds a texture that approximately matches the descriptor. Will be
151 * at least as large in width and height as desc specifies. If desc
152 * specifies that texture is a render target then result will be a
153 * render target. If desc specifies a render target and doesn't set the
154 * no stencil flag then result will have a stencil. Format and aa level
155 * will always match.
156 */
157 kApprox_ScratchTexMatch
158 };
bsalomon@google.com27847de2011-02-22 20:59:41 +0000159
160 /**
bsalomon@google.comfea37b52011-04-25 15:51:06 +0000161 * Returns a texture matching the desc. It's contents are unknown. Subsequent
162 * requests with the same descriptor are not guaranteed to return the same
163 * texture. The same texture is guaranteed not be returned again until it is
robertphillips@google.com15c0fea2012-06-22 12:41:43 +0000164 * unlocked. Call must be balanced with an unlockTexture() call.
bsalomon@google.coma39f4042011-04-26 13:18:16 +0000165 *
166 * Textures created by createAndLockTexture() hide the complications of
167 * tiling non-power-of-two textures on APIs that don't support this (e.g.
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000168 * unextended GLES2). Tiling a npot texture created by lockScratchTexture on
bsalomon@google.coma39f4042011-04-26 13:18:16 +0000169 * such an API will create gaps in the tiling pattern. This includes clamp
170 * mode. (This may be addressed in a future update.)
bsalomon@google.comfea37b52011-04-25 15:51:06 +0000171 */
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000172 GrTexture* lockScratchTexture(const GrTextureDesc& desc,
173 ScratchTexMatch match);
bsalomon@google.comb5b31682011-06-16 18:05:35 +0000174
175 /**
bsalomon@google.com27847de2011-02-22 20:59:41 +0000176 * When done with an entry, call unlockTexture(entry) on it, which returns
177 * it to the cache, where it may be purged.
178 */
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000179 void unlockTexture(GrTexture* texture);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000180
181 /**
bsalomon@google.com27847de2011-02-22 20:59:41 +0000182 * Creates a texture that is outside the cache. Does not count against
183 * cache's budget.
184 */
robertphillips@google.com75b3c962012-06-07 12:08:45 +0000185 GrTexture* createUncachedTexture(const GrTextureDesc& desc,
bsalomon@google.com27847de2011-02-22 20:59:41 +0000186 void* srcData,
187 size_t rowBytes);
188
189 /**
bsalomon@google.comb8670992012-07-25 21:27:09 +0000190 * Returns true if the specified use of an indexed texture is supported.
191 * Support may depend upon whether the texture params indicate that the
192 * texture will be tiled. Passing NULL for the texture params indicates
193 * clamp mode.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000194 */
bsalomon@google.comb8670992012-07-25 21:27:09 +0000195 bool supportsIndex8PixelConfig(const GrTextureParams*,
bsalomon@google.com1f221a72011-08-23 20:54:07 +0000196 int width,
197 int height) const;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000198
199 /**
bsalomon@google.com07fc0d12012-06-22 15:15:59 +0000200 * Return the current texture cache limits.
201 *
202 * @param maxTextures If non-null, returns maximum number of textures that
203 * can be held in the cache.
204 * @param maxTextureBytes If non-null, returns maximum number of bytes of
205 * texture memory that can be held in the cache.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000206 */
bsalomon@google.com07fc0d12012-06-22 15:15:59 +0000207 void getTextureCacheLimits(int* maxTextures, size_t* maxTextureBytes) const;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000208
209 /**
bsalomon@google.com07fc0d12012-06-22 15:15:59 +0000210 * Specify the texture cache limits. If the current cache exceeds either
211 * of these, it will be purged (LRU) to keep the cache within these limits.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000212 *
bsalomon@google.com07fc0d12012-06-22 15:15:59 +0000213 * @param maxTextures The maximum number of textures that can be held in
214 * the cache.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000215 * @param maxTextureBytes The maximum number of bytes of texture memory
216 * that can be held in the cache.
217 */
bsalomon@google.com07fc0d12012-06-22 15:15:59 +0000218 void setTextureCacheLimits(int maxTextures, size_t maxTextureBytes);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000219
220 /**
221 * Return the max width or height of a texture supported by the current gpu
222 */
bsalomon@google.com91958362011-06-13 17:58:13 +0000223 int getMaxTextureSize() const;
224
225 /**
226 * Return the max width or height of a render target supported by the
227 * current gpu
228 */
229 int getMaxRenderTargetSize() const;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000230
231 ///////////////////////////////////////////////////////////////////////////
232 // Render targets
233
234 /**
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000235 * Sets the render target.
236 * @param target the render target to set. (should not be NULL.)
237 */
238 void setRenderTarget(GrRenderTarget* target);
239
240 /**
241 * Gets the current render target.
242 * @return the currently bound render target. Should never be NULL.
243 */
244 const GrRenderTarget* getRenderTarget() const;
245 GrRenderTarget* getRenderTarget();
246
robertphillips@google.comf69a11b2012-06-15 13:58:07 +0000247 GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; }
248
robertphillips@google.com99a5ac02012-04-10 19:26:38 +0000249 /**
250 * Can the provided configuration act as a color render target?
251 */
252 bool isConfigRenderable(GrPixelConfig config) const;
253
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000254 ///////////////////////////////////////////////////////////////////////////
255 // Platform Surfaces
256
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000257 /**
bsalomon@google.come269f212011-11-07 13:29:52 +0000258 * Wraps an existing texture with a GrTexture object.
259 *
260 * OpenGL: if the object is a texture Gr may change its GL texture params
261 * when it is drawn.
262 *
263 * @param desc description of the object to create.
264 *
265 * @return GrTexture object or NULL on failure.
266 */
267 GrTexture* createPlatformTexture(const GrPlatformTextureDesc& desc);
268
269 /**
270 * Wraps an existing render target with a GrRenderTarget object. It is
271 * similar to createPlatformTexture but can be used to draw into surfaces
272 * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that
273 * the client will resolve to a texture).
274 *
275 * @param desc description of the object to create.
276 *
277 * @return GrTexture object or NULL on failure.
278 */
279 GrRenderTarget* createPlatformRenderTarget(
280 const GrPlatformRenderTargetDesc& desc);
281
bsalomon@google.com27847de2011-02-22 20:59:41 +0000282 ///////////////////////////////////////////////////////////////////////////
283 // Matrix state
284
285 /**
286 * Gets the current transformation matrix.
287 * @return the current matrix.
288 */
289 const GrMatrix& getMatrix() const;
290
291 /**
292 * Sets the transformation matrix.
293 * @param m the matrix to set.
294 */
295 void setMatrix(const GrMatrix& m);
296
297 /**
298 * Concats the current matrix. The passed matrix is applied before the
299 * current matrix.
300 * @param m the matrix to concat.
301 */
302 void concatMatrix(const GrMatrix& m) const;
303
304
305 ///////////////////////////////////////////////////////////////////////////
306 // Clip state
307 /**
308 * Gets the current clip.
309 * @return the current clip.
310 */
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000311 const GrClipData* getClip() const;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000312
313 /**
314 * Sets the clip.
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000315 * @param clipData the clip to set.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000316 */
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000317 void setClip(const GrClipData* clipData);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000318
bsalomon@google.com27847de2011-02-22 20:59:41 +0000319 ///////////////////////////////////////////////////////////////////////////
320 // Draws
321
322 /**
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000323 * Clear the entire or rect of the render target, ignoring any clips.
324 * @param rect the rect to clear or the whole thing if rect is NULL.
325 * @param color the color to clear to.
robertphillips@google.comc82a8b72012-06-21 20:15:48 +0000326 * @param target if non-NULL, the render target to clear otherwise clear
327 * the current render target
bsalomon@google.com27847de2011-02-22 20:59:41 +0000328 */
robertphillips@google.comc82a8b72012-06-21 20:15:48 +0000329 void clear(const GrIRect* rect, GrColor color,
330 GrRenderTarget* target = NULL);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000331
332 /**
333 * Draw everywhere (respecting the clip) with the paint.
334 */
335 void drawPaint(const GrPaint& paint);
336
337 /**
338 * Draw the rect using a paint.
339 * @param paint describes how to color pixels.
340 * @param strokeWidth If strokeWidth < 0, then the rect is filled, else
341 * the rect is mitered stroked based on strokeWidth. If
342 * strokeWidth == 0, then the stroke is always a single
343 * pixel thick.
344 * @param matrix Optional matrix applied to the rect. Applied before
345 * context's matrix or the paint's matrix.
346 * The rects coords are used to access the paint (through texture matrix)
347 */
348 void drawRect(const GrPaint& paint,
349 const GrRect&,
350 GrScalar strokeWidth = -1,
351 const GrMatrix* matrix = NULL);
352
353 /**
354 * Maps a rect of paint coordinates onto the a rect of destination
355 * coordinates. Each rect can optionally be transformed. The srcRect
356 * is stretched over the dstRect. The dstRect is transformed by the
357 * context's matrix and the srcRect is transformed by the paint's matrix.
358 * Additional optional matrices can be provided by parameters.
359 *
360 * @param paint describes how to color pixels.
361 * @param dstRect the destination rect to draw.
362 * @param srcRect rect of paint coordinates to be mapped onto dstRect
363 * @param dstMatrix Optional matrix to transform dstRect. Applied before
364 * context's matrix.
365 * @param srcMatrix Optional matrix to transform srcRect Applied before
366 * paint's matrix.
367 */
368 void drawRectToRect(const GrPaint& paint,
369 const GrRect& dstRect,
370 const GrRect& srcRect,
371 const GrMatrix* dstMatrix = NULL,
372 const GrMatrix* srcMatrix = NULL);
373
374 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +0000375 * Draws a path.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000376 *
377 * @param paint describes how to color pixels.
reed@google.com07f3ee12011-05-16 17:21:57 +0000378 * @param path the path to draw
bsalomon@google.com27847de2011-02-22 20:59:41 +0000379 * @param fill the path filling rule to use.
380 * @param translate optional additional translation applied to the
381 * path.
382 */
bsalomon@google.com8d033a12012-04-27 15:52:53 +0000383 void drawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill,
bsalomon@google.comd302f142011-03-03 13:54:13 +0000384 const GrPoint* translate = NULL);
reed@google.com07f3ee12011-05-16 17:21:57 +0000385
bsalomon@google.com27847de2011-02-22 20:59:41 +0000386 /**
387 * Draws vertices with a paint.
388 *
389 * @param paint describes how to color pixels.
390 * @param primitiveType primitives type to draw.
391 * @param vertexCount number of vertices.
392 * @param positions array of vertex positions, required.
393 * @param texCoords optional array of texture coordinates used
394 * to access the paint.
395 * @param colors optional array of per-vertex colors, supercedes
396 * the paint's color field.
397 * @param indices optional array of indices. If NULL vertices
398 * are drawn non-indexed.
399 * @param indexCount if indices is non-null then this is the
400 * number of indices.
401 */
402 void drawVertices(const GrPaint& paint,
403 GrPrimitiveType primitiveType,
404 int vertexCount,
405 const GrPoint positions[],
406 const GrPoint texs[],
407 const GrColor colors[],
408 const uint16_t indices[],
409 int indexCount);
410
bsalomon@google.com93c96602012-04-27 13:05:21 +0000411 /**
412 * Draws an oval.
413 *
414 * @param paint describes how to color pixels.
415 * @param rect the bounding rect of the oval.
416 * @param strokeWidth if strokeWidth < 0, then the oval is filled, else
417 * the rect is stroked based on strokeWidth. If
418 * strokeWidth == 0, then the stroke is always a single
419 * pixel thick.
420 */
421 void drawOval(const GrPaint& paint,
422 const GrRect& rect,
423 SkScalar strokeWidth);
424
bsalomon@google.com27847de2011-02-22 20:59:41 +0000425 ///////////////////////////////////////////////////////////////////////////
426 // Misc.
427
428 /**
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000429 * Flags that affect flush() behavior.
430 */
431 enum FlushBits {
432 /**
433 * A client may want Gr to bind a GrRenderTarget in the 3D API so that
434 * it can be rendered to directly. However, Gr lazily sets state. Simply
435 * calling setRenderTarget() followed by flush() without flags may not
436 * bind the render target. This flag forces the context to bind the last
437 * set render target in the 3D API.
438 */
439 kForceCurrentRenderTarget_FlushBit = 0x1,
440 /**
441 * A client may reach a point where it has partially rendered a frame
442 * through a GrContext that it knows the user will never see. This flag
443 * causes the flush to skip submission of deferred content to the 3D API
444 * during the flush.
445 */
446 kDiscard_FlushBit = 0x2,
447 };
448
449 /**
bsalomon@google.com27847de2011-02-22 20:59:41 +0000450 * Call to ensure all drawing to the context has been issued to the
451 * underlying 3D API.
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000452 * @param flagsBitfield flags that control the flushing behavior. See
453 * FlushBits.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000454 */
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000455 void flush(int flagsBitfield = 0);
bsalomon@google.com6f379512011-11-16 20:36:03 +0000456
bsalomon@google.com0342a852012-08-20 19:22:38 +0000457 /**
458 * These flags can be used with the read/write pixels functions below.
459 */
460 enum PixelOpsFlags {
461 /** The GrContext will not be flushed. This means that the read or write may occur before
462 previous draws have executed. */
463 kDontFlush_PixelOpsFlag = 0x1,
464 /** The src for write or dst read is unpremultiplied. This is only respected if both the
465 config src and dst configs are an RGBA/BGRA 8888 format. */
466 kUnpremul_PixelOpsFlag = 0x2,
467 };
468
bsalomon@google.com27847de2011-02-22 20:59:41 +0000469 /**
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000470 * Reads a rectangle of pixels from a render target.
bsalomon@google.com0342a852012-08-20 19:22:38 +0000471 * @param target the render target to read from. NULL means the current render target.
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000472 * @param left left edge of the rectangle to read (inclusive)
473 * @param top top edge of the rectangle to read (inclusive)
474 * @param width width of rectangle to read in pixels.
475 * @param height height of rectangle to read in pixels.
476 * @param config the pixel config of the destination buffer
477 * @param buffer memory to read the rectangle into.
bsalomon@google.com0342a852012-08-20 19:22:38 +0000478 * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly
479 * packed.
480 * @param pixelOpsFlags see PixelOpsFlags enum above.
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000481 *
bsalomon@google.com0342a852012-08-20 19:22:38 +0000482 * @return true if the read succeeded, false if not. The read can fail because of an unsupported
483 * pixel config or because no render target is currently set and NULL was passed for
484 * target.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000485 */
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000486 bool readRenderTargetPixels(GrRenderTarget* target,
487 int left, int top, int width, int height,
bsalomon@google.com0342a852012-08-20 19:22:38 +0000488 GrPixelConfig config, void* buffer,
489 size_t rowBytes = 0,
490 uint32_t pixelOpsFlags = 0);
bsalomon@google.com6f379512011-11-16 20:36:03 +0000491
492 /**
bsalomon@google.com0342a852012-08-20 19:22:38 +0000493 * Copy the src pixels [buffer, rowbytes, pixelconfig] into a render target at the specified
494 * rectangle.
495 * @param target the render target to write into. NULL means the current render target.
bsalomon@google.com6f379512011-11-16 20:36:03 +0000496 * @param left left edge of the rectangle to write (inclusive)
497 * @param top top edge of the rectangle to write (inclusive)
498 * @param width width of rectangle to write in pixels.
499 * @param height height of rectangle to write in pixels.
500 * @param config the pixel config of the source buffer
501 * @param buffer memory to read the rectangle from.
bsalomon@google.com0342a852012-08-20 19:22:38 +0000502 * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly
503 * packed.
504 * @param pixelOpsFlags see PixelOpsFlags enum above.
bsalomon@google.com6f379512011-11-16 20:36:03 +0000505 */
506 void writeRenderTargetPixels(GrRenderTarget* target,
507 int left, int top, int width, int height,
508 GrPixelConfig config, const void* buffer,
bsalomon@google.com0342a852012-08-20 19:22:38 +0000509 size_t rowBytes = 0,
510 uint32_t pixelOpsFlags = 0);
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000511
512 /**
513 * Reads a rectangle of pixels from a texture.
bsalomon@google.com6f379512011-11-16 20:36:03 +0000514 * @param texture the texture to read from.
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000515 * @param left left edge of the rectangle to read (inclusive)
516 * @param top top edge of the rectangle to read (inclusive)
517 * @param width width of rectangle to read in pixels.
518 * @param height height of rectangle to read in pixels.
519 * @param config the pixel config of the destination buffer
520 * @param buffer memory to read the rectangle into.
bsalomon@google.com0342a852012-08-20 19:22:38 +0000521 * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly
522 * packed.
523 * @param pixelOpsFlags see PixelOpsFlags enum above.
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000524 *
bsalomon@google.com0342a852012-08-20 19:22:38 +0000525 * @return true if the read succeeded, false if not. The read can fail because of an unsupported
526 * pixel config.
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000527 */
bsalomon@google.com6f379512011-11-16 20:36:03 +0000528 bool readTexturePixels(GrTexture* texture,
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000529 int left, int top, int width, int height,
bsalomon@google.com6f379512011-11-16 20:36:03 +0000530 GrPixelConfig config, void* buffer,
bsalomon@google.com0342a852012-08-20 19:22:38 +0000531 size_t rowBytes = 0,
532 uint32_t pixelOpsFlags = 0);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000533
534 /**
bsalomon@google.com6f379512011-11-16 20:36:03 +0000535 * Writes a rectangle of pixels to a texture.
536 * @param texture the render target to read from.
537 * @param left left edge of the rectangle to write (inclusive)
538 * @param top top edge of the rectangle to write (inclusive)
539 * @param width width of rectangle to write in pixels.
540 * @param height height of rectangle to write in pixels.
541 * @param config the pixel config of the source buffer
542 * @param buffer memory to read pixels from
543 * @param rowBytes number of bytes bewtween consecutive rows. Zero
544 * means rows are tightly packed.
bsalomon@google.com0342a852012-08-20 19:22:38 +0000545 * @param pixelOpsFlags see PixelOpsFlags enum above.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000546 */
bsalomon@google.com6f379512011-11-16 20:36:03 +0000547 void writeTexturePixels(GrTexture* texture,
548 int left, int top, int width, int height,
549 GrPixelConfig config, const void* buffer,
bsalomon@google.com0342a852012-08-20 19:22:38 +0000550 size_t rowBytes,
551 uint32_t pixelOpsFlags = 0);
552
553
senorblanco@chromium.org027de5f2011-07-08 18:03:33 +0000554 /**
senorblanco@chromium.orgef843cd2011-12-02 19:11:17 +0000555 * Copies all texels from one texture to another.
556 * @param src the texture to copy from.
557 * @param dst the render target to copy to.
558 */
559 void copyTexture(GrTexture* src, GrRenderTarget* dst);
bsalomon@google.com75f9f252012-01-31 13:35:56 +0000560
561 /**
562 * Resolves a render target that has MSAA. The intermediate MSAA buffer is
563 * downsampled to the associated GrTexture (accessible via
564 * GrRenderTarget::asTexture()). Any pending draws to the render target will
565 * be executed before the resolve.
566 *
567 * This is only necessary when a client wants to access the object directly
568 * using the underlying graphics API. GrContext will detect when it must
569 * perform a resolve to a GrTexture used as the source of a draw or before
570 * reading pixels back from a GrTexture or GrRenderTarget.
571 */
572 void resolveRenderTarget(GrRenderTarget* target);
573
senorblanco@chromium.orgef843cd2011-12-02 19:11:17 +0000574 /**
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000575 * Applies a 2D Gaussian blur to a given texture.
576 * @param srcTexture The source texture to be blurred.
senorblanco@chromium.org1e95d712012-07-18 19:52:53 +0000577 * @param canClobberSrc If true, srcTexture may be overwritten, and
578 * may be returned as the result.
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000579 * @param rect The destination rectangle.
580 * @param sigmaX The blur's standard deviation in X.
581 * @param sigmaY The blur's standard deviation in Y.
senorblanco@chromium.org1e95d712012-07-18 19:52:53 +0000582 * @return the blurred texture, which may be srcTexture ref'ed, or a
583 * new texture. It is the caller's responsibility to unref this texture.
senorblanco@chromium.org027de5f2011-07-08 18:03:33 +0000584 */
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000585 GrTexture* gaussianBlur(GrTexture* srcTexture,
senorblanco@chromium.org1e95d712012-07-18 19:52:53 +0000586 bool canClobberSrc,
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000587 const SkRect& rect,
588 float sigmaX, float sigmaY);
589
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000590 /**
bsalomon@google.com82aa7482012-08-13 14:22:17 +0000591 * Zooms a subset of the texture to a larger size with a nice edge.
592 * The inner rectangle is a simple scaling of the texture by a factor of
593 * |zoom|. The outer |inset| pixels transition from the background texture
594 * to the zoomed coordinate system at a rate of
595 * (distance_to_edge / inset) ^2, producing a rounded lens effect.
596 * @param srcTexture The source texture to be zoomed.
597 * @param dstRect The destination rectangle.
598 * @param srcRect The source rectangle. Must be smaller than
599 * dstRect
600 * @param inset Number of pixels to blend along the edges.
601 * @return the zoomed texture, which is dstTexture.
602 */
603 GrTexture* zoom(GrTexture* srcTexture,
604 const SkRect& dstRect, const SkRect& srcRect, float inset);
605
606
607 /**
bsalomon@google.comb505a122012-05-31 18:40:36 +0000608 * This enum is used with the function below, applyMorphology.
609 */
610 enum MorphologyType {
611 kErode_MorphologyType,
612 kDilate_MorphologyType,
613 };
614
615 /**
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000616 * Applies a 2D morphology to a given texture.
617 * @param srcTexture The source texture to be blurred.
618 * @param rect The destination rectangle.
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000619 * @param filter The morphology filter. Must be kDilate_Filter or
620 * kErode_Filter.
621 * @param radius The morphology radius in X and Y. The filter is
622 * applied to a fWidth by fHeight rectangle of
623 * pixels.
senorblanco@chromium.org1e95d712012-07-18 19:52:53 +0000624 * @return the morphed texture, which may be srcTexture ref'ed, or a
625 * new texture. It is the caller's responsibility to unref this texture.
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000626 */
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000627 GrTexture* applyMorphology(GrTexture* srcTexture,
628 const GrRect& rect,
bsalomon@google.comb505a122012-05-31 18:40:36 +0000629 MorphologyType type,
senorblanco@chromium.org3b4dd902012-03-05 20:41:22 +0000630 SkISize radius);
631
bsalomon@google.com27847de2011-02-22 20:59:41 +0000632 ///////////////////////////////////////////////////////////////////////////
633 // Helpers
634
635 class AutoRenderTarget : ::GrNoncopyable {
636 public:
637 AutoRenderTarget(GrContext* context, GrRenderTarget* target) {
638 fContext = NULL;
639 fPrevTarget = context->getRenderTarget();
640 if (fPrevTarget != target) {
641 context->setRenderTarget(target);
642 fContext = context;
643 }
644 }
645 ~AutoRenderTarget() {
646 if (fContext) {
647 fContext->setRenderTarget(fPrevTarget);
648 }
649 }
650 private:
651 GrContext* fContext;
652 GrRenderTarget* fPrevTarget;
653 };
654
robertphillips@google.comfea85ac2012-07-11 18:53:23 +0000655 /**
656 * Save/restore the view-matrix in the context.
657 */
658 class AutoMatrix : GrNoncopyable {
659 public:
660 AutoMatrix() : fContext(NULL) {}
661 AutoMatrix(GrContext* ctx) : fContext(ctx) {
662 fMatrix = ctx->getMatrix();
663 }
664 AutoMatrix(GrContext* ctx, const GrMatrix& matrix) : fContext(ctx) {
665 fMatrix = ctx->getMatrix();
666 ctx->setMatrix(matrix);
667 }
668 void set(GrContext* ctx) {
669 if (NULL != fContext) {
670 fContext->setMatrix(fMatrix);
671 }
672 fMatrix = ctx->getMatrix();
673 fContext = ctx;
674 }
675 void set(GrContext* ctx, const GrMatrix& matrix) {
676 if (NULL != fContext) {
677 fContext->setMatrix(fMatrix);
678 }
679 fMatrix = ctx->getMatrix();
680 ctx->setMatrix(matrix);
681 fContext = ctx;
682 }
683 ~AutoMatrix() {
684 if (NULL != fContext) {
685 fContext->setMatrix(fMatrix);
686 }
687 }
688
689 private:
690 GrContext* fContext;
691 GrMatrix fMatrix;
692 };
bsalomon@google.com27847de2011-02-22 20:59:41 +0000693
robertphillips@google.com56c79b12012-07-11 20:57:46 +0000694 class AutoClip : GrNoncopyable {
695 public:
696 AutoClip(GrContext* context, const GrRect& newClipRect)
697 : fContext(context)
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000698 , fNewClipStack(newClipRect) {
699 fNewClipData.fClipStack = &fNewClipStack;
700
robertphillips@google.com56c79b12012-07-11 20:57:46 +0000701 fOldClip = fContext->getClip();
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000702 fContext->setClip(&fNewClipData);
robertphillips@google.com56c79b12012-07-11 20:57:46 +0000703 }
704
705 ~AutoClip() {
706 if (NULL != fContext) {
707 fContext->setClip(fOldClip);
708 }
709 }
710 private:
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000711 GrContext* fContext;
712 const GrClipData* fOldClip;
713
robertphillips@google.com641f8b12012-07-31 19:15:58 +0000714 SkClipStack fNewClipStack;
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000715 GrClipData fNewClipData;
robertphillips@google.com56c79b12012-07-11 20:57:46 +0000716 };
717
bsalomon@google.com27847de2011-02-22 20:59:41 +0000718 ///////////////////////////////////////////////////////////////////////////
719 // Functions intended for internal use only.
720 GrGpu* getGpu() { return fGpu; }
bsalomon@google.com1f221a72011-08-23 20:54:07 +0000721 const GrGpu* getGpu() const { return fGpu; }
bsalomon@google.com27847de2011-02-22 20:59:41 +0000722 GrFontCache* getFontCache() { return fFontCache; }
723 GrDrawTarget* getTextTarget(const GrPaint& paint);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000724 const GrIndexBuffer* getQuadIndexBuffer() const;
bsalomon@google.com9923c2b2012-06-06 18:21:18 +0000725
bsalomon@google.com558a75b2011-08-08 17:01:14 +0000726 /**
727 * Stencil buffers add themselves to the cache using
728 * addAndLockStencilBuffer. When a SB's RT-attachment count
729 * reaches zero the SB unlocks itself using unlockStencilBuffer and is
730 * eligible for purging. findStencilBuffer is called to check the cache for
731 * a SB that matching an RT's criteria. If a match is found that has been
732 * unlocked (its attachment count has reached 0) then it will be relocked.
733 */
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000734 void addAndLockStencilBuffer(GrStencilBuffer* sb);
735 void unlockStencilBuffer(GrStencilBuffer* sb);
bsalomon@google.com558a75b2011-08-08 17:01:14 +0000736 GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000737
robertphillips@google.com2c756812012-05-22 20:28:23 +0000738 GrPathRenderer* getPathRenderer(const SkPath& path,
739 GrPathFill fill,
740 const GrDrawTarget* target,
robertphillips@google.com72176b22012-05-23 13:19:12 +0000741 bool antiAlias,
742 bool allowSW);
robertphillips@google.com2c756812012-05-22 20:28:23 +0000743
robertphillips@google.com5f9f2f52012-08-22 10:57:05 +0000744#ifdef GR_DEBUG
745 void printCacheStats() const;
746#endif
747
bsalomon@google.com27847de2011-02-22 20:59:41 +0000748private:
bsalomon@google.com1d4edd32012-08-16 18:36:06 +0000749 // Used to indicate whether a draw should be performed immediately or queued in fDrawBuffer.
750 enum BufferedDraw {
751 kYes_BufferedDraw,
752 kNo_BufferedDraw,
bsalomon@google.com27847de2011-02-22 20:59:41 +0000753 };
bsalomon@google.com1d4edd32012-08-16 18:36:06 +0000754 BufferedDraw fLastDrawWasBuffered;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000755
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000756 GrGpu* fGpu;
bsalomon@google.com10e04bf2012-03-30 14:35:04 +0000757 GrDrawState* fDrawState;
758
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000759 GrResourceCache* fTextureCache;
760 GrFontCache* fFontCache;
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000761
bsalomon@google.com30085192011-08-19 15:42:31 +0000762 GrPathRendererChain* fPathRendererChain;
robertphillips@google.com72176b22012-05-23 13:19:12 +0000763 GrSoftwarePathRenderer* fSoftwarePathRenderer;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000764
765 GrVertexBufferAllocPool* fDrawBufferVBAllocPool;
766 GrIndexBufferAllocPool* fDrawBufferIBAllocPool;
767 GrInOrderDrawBuffer* fDrawBuffer;
768
robertphillips@google.comf69a11b2012-06-15 13:58:07 +0000769 GrAARectRenderer* fAARectRenderer;
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000770
robertphillips@google.comf69a11b2012-06-15 13:58:07 +0000771 GrContext(GrGpu* gpu);
bsalomon@google.com205d4602011-04-25 12:43:45 +0000772
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000773 void setupDrawBuffer();
774
bsalomon@google.com27847de2011-02-22 20:59:41 +0000775 void flushDrawBuffer();
776
bsalomon@google.com10e04bf2012-03-30 14:35:04 +0000777 void setPaint(const GrPaint& paint);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000778
bsalomon@google.com07ea2db2012-08-17 14:06:49 +0000779 /// Sets the paint and returns the target to draw into. The paint can be NULL in which case the
780 /// draw state is left unmodified.
781 GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000782
bsalomon@google.com8d033a12012-04-27 15:52:53 +0000783 void internalDrawPath(const GrPaint& paint, const SkPath& path,
bsalomon@google.com93c96602012-04-27 13:05:21 +0000784 GrPathFill fill, const GrPoint* translate);
785
robertphillips@google.com3319f332012-08-13 18:00:36 +0000786 GrTexture* createResizedTexture(const GrTextureDesc& desc,
787 const GrCacheData& cacheData,
788 void* srcData,
789 size_t rowBytes,
790 bool needsFiltering);
791
robertphillips@google.com15c0fea2012-06-22 12:41:43 +0000792 // Needed so GrTexture's returnToCache helper function can call
793 // addExistingTextureToCache
794 friend class GrTexture;
795
796 // Add an existing texture to the texture cache. This is intended solely
797 // for use with textures released from an GrAutoScratchTexture.
798 void addExistingTextureToCache(GrTexture* texture);
reed@google.comfa35e3d2012-06-26 20:16:17 +0000799
800 typedef GrRefCnt INHERITED;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000801};
802
803/**
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000804 * Gets and locks a scratch texture from a descriptor using
805 * either exact or approximate criteria. Unlocks texture in
806 * the destructor.
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000807 */
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000808class GrAutoScratchTexture : ::GrNoncopyable {
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000809public:
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000810 GrAutoScratchTexture()
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000811 : fContext(NULL)
812 , fTexture(NULL) {
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000813 }
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000814
815 GrAutoScratchTexture(GrContext* context,
816 const GrTextureDesc& desc,
817 GrContext::ScratchTexMatch match =
818 GrContext::kApprox_ScratchTexMatch)
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000819 : fContext(NULL)
820 , fTexture(NULL) {
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000821 this->set(context, desc, match);
822 }
823
824 ~GrAutoScratchTexture() {
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000825 this->reset();
826 }
827
828 void reset() {
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000829 if (NULL != fContext && NULL != fTexture) {
830 fContext->unlockTexture(fTexture);
831 fTexture = NULL;
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000832 }
833 }
bsalomon@google.com84223112011-07-14 14:45:44 +0000834
robertphillips@google.com15c0fea2012-06-22 12:41:43 +0000835 /*
836 * When detaching a texture we do not unlock it in the texture cache but
837 * we do set the returnToCache flag. In this way the texture remains
838 * "locked" in the texture cache until it is freed and recycled in
839 * GrTexture::internal_dispose. In reality, the texture has been removed
840 * from the cache (because this is in AutoScratchTexture) and by not
841 * calling unlockTexture we simply don't re-add it. It will be reattached
842 * in GrTexture::internal_dispose.
843 *
844 * Note that the caller is assumed to accept and manage the ref to the
845 * returned texture.
846 */
847 GrTexture* detach() {
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000848 GrTexture* temp = fTexture;
robertphillips@google.com15c0fea2012-06-22 12:41:43 +0000849
robertphillips@google.com521eaf82012-08-22 11:03:19 +0000850 // Conceptually the texture's cache entry loses its ref to the
851 // texture while the caller of this method gets a ref.
852 GrAssert(NULL != temp->getCacheEntry());
853
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000854 fTexture = NULL;
robertphillips@google.com15c0fea2012-06-22 12:41:43 +0000855
856 temp->setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit);
robertphillips@google.com15c0fea2012-06-22 12:41:43 +0000857 return temp;
858 }
859
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000860 GrTexture* set(GrContext* context,
861 const GrTextureDesc& desc,
862 GrContext::ScratchTexMatch match =
863 GrContext::kApprox_ScratchTexMatch) {
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000864 this->reset();
865
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000866 fContext = context;
867 if (NULL != fContext) {
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000868 fTexture = fContext->lockScratchTexture(desc, match);
869 if (NULL == fTexture) {
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000870 fContext = NULL;
871 }
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000872 return fTexture;
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000873 } else {
874 return NULL;
875 }
876 }
877
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000878 GrTexture* texture() { return fTexture; }
879
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000880private:
bsalomon@google.com50398bf2011-07-26 20:45:30 +0000881 GrContext* fContext;
robertphillips@google.com1f47f4f2012-08-16 14:49:16 +0000882 GrTexture* fTexture;
senorblanco@chromium.orgaadd9f82011-07-12 19:44:51 +0000883};
884
bsalomon@google.com27847de2011-02-22 20:59:41 +0000885#endif