blob: 5eda2b71867653a9ad445d7f58f35a0d223898ec [file] [log] [blame]
bsalomon@google.com27847de2011-02-22 20:59:41 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17#ifndef GrContext_DEFINED
18#define GrContext_DEFINED
19
20#include "GrClip.h"
21#include "GrGpu.h"
22#include "GrTextureCache.h"
23#include "GrPaint.h"
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +000024#include "GrPathRenderer.h"
bsalomon@google.com27847de2011-02-22 20:59:41 +000025
26class GrFontCache;
27class GrPathIter;
28class GrVertexBufferAllocPool;
29class GrIndexBufferAllocPool;
30class GrInOrderDrawBuffer;
bsalomon@google.com27847de2011-02-22 20:59:41 +000031
bsalomon@google.com91826102011-03-21 19:51:57 +000032class GR_API GrContext : public GrRefCnt {
bsalomon@google.com27847de2011-02-22 20:59:41 +000033public:
34 /**
35 * Creates a GrContext from within a 3D context.
36 */
37 static GrContext* Create(GrGpu::Engine engine,
38 GrGpu::Platform3DContext context3D);
39
40 /**
41 * Helper to create a opengl-shader based context
42 */
43 static GrContext* CreateGLShaderContext();
44
45 virtual ~GrContext();
46
47 /**
48 * The GrContext normally assumes that no outsider is setting state
49 * within the underlying 3D API's context/device/whatever. This call informs
50 * the context that the state was modified and it should resend. Shouldn't
51 * be called frequently for good performance.
52 */
53 void resetContext();
54
bsalomon@google.com8fe72472011-03-30 21:26:44 +000055 /**
56 * Abandons all gpu resources, assumes 3D API state is unknown. Call this
57 * if you have lost the associated GPU context, and thus internal texture,
58 * buffer, etc. references/IDs are now invalid. Should be called even when
59 * GrContext is no longer going to be used for two reasons:
60 * 1) ~GrContext will not try to free the objects in the 3D API.
61 * 2) If you've created GrResources that outlive the GrContext they will
62 * be marked as invalid (GrResource::isValid()) and won't attempt to
63 * free their underlying resource in the 3D API.
64 * Content drawn since the last GrContext::flush() may be lost.
65 */
66 void contextLost();
bsalomon@google.com27847de2011-02-22 20:59:41 +000067
68 /**
bsalomon@google.com8fe72472011-03-30 21:26:44 +000069 * Frees gpu created by the context. Can be called to reduce GPU memory
70 * pressure.
bsalomon@google.com27847de2011-02-22 20:59:41 +000071 */
bsalomon@google.com8fe72472011-03-30 21:26:44 +000072 void freeGpuResources();
73
74 ///////////////////////////////////////////////////////////////////////////
75 // Textures
bsalomon@google.com27847de2011-02-22 20:59:41 +000076
77 /**
78 * Search for an entry with the same Key. If found, "lock" it and return it.
79 * If not found, return null.
80 */
81 GrTextureEntry* findAndLockTexture(GrTextureKey*,
82 const GrSamplerState&);
83
84
85 /**
86 * Create a new entry, based on the specified key and texture, and return
87 * its "locked" entry.
88 *
89 * Ownership of the texture is transferred to the Entry, which will unref()
90 * it when we are purged or deleted.
91 */
92 GrTextureEntry* createAndLockTexture(GrTextureKey* key,
93 const GrSamplerState&,
94 const GrGpu::TextureDesc&,
95 void* srcData, size_t rowBytes);
96
97 /**
98 * When done with an entry, call unlockTexture(entry) on it, which returns
99 * it to the cache, where it may be purged.
100 */
101 void unlockTexture(GrTextureEntry* entry);
102
103 /**
104 * Removes an texture from the cache. This prevents the texture from
105 * being found by a subsequent findAndLockTexture() until it is
106 * reattached. The entry still counts against the cache's budget and should
107 * be reattached when exclusive access is no longer needed.
108 */
109 void detachCachedTexture(GrTextureEntry*);
110
111 /**
112 * Reattaches a texture to the cache and unlocks it. Allows it to be found
113 * by a subsequent findAndLock or be purged (provided its lock count is
114 * now 0.)
115 */
116 void reattachAndUnlockCachedTexture(GrTextureEntry*);
117
118 /**
119 * Creates a texture that is outside the cache. Does not count against
120 * cache's budget.
121 */
122 GrTexture* createUncachedTexture(const GrGpu::TextureDesc&,
123 void* srcData,
124 size_t rowBytes);
125
126 /**
127 * Returns true if the specified use of an indexed texture is supported.
128 */
129 bool supportsIndex8PixelConfig(const GrSamplerState&, int width, int height);
130
131 /**
132 * Return the current texture cache limits.
133 *
134 * @param maxTextures If non-null, returns maximum number of textures that
135 * can be held in the cache.
136 * @param maxTextureBytes If non-null, returns maximum number of bytes of
137 * texture memory that can be held in the cache.
138 */
139 void getTextureCacheLimits(int* maxTextures, size_t* maxTextureBytes) const;
140
141 /**
142 * Specify the texture cache limits. If the current cache exceeds either
143 * of these, it will be purged (LRU) to keep the cache within these limits.
144 *
145 * @param maxTextures The maximum number of textures that can be held in
146 * the cache.
147 * @param maxTextureBytes The maximum number of bytes of texture memory
148 * that can be held in the cache.
149 */
150 void setTextureCacheLimits(int maxTextures, size_t maxTextureBytes);
151
152 /**
153 * Return the max width or height of a texture supported by the current gpu
154 */
155 int getMaxTextureDimension();
156
157 ///////////////////////////////////////////////////////////////////////////
158 // Render targets
159
160 /**
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000161 * Sets the render target.
162 * @param target the render target to set. (should not be NULL.)
163 */
164 void setRenderTarget(GrRenderTarget* target);
165
166 /**
167 * Gets the current render target.
168 * @return the currently bound render target. Should never be NULL.
169 */
170 const GrRenderTarget* getRenderTarget() const;
171 GrRenderTarget* getRenderTarget();
172
173 ///////////////////////////////////////////////////////////////////////////
174 // Platform Surfaces
175
176 // GrContext provides an interface for wrapping externally created textures
177 // and rendertargets in their Gr-equivalents.
178
179 /**
180 * Wraps an existing 3D API surface in a GrObject. desc.fFlags determines
181 * the type of object returned. If kIsTexture is set the returned object
182 * will be a GrTexture*. Otherwise, it will be a GrRenderTarget*. If both
183 * are set the render target object is accessible by
184 * GrTexture::asRenderTarget().
185 *
186 * GL: if the object is a texture Gr may change its GL texture parameters
187 * when it is drawn.
188 *
189 * @param desc description of the object to create.
190 * @return either a GrTexture* or GrRenderTarget* depending on desc. NULL
191 * on failure.
192 */
193 GrResource* createPlatformSurface(const GrPlatformSurfaceDesc& desc);
194
195 /**
196 * DEPRECATED, WILL BE REMOVED SOON. USE createPlatformSurface.
197 *
bsalomon@google.com27847de2011-02-22 20:59:41 +0000198 * Wraps an externally-created rendertarget in a GrRenderTarget.
199 * @param platformRenderTarget 3D API-specific render target identifier
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000200 * e.g. in GL platforamRenderTarget is an FBO
bsalomon@google.com27847de2011-02-22 20:59:41 +0000201 * id.
202 * @param stencilBits the number of stencil bits that the render
203 * target has.
bsalomon@google.comf954d8d2011-04-06 17:50:02 +0000204 * @param isMultisampled specify whether the render target is
205 * multisampled.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000206 * @param width width of the render target.
207 * @param height height of the render target.
208 */
209 GrRenderTarget* createPlatformRenderTarget(intptr_t platformRenderTarget,
210 int stencilBits,
bsalomon@google.comf954d8d2011-04-06 17:50:02 +0000211 bool isMultisampled,
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000212 int width, int height) {
213 #if GR_DEBUG
214 GrPrintf("Using deprecated createPlatformRenderTarget API.");
215 #endif
216 return fGpu->createPlatformRenderTarget(platformRenderTarget,
217 stencilBits, isMultisampled,
218 width, height);
219 }
bsalomon@google.com27847de2011-02-22 20:59:41 +0000220
221 /**
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000222 * DEPRECATED, WILL BE REMOVED SOON. USE createPlatformSurface.
223 *
bsalomon@google.com27847de2011-02-22 20:59:41 +0000224 * Reads the current target object (e.g. FBO or IDirect3DSurface9*) and
225 * viewport state from the underlying 3D API and wraps it in a
226 * GrRenderTarget. The GrRenderTarget will not attempt to delete/destroy the
227 * underlying object in its destructor and it is up to caller to guarantee
228 * that it remains valid while the GrRenderTarget is used.
229 *
230 * @return the newly created GrRenderTarget
231 */
232 GrRenderTarget* createRenderTargetFrom3DApiState() {
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000233 #if GR_DEBUG
234 GrPrintf("Using deprecated createRenderTargetFrom3DApiState API.");
235 #endif
bsalomon@google.com27847de2011-02-22 20:59:41 +0000236 return fGpu->createRenderTargetFrom3DApiState();
237 }
238
bsalomon@google.com27847de2011-02-22 20:59:41 +0000239 ///////////////////////////////////////////////////////////////////////////
240 // Matrix state
241
242 /**
243 * Gets the current transformation matrix.
244 * @return the current matrix.
245 */
246 const GrMatrix& getMatrix() const;
247
248 /**
249 * Sets the transformation matrix.
250 * @param m the matrix to set.
251 */
252 void setMatrix(const GrMatrix& m);
253
254 /**
255 * Concats the current matrix. The passed matrix is applied before the
256 * current matrix.
257 * @param m the matrix to concat.
258 */
259 void concatMatrix(const GrMatrix& m) const;
260
261
262 ///////////////////////////////////////////////////////////////////////////
263 // Clip state
264 /**
265 * Gets the current clip.
266 * @return the current clip.
267 */
268 const GrClip& getClip() const { return fGpu->getClip(); }
269
270 /**
271 * Sets the clip.
272 * @param clip the clip to set.
273 */
274 void setClip(const GrClip& clip);
275
276 /**
277 * Convenience method for setting the clip to a rect.
278 * @param rect the rect to set as the new clip.
279 */
280 void setClip(const GrIRect& rect);
281
282 ///////////////////////////////////////////////////////////////////////////
283 // Draws
284
285 /**
bsalomon@google.com398109c2011-04-14 18:40:27 +0000286 * Clear the entire render target, ignoring any clips
bsalomon@google.com27847de2011-02-22 20:59:41 +0000287 */
bsalomon@google.com398109c2011-04-14 18:40:27 +0000288 void clear(GrColor color);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000289
290 /**
291 * Draw everywhere (respecting the clip) with the paint.
292 */
293 void drawPaint(const GrPaint& paint);
294
295 /**
296 * Draw the rect using a paint.
297 * @param paint describes how to color pixels.
298 * @param strokeWidth If strokeWidth < 0, then the rect is filled, else
299 * the rect is mitered stroked based on strokeWidth. If
300 * strokeWidth == 0, then the stroke is always a single
301 * pixel thick.
302 * @param matrix Optional matrix applied to the rect. Applied before
303 * context's matrix or the paint's matrix.
304 * The rects coords are used to access the paint (through texture matrix)
305 */
306 void drawRect(const GrPaint& paint,
307 const GrRect&,
308 GrScalar strokeWidth = -1,
309 const GrMatrix* matrix = NULL);
310
311 /**
312 * Maps a rect of paint coordinates onto the a rect of destination
313 * coordinates. Each rect can optionally be transformed. The srcRect
314 * is stretched over the dstRect. The dstRect is transformed by the
315 * context's matrix and the srcRect is transformed by the paint's matrix.
316 * Additional optional matrices can be provided by parameters.
317 *
318 * @param paint describes how to color pixels.
319 * @param dstRect the destination rect to draw.
320 * @param srcRect rect of paint coordinates to be mapped onto dstRect
321 * @param dstMatrix Optional matrix to transform dstRect. Applied before
322 * context's matrix.
323 * @param srcMatrix Optional matrix to transform srcRect Applied before
324 * paint's matrix.
325 */
326 void drawRectToRect(const GrPaint& paint,
327 const GrRect& dstRect,
328 const GrRect& srcRect,
329 const GrMatrix* dstMatrix = NULL,
330 const GrMatrix* srcMatrix = NULL);
331
332 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +0000333 * Draws a path.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000334 *
335 * @param paint describes how to color pixels.
bsalomon@google.comd302f142011-03-03 13:54:13 +0000336 * @param pathIter the path to draw
bsalomon@google.com27847de2011-02-22 20:59:41 +0000337 * @param fill the path filling rule to use.
338 * @param translate optional additional translation applied to the
339 * path.
340 */
341 void drawPath(const GrPaint& paint,
bsalomon@google.comd302f142011-03-03 13:54:13 +0000342 GrPathIter* pathIter,
343 GrPathFill fill,
344 const GrPoint* translate = NULL);
345 /**
346 * Helper version of drawPath that takes a GrPath
347 */
348 void drawPath(const GrPaint& paint,
349 const GrPath& path,
bsalomon@google.com27847de2011-02-22 20:59:41 +0000350 GrPathFill fill,
351 const GrPoint* translate = NULL);
352 /**
353 * Draws vertices with a paint.
354 *
355 * @param paint describes how to color pixels.
356 * @param primitiveType primitives type to draw.
357 * @param vertexCount number of vertices.
358 * @param positions array of vertex positions, required.
359 * @param texCoords optional array of texture coordinates used
360 * to access the paint.
361 * @param colors optional array of per-vertex colors, supercedes
362 * the paint's color field.
363 * @param indices optional array of indices. If NULL vertices
364 * are drawn non-indexed.
365 * @param indexCount if indices is non-null then this is the
366 * number of indices.
367 */
368 void drawVertices(const GrPaint& paint,
369 GrPrimitiveType primitiveType,
370 int vertexCount,
371 const GrPoint positions[],
372 const GrPoint texs[],
373 const GrColor colors[],
374 const uint16_t indices[],
375 int indexCount);
376
377 /**
378 * Similar to drawVertices but caller provides objects that convert to Gr
379 * types. The count of vertices is given by posSrc.
380 *
381 * @param paint describes how to color pixels.
382 * @param primitiveType primitives type to draw.
383 * @param posSrc Source of vertex positions. Must implement
384 * int count() const;
385 * void writeValue(int i, GrPoint* point) const;
386 * count returns the total number of vertices and
387 * writeValue writes a vertex position to point.
388 * @param texSrc optional, pass NULL to not use explicit tex
389 * coords. If present provides tex coords with
390 * method:
391 * void writeValue(int i, GrPoint* point) const;
392 * @param texSrc optional, pass NULL to not use per-vertex colors
393 * If present provides colors with method:
394 * void writeValue(int i, GrColor* point) const;
395 * @param indices optional, pass NULL for non-indexed drawing. If
396 * present supplies indices for indexed drawing
397 * with following methods:
398 * int count() const;
399 * void writeValue(int i, uint16_t* point) const;
400 * count returns the number of indices and
401 * writeValue supplies each index.
402 */
403 template <typename POS_SRC,
404 typename TEX_SRC,
405 typename COL_SRC,
406 typename IDX_SRC>
407 void drawCustomVertices(const GrPaint& paint,
408 GrPrimitiveType primitiveType,
409 const POS_SRC& posSrc,
410 const TEX_SRC* texCoordSrc,
411 const COL_SRC* colorSrc,
412 const IDX_SRC* idxSrc);
413 /**
414 * To avoid the problem of having to create a typename for NULL parameters,
415 * these reduced versions of drawCustomVertices are provided.
416 */
417 template <typename POS_SRC>
418 void drawCustomVertices(const GrPaint& paint,
419 GrPrimitiveType primitiveType,
420 const POS_SRC& posSrc);
421 template <typename POS_SRC, typename TEX_SRC>
422 void drawCustomVertices(const GrPaint& paint,
423 GrPrimitiveType primitiveType,
424 const POS_SRC& posSrc,
425 const TEX_SRC* texCoordSrc);
426 template <typename POS_SRC, typename TEX_SRC, typename COL_SRC>
427 void drawCustomVertices(const GrPaint& paint,
428 GrPrimitiveType primitiveType,
429 const POS_SRC& posSrc,
430 const TEX_SRC* texCoordSrc,
431 const COL_SRC* colorSrc);
432
433
434 ///////////////////////////////////////////////////////////////////////////
435 // Misc.
436
437 /**
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000438 * Flags that affect flush() behavior.
439 */
440 enum FlushBits {
441 /**
442 * A client may want Gr to bind a GrRenderTarget in the 3D API so that
443 * it can be rendered to directly. However, Gr lazily sets state. Simply
444 * calling setRenderTarget() followed by flush() without flags may not
445 * bind the render target. This flag forces the context to bind the last
446 * set render target in the 3D API.
447 */
448 kForceCurrentRenderTarget_FlushBit = 0x1,
449 /**
450 * A client may reach a point where it has partially rendered a frame
451 * through a GrContext that it knows the user will never see. This flag
452 * causes the flush to skip submission of deferred content to the 3D API
453 * during the flush.
454 */
455 kDiscard_FlushBit = 0x2,
456 };
457
458 /**
bsalomon@google.com27847de2011-02-22 20:59:41 +0000459 * Call to ensure all drawing to the context has been issued to the
460 * underlying 3D API.
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000461 * @param flagsBitfield flags that control the flushing behavior. See
462 * FlushBits.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000463 */
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000464 void flush(int flagsBitfield = 0);
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000465
bsalomon@google.com27847de2011-02-22 20:59:41 +0000466 /**
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000467 * Reads a rectangle of pixels from a render target.
468 * @param renderTarget the render target to read from. NULL means the
469 * current render target.
470 * @param left left edge of the rectangle to read (inclusive)
471 * @param top top edge of the rectangle to read (inclusive)
472 * @param width width of rectangle to read in pixels.
473 * @param height height of rectangle to read in pixels.
474 * @param config the pixel config of the destination buffer
475 * @param buffer memory to read the rectangle into.
476 *
477 * @return true if the read succeeded, false if not. The read can fail
478 * because of a unsupported pixel config or because no render
479 * target is currently set.
bsalomon@google.com27847de2011-02-22 20:59:41 +0000480 */
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000481 bool readRenderTargetPixels(GrRenderTarget* target,
482 int left, int top, int width, int height,
483 GrPixelConfig config, void* buffer);
484
485 /**
486 * Reads a rectangle of pixels from a texture.
487 * @param texture the render target to read from.
488 * @param left left edge of the rectangle to read (inclusive)
489 * @param top top edge of the rectangle to read (inclusive)
490 * @param width width of rectangle to read in pixels.
491 * @param height height of rectangle to read in pixels.
492 * @param config the pixel config of the destination buffer
493 * @param buffer memory to read the rectangle into.
494 *
495 * @return true if the read succeeded, false if not. The read can fail
496 * because of a unsupported pixel config.
497 */
498 bool readTexturePixels(GrTexture* target,
499 int left, int top, int width, int height,
500 GrPixelConfig config, void* buffer);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000501
502 /**
503 * Copy the src pixels [buffer, stride, pixelconfig] into the current
504 * render-target at the specified rectangle.
505 */
506 void writePixels(int left, int top, int width, int height,
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000507 GrPixelConfig, const void* buffer, size_t stride);
bsalomon@google.com27847de2011-02-22 20:59:41 +0000508
509
510 ///////////////////////////////////////////////////////////////////////////
511 // Statistics
512
513 void resetStats();
514
515 const GrGpu::Stats& getStats() const;
516
517 void printStats() const;
518
519 ///////////////////////////////////////////////////////////////////////////
520 // Helpers
521
522 class AutoRenderTarget : ::GrNoncopyable {
523 public:
524 AutoRenderTarget(GrContext* context, GrRenderTarget* target) {
525 fContext = NULL;
526 fPrevTarget = context->getRenderTarget();
527 if (fPrevTarget != target) {
528 context->setRenderTarget(target);
529 fContext = context;
530 }
531 }
532 ~AutoRenderTarget() {
533 if (fContext) {
534 fContext->setRenderTarget(fPrevTarget);
535 }
536 }
537 private:
538 GrContext* fContext;
539 GrRenderTarget* fPrevTarget;
540 };
541
542
543 ///////////////////////////////////////////////////////////////////////////
544 // Functions intended for internal use only.
545 GrGpu* getGpu() { return fGpu; }
546 GrFontCache* getFontCache() { return fFontCache; }
547 GrDrawTarget* getTextTarget(const GrPaint& paint);
548 void flushText();
549 const GrIndexBuffer* getQuadIndexBuffer() const;
550
551private:
552 // used to keep track of when we need to flush the draw buffer
553 enum DrawCategory {
554 kBuffered_DrawCategory, // last draw was inserted in draw buffer
555 kUnbuffered_DrawCategory, // last draw was not inserted in the draw buffer
556 kText_DrawCategory // text context was last to draw
557 };
558 DrawCategory fLastDrawCategory;
559
560 GrGpu* fGpu;
561 GrTextureCache* fTextureCache;
562 GrFontCache* fFontCache;
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000563
564 GrPathRenderer* fCustomPathRenderer;
565 GrDefaultPathRenderer fDefaultPathRenderer;
bsalomon@google.com27847de2011-02-22 20:59:41 +0000566
567 GrVertexBufferAllocPool* fDrawBufferVBAllocPool;
568 GrIndexBufferAllocPool* fDrawBufferIBAllocPool;
569 GrInOrderDrawBuffer* fDrawBuffer;
570
571 GrContext(GrGpu* gpu);
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000572
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000573 void setupDrawBuffer();
574
bsalomon@google.com27847de2011-02-22 20:59:41 +0000575 void flushDrawBuffer();
576
577 static void SetPaint(const GrPaint& paint, GrDrawTarget* target);
578
579 bool finalizeTextureKey(GrTextureKey*, const GrSamplerState&) const;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000580
bsalomon@google.com27847de2011-02-22 20:59:41 +0000581 GrDrawTarget* prepareToDraw(const GrPaint& paint, DrawCategory drawType);
582
583 void drawClipIntoStencil();
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000584
585 GrPathRenderer* getPathRenderer(const GrDrawTarget* target,
586 GrPathIter* path,
587 GrPathFill fill);
588
bsalomon@google.com27847de2011-02-22 20:59:41 +0000589};
590
591/**
592 * Save/restore the view-matrix in the context.
593 */
594class GrAutoMatrix : GrNoncopyable {
595public:
596 GrAutoMatrix(GrContext* ctx) : fContext(ctx) {
597 fMatrix = ctx->getMatrix();
598 }
599 GrAutoMatrix(GrContext* ctx, const GrMatrix& matrix) : fContext(ctx) {
600 fMatrix = ctx->getMatrix();
601 ctx->setMatrix(matrix);
602 }
603 ~GrAutoMatrix() {
604 fContext->setMatrix(fMatrix);
605 }
606
607private:
608 GrContext* fContext;
609 GrMatrix fMatrix;
610};
611
612#endif
613
614#include "GrContext_impl.h"