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 SkGLContext_DEFINED | 8 #ifndef SkGLContext_DEFINED |
9 #define SkGLContext_DEFINED | 9 #define SkGLContext_DEFINED |
10 | 10 |
11 #include "GrGLInterface.h" | 11 #include "GrGLInterface.h" |
12 #include "../private/SkGpuFenceSync.h" | 12 #include "../private/SkGpuFenceSync.h" |
13 | 13 |
14 /** | 14 /** |
15 * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO. | 15 * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO. |
16 * Provides a GrGLInterface struct of function pointers for the context. | 16 * Provides a GrGLInterface struct of function pointers for the context. |
17 * This class is intended for Skia's testing needs and not for general | 17 * This class is intended for Skia's testing needs and not for general |
18 * use. | 18 * use. |
19 */ | 19 */ |
20 class SK_API SkGLContext : public SkRefCnt { | 20 class SK_API SkGLContext : public SkNoncopyable { |
21 public: | 21 public: |
22 ~SkGLContext() override; | 22 virtual ~SkGLContext(); |
23 | 23 |
24 bool isValid() const { return NULL != gl(); } | 24 bool isValid() const { return NULL != gl(); } |
25 | 25 |
26 const GrGLInterface* gl() const { return fGL.get(); } | 26 const GrGLInterface* gl() const { return fGL.get(); } |
27 | 27 |
28 bool fenceSyncSupport() const { return SkToBool(fFenceSync); } | 28 bool fenceSyncSupport() const { return SkToBool(fFenceSync); } |
29 | 29 |
30 bool getMaxGpuFrameLag(int* maxFrameLag) const { | 30 bool getMaxGpuFrameLag(int* maxFrameLag) const { |
31 if (!fFenceSync) { | 31 if (!fFenceSync) { |
32 return false; | 32 return false; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 SkAutoTDelete<SkGpuFenceSync> fFenceSync; | 100 SkAutoTDelete<SkGpuFenceSync> fFenceSync; |
101 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1]; | 101 SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1]; |
102 int fCurrentFenceIdx; | 102 int fCurrentFenceIdx; |
103 | 103 |
104 /** Subclass provides the gl interface object if construction was | 104 /** Subclass provides the gl interface object if construction was |
105 * successful. */ | 105 * successful. */ |
106 SkAutoTUnref<const GrGLInterface> fGL; | 106 SkAutoTUnref<const GrGLInterface> fGL; |
107 | 107 |
108 friend class GLFenceSync; // For onPlatformGetProcAddress. | 108 friend class GLFenceSync; // For onPlatformGetProcAddress. |
109 | |
110 typedef SkRefCnt INHERITED; | |
111 }; | 109 }; |
112 | 110 |
113 /** Creates platform-dependent GL context object | 111 /** Creates platform-dependent GL context object |
114 * Returns a valid gl context object or NULL if such can not be created. | 112 * Returns a valid gl context object or NULL if such can not be created. |
115 * Note: If Skia embedder needs a custom GL context that sets up the GL | 113 * Note: If Skia embedder needs a custom GL context that sets up the GL |
116 * interface, this function should be implemented by the embedder. | 114 * interface, this function should be implemented by the embedder. |
117 * Otherwise, the default implementation for the platform should be compiled in | 115 * Otherwise, the default implementation for the platform should be compiled in |
118 * the library. | 116 * the library. |
119 */ | 117 */ |
120 SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI); | 118 SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI); |
121 | 119 |
122 /** | 120 /** |
123 * Helper macros for using the GL context through the GrGLInterface. Example: | 121 * Helper macros for using the GL context through the GrGLInterface. Example: |
124 * SK_GL(glCtx, GenTextures(1, &texID)); | 122 * SK_GL(glCtx, GenTextures(1, &texID)); |
125 */ | 123 */ |
126 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \ | 124 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \ |
127 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) | 125 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) |
128 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \ | 126 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \ |
129 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) | 127 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) |
130 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X | 128 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X |
131 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X | 129 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X |
132 | 130 |
133 #endif | 131 #endif |
OLD | NEW |