Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: include/gpu/gl/SkGLContext.h

Issue 1560643002: Revert of Make SkGLContext lifetime more well-defined (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gyp/pathops_unittest.gyp ('k') | src/gpu/GrContextFactory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SkNoncopyable { 20 class SK_API SkGLContext : public SkRefCnt {
21 public: 21 public:
22 virtual ~SkGLContext(); 22 ~SkGLContext() override;
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
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;
109 }; 111 };
110 112
111 /** Creates platform-dependent GL context object 113 /** Creates platform-dependent GL context object
112 * Returns a valid gl context object or NULL if such can not be created. 114 * Returns a valid gl context object or NULL if such can not be created.
113 * Note: If Skia embedder needs a custom GL context that sets up the GL 115 * Note: If Skia embedder needs a custom GL context that sets up the GL
114 * interface, this function should be implemented by the embedder. 116 * interface, this function should be implemented by the embedder.
115 * Otherwise, the default implementation for the platform should be compiled in 117 * Otherwise, the default implementation for the platform should be compiled in
116 * the library. 118 * the library.
117 */ 119 */
118 SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI); 120 SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI);
119 121
120 /** 122 /**
121 * Helper macros for using the GL context through the GrGLInterface. Example: 123 * Helper macros for using the GL context through the GrGLInterface. Example:
122 * SK_GL(glCtx, GenTextures(1, &texID)); 124 * SK_GL(glCtx, GenTextures(1, &texID));
123 */ 125 */
124 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \ 126 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \
125 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) 127 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError())
126 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \ 128 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \
127 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError()) 129 SkASSERT(0 == (ctx).gl()->fFunctions.fGetError())
128 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X 130 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X
129 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X 131 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X
130 132
131 #endif 133 #endif
OLDNEW
« no previous file with comments | « gyp/pathops_unittest.gyp ('k') | src/gpu/GrContextFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698