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

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

Issue 12328111: Use glGetStringi to get extensions when available. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « include/gpu/gl/GrGLInterface.h ('k') | src/gpu/gl/GrGLContextInfo.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 2011 Google Inc. 3 * Copyright 2011 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 "GrGLExtensions.h"
11 #include "GrGLInterface.h" 12 #include "GrGLInterface.h"
12 #include "SkString.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 */ 17 */
18 18
19 class SkGLContext : public SkRefCnt { 19 class SkGLContext : public SkRefCnt {
20 public: 20 public:
21 SK_DECLARE_INST_COUNT(SkGLContext) 21 SK_DECLARE_INST_COUNT(SkGLContext)
22 22
23 SkGLContext(); 23 SkGLContext();
24 virtual ~SkGLContext(); 24 virtual ~SkGLContext();
25 25
26 /** 26 /**
27 * Initializes the context and makes it current. 27 * Initializes the context and makes it current.
28 */ 28 */
29 bool init(const int width, const int height); 29 bool init(const int width, const int height);
30 30
31 int getFBOID() const { return fFBO; } 31 int getFBOID() const { return fFBO; }
32 32
33 const GrGLInterface* gl() const { return fGL; } 33 const GrGLInterface* gl() const { return fGL; }
34 34
35 virtual void makeCurrent() const = 0; 35 virtual void makeCurrent() const = 0;
36 36
37 bool hasExtension(const char* extensionName) const; 37 bool hasExtension(const char* extensionName) const {
38 GrAssert(NULL != fGL);
39 return fExtensions.has(extensionName);
40 }
38 41
39 protected: 42 protected:
40 /** 43 /**
41 * Subclass implements this to make a GL context. The returned GrGLInterface 44 * Subclass implements this to make a GL context. The returned GrGLInterface
42 * should be populated with functions compatible with the context. The 45 * should be populated with functions compatible with the context. The
43 * format and size of backbuffers does not matter since an FBO will be 46 * format and size of backbuffers does not matter since an FBO will be
44 * created. 47 * created.
45 */ 48 */
46 virtual const GrGLInterface* createGLContext() = 0; 49 virtual const GrGLInterface* createGLContext() = 0;
47 50
48 /** 51 /**
49 * Subclass should destroy the underlying GL context. 52 * Subclass should destroy the underlying GL context.
50 */ 53 */
51 virtual void destroyGLContext() = 0; 54 virtual void destroyGLContext() = 0;
52 55
53 private: 56 private:
54 SkString fExtensionString; 57 GrGLExtensions fExtensions;
55 GrGLuint fFBO; 58 GrGLuint fFBO;
56 GrGLuint fColorBufferID; 59 GrGLuint fColorBufferID;
57 GrGLuint fDepthStencilBufferID; 60 GrGLuint fDepthStencilBufferID;
58 const GrGLInterface* fGL; 61 const GrGLInterface* fGL;
59 62
60 typedef SkRefCnt INHERITED; 63 typedef SkRefCnt INHERITED;
61 }; 64 };
62 65
63 /** 66 /**
64 * Helper macros for using the GL context through the GrGLInterface. Example: 67 * Helper macros for using the GL context through the GrGLInterface. Example:
65 * SK_GL(glCtx, GenTextures(1, &texID)); 68 * SK_GL(glCtx, GenTextures(1, &texID));
66 */ 69 */
67 #define SK_GL(ctx, X) (ctx).gl()->f ## X; \ 70 #define SK_GL(ctx, X) (ctx).gl()->f ## X; \
68 SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError()) 71 SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
69 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->f ## X; \ 72 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->f ## X; \
70 SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError()) 73 SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
71 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->f ## X 74 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->f ## X
72 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->f ## X 75 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->f ## X
73 76
74 #endif 77 #endif
OLDNEW
« no previous file with comments | « include/gpu/gl/GrGLInterface.h ('k') | src/gpu/gl/GrGLContextInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698