OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkGLContextHelper_DEFINED | 8 #ifndef SkGLContext_DEFINED |
9 #define SkGLContextHelper_DEFINED | 9 #define SkGLContext_DEFINED |
10 | 10 |
11 #include "GrGLInterface.h" | 11 #include "GrGLInterface.h" |
12 | 12 |
13 /** | 13 /** |
14 * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO. | 14 * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO. |
15 * Provides a GrGLInterface struct of function pointers for the context. | 15 * Provides a GrGLInterface struct of function pointers for the context. |
16 */ | 16 */ |
17 | 17 |
18 class SK_API SkGLContextHelper : public SkRefCnt { | 18 class SK_API SkGLContext : public SkRefCnt { |
19 public: | 19 public: |
20 SK_DECLARE_INST_COUNT(SkGLContextHelper) | 20 SK_DECLARE_INST_COUNT(SkGLContext) |
21 | 21 |
22 SkGLContextHelper(); | 22 SkGLContext(); |
23 virtual ~SkGLContextHelper(); | 23 virtual ~SkGLContext(); |
24 | 24 |
25 /** | 25 /** |
26 * Initializes the context and makes it current. | 26 * Initializes the context and makes it current. |
27 */ | 27 */ |
28 bool init(GrGLStandard forcedGpuAPI, const int width, const int height); | 28 bool init(GrGLStandard forcedGpuAPI, const int width, const int height); |
29 | 29 |
30 int getFBOID() const { return fFBO; } | 30 int getFBOID() const { return fFBO; } |
31 | 31 |
32 const GrGLInterface* gl() const { return fGL; } | 32 const GrGLInterface* gl() const { return fGL; } |
33 | 33 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 private: | 75 private: |
76 GrGLuint fFBO; | 76 GrGLuint fFBO; |
77 GrGLuint fColorBufferID; | 77 GrGLuint fColorBufferID; |
78 GrGLuint fDepthStencilBufferID; | 78 GrGLuint fDepthStencilBufferID; |
79 const GrGLInterface* fGL; | 79 const GrGLInterface* fGL; |
80 | 80 |
81 typedef SkRefCnt INHERITED; | 81 typedef SkRefCnt INHERITED; |
82 }; | 82 }; |
83 | 83 |
| 84 /** Creates platform-dependent GL context object |
| 85 * Note: If Skia embedder needs a custom GL context that sets up the GL |
| 86 * interface, this function should be implemented by the embedder. |
| 87 * Otherwise, the default implementation for the platform should be compiled in |
| 88 * the library. |
| 89 */ |
| 90 SK_API SkGLContext* SkCreatePlatformGLContext(); |
| 91 |
84 /** | 92 /** |
85 * Helper macros for using the GL context through the GrGLInterface. Example: | 93 * Helper macros for using the GL context through the GrGLInterface. Example: |
86 * SK_GL(glCtx, GenTextures(1, &texID)); | 94 * SK_GL(glCtx, GenTextures(1, &texID)); |
87 */ | 95 */ |
88 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \ | 96 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \ |
89 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) | 97 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) |
90 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \ | 98 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \ |
91 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) | 99 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) |
92 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X | 100 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X |
93 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X | 101 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X |
94 | 102 |
95 #endif | 103 #endif |
OLD | NEW |