bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 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. |
| 7 | */ |
| 8 | #ifndef SkMesaGLContext_DEFINED |
| 9 | #define SkMesaGLContext_DEFINED |
| 10 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 11 | #include "SkGLContextHelper.h" |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 12 | |
| 13 | #if SK_MESA |
| 14 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 15 | class SkMesaGLContext : public SkGLContextHelper { |
bsalomon@google.com | 57f5d98 | 2011-10-24 21:17:53 +0000 | [diff] [blame] | 16 | private: |
| 17 | typedef intptr_t Context; |
| 18 | |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 19 | public: |
| 20 | SkMesaGLContext(); |
| 21 | |
| 22 | virtual ~SkMesaGLContext(); |
| 23 | |
| 24 | virtual void makeCurrent() const SK_OVERRIDE; |
| 25 | |
bsalomon@google.com | 57f5d98 | 2011-10-24 21:17:53 +0000 | [diff] [blame] | 26 | class AutoContextRestore { |
| 27 | public: |
| 28 | AutoContextRestore(); |
| 29 | ~AutoContextRestore(); |
| 30 | |
| 31 | private: |
| 32 | Context fOldContext; |
bsalomon@google.com | b3400ba | 2012-04-19 19:27:19 +0000 | [diff] [blame] | 33 | GrGLint fOldWidth; |
| 34 | GrGLint fOldHeight; |
| 35 | GrGLint fOldFormat; |
bsalomon@google.com | 57f5d98 | 2011-10-24 21:17:53 +0000 | [diff] [blame] | 36 | void* fOldImage; |
| 37 | }; |
| 38 | |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 39 | protected: |
| 40 | virtual const GrGLInterface* createGLContext() SK_OVERRIDE; |
bsalomon@google.com | 7491372 | 2011-10-27 20:44:19 +0000 | [diff] [blame] | 41 | virtual void destroyGLContext() SK_OVERRIDE; |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 42 | |
| 43 | private: |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 44 | Context fContext; |
| 45 | GrGLubyte *fImage; |
| 46 | }; |
| 47 | |
| 48 | #endif |
| 49 | |
bsalomon@google.com | 57f5d98 | 2011-10-24 21:17:53 +0000 | [diff] [blame] | 50 | #endif |