diff options
author | Derek Sollenberger <djsollen@google.com> | 2012-01-18 08:56:56 -0500 |
---|---|---|
committer | Derek Sollenberger <derek@android.com> | 2012-02-06 14:14:40 -0500 |
commit | 1cab2921ab279367f8206cdadc9259d12e603548 (patch) | |
tree | 2852f9dc2481f639122e18fc7831ae6ca43d6d5a /include/gpu/SkGLContext.h | |
parent | d7176fd5571bc9878d3cdac8696eaa35ec170d9d (diff) | |
download | external_skia-1cab2921ab279367f8206cdadc9259d12e603548.zip external_skia-1cab2921ab279367f8206cdadc9259d12e603548.tar.gz external_skia-1cab2921ab279367f8206cdadc9259d12e603548.tar.bz2 |
Skia merge (revision 3022)
This CL has companion changes to account for API updates in...
(1) frameworks/base
(2) external/webkit
Change-Id: Ibb989e76e8bd24313849f9631dbef42cdef9eb7d
Diffstat (limited to 'include/gpu/SkGLContext.h')
-rw-r--r-- | include/gpu/SkGLContext.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/gpu/SkGLContext.h b/include/gpu/SkGLContext.h new file mode 100644 index 0000000..f92a770 --- /dev/null +++ b/include/gpu/SkGLContext.h @@ -0,0 +1,59 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef SkGLContext_DEFINED +#define SkGLContext_DEFINED + +#include "GrGLInterface.h" + +/** + * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO. + * Provides a GrGLInterface struct of function pointers for the context. + */ + +class SkGLContext : public SkRefCnt { +public: + SkGLContext(); + virtual ~SkGLContext(); + + /** + * Initializes the context and makes it current. + */ + bool init(const int width, const int height); + + int getFBOID() const { return fFBO; } + + const GrGLInterface* gl() const { return fGL; } + + virtual void makeCurrent() const = 0; + +protected: + /** + * Subclass implements this to make a GL context. The returned GrGLInterface + * should be populated with functions compatible with the context. The + * format and size of backbuffers does not matter since an FBO will be + * created. + */ + virtual const GrGLInterface* createGLContext() = 0; + + /** + * Subclass should destroy the underlying GL context. + */ + virtual void destroyGLContext() = 0; + +private: + GrGLuint fFBO; + const GrGLInterface* fGL; +}; + +/** + * Helper macro for using the GL context through the GrGLInterface. Example: + * SK_GL(glCtx, GenTextures(1, &texID)); + */ +#define SK_GL(ctx, X) (ctx).gl()->f ## X + +#endif |