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 GLContext_DEFINED | 8 #ifndef GLTestContext_DEFINED |
9 #define GLContext_DEFINED | 9 #define GLTestContext_DEFINED |
10 | 10 |
11 #include "gl/GrGLInterface.h" | 11 #include "gl/GrGLInterface.h" |
12 #include "../private/SkGpuFenceSync.h" | 12 #include "../private/SkGpuFenceSync.h" |
13 | 13 |
14 | 14 |
15 namespace sk_gpu_test { | 15 namespace sk_gpu_test { |
16 /** | 16 /** |
17 * Create an offscreen Oppengl context. Provides a GrGLInterface struct of funct
ion pointers for | 17 * Create an offscreen Oppengl context. Provides a GrGLInterface struct of funct
ion pointers for |
18 * the context. This class is intended for Skia's internal testing needs and not
for general use. | 18 * the context. This class is intended for Skia's internal testing needs and not
for general use. |
19 */ | 19 */ |
20 class GLContext : public SkNoncopyable { | 20 class GLTestContext : public SkNoncopyable { |
21 public: | 21 public: |
22 virtual ~GLContext(); | 22 virtual ~GLTestContext(); |
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 fFenceSync != nullptr; } | 28 bool fenceSyncSupport() const { return fFenceSync != nullptr; } |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 * the context. It is useful for debugging contexts that would otherwise | 75 * the context. It is useful for debugging contexts that would otherwise |
76 * test that GPU resources are properly deleted. It also allows a debugging | 76 * test that GPU resources are properly deleted. It also allows a debugging |
77 * context to test that further GL calls are not made by Skia GPU code. | 77 * context to test that further GL calls are not made by Skia GPU code. |
78 */ | 78 */ |
79 void testAbandon(); | 79 void testAbandon(); |
80 | 80 |
81 /** | 81 /** |
82 * Creates a new GL context of the same type and makes the returned context
current | 82 * Creates a new GL context of the same type and makes the returned context
current |
83 * (if not null). | 83 * (if not null). |
84 */ | 84 */ |
85 virtual GLContext *createNew() const { return nullptr; } | 85 virtual GLTestContext *createNew() const { return nullptr; } |
86 | 86 |
87 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu
nctionality. | 87 class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL fu
nctionality. |
88 | 88 |
89 /* | 89 /* |
90 * returns the fencesync object owned by this GLContext | 90 * returns the fencesync object owned by this GLTestContext |
91 */ | 91 */ |
92 SkGpuFenceSync *fenceSync() { return fFenceSync.get(); } | 92 SkGpuFenceSync *fenceSync() { return fFenceSync.get(); } |
93 | 93 |
94 protected: | 94 protected: |
95 GLContext(); | 95 GLTestContext(); |
96 | 96 |
97 /* | 97 /* |
98 * Methods that sublcasses must call from their constructors and destructors
. | 98 * Methods that sublcasses must call from their constructors and destructors
. |
99 */ | 99 */ |
100 void init(const GrGLInterface *, SkGpuFenceSync * = NULL); | 100 void init(const GrGLInterface *, SkGpuFenceSync * = NULL); |
101 | 101 |
102 void teardown(); | 102 void teardown(); |
103 | 103 |
104 /* | 104 /* |
105 * Operations that have a platform-dependent implementation. | 105 * Operations that have a platform-dependent implementation. |
(...skipping 15 matching lines...) Expand all Loading... |
121 | 121 |
122 /** Subclass provides the gl interface object if construction was | 122 /** Subclass provides the gl interface object if construction was |
123 * successful. */ | 123 * successful. */ |
124 SkAutoTUnref<const GrGLInterface> fGL; | 124 SkAutoTUnref<const GrGLInterface> fGL; |
125 | 125 |
126 friend class GLFenceSync; // For onPlatformGetProcAddress. | 126 friend class GLFenceSync; // For onPlatformGetProcAddress. |
127 }; | 127 }; |
128 | 128 |
129 | 129 |
130 /** Creates platform-dependent GL context object. The shareContext parameter is
in an optional | 130 /** Creates platform-dependent GL context object. The shareContext parameter is
in an optional |
131 * context with which to share display lists. This should be a pointer to an GLC
ontext created | 131 * context with which to share display lists. This should be a pointer to an GLT
estContext created |
132 * with SkCreatePlatformGLContext. NULL indicates that no sharing is to take pl
ace. Returns a valid | 132 * with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to tak
e place. Returns a valid |
133 * gl context object or NULL if such can not be created. | 133 * gl context object or NULL if such can not be created. |
134 * Note: If Skia embedder needs a custom GL context that sets up the GL interfac
e, this function | 134 * Note: If Skia embedder needs a custom GL context that sets up the GL interfac
e, this function |
135 * should be implemented by the embedder. Otherwise, the default implementation
for the platform | 135 * should be implemented by the embedder. Otherwise, the default implementation
for the platform |
136 * should be compiled in the library. | 136 * should be compiled in the library. |
137 */ | 137 */ |
138 GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareCo
ntext = nullptr); | 138 GLTestContext* CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, GLTestCont
ext *shareContext = nullptr); |
139 | 139 |
140 } // namespace sk_gpu_test | 140 } // namespace sk_gpu_test |
141 #endif | 141 #endif |
OLD | NEW |