OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef APP_GFX_GL_GL_CONTEXT_EGL_H_ |
| 6 #define APP_GFX_GL_GL_CONTEXT_EGL_H_ |
| 7 |
| 8 #include "gfx/size.h" |
| 9 #include "app/gfx/gl/gl_context.h" |
| 10 |
| 11 typedef void *EGLContext; |
| 12 typedef void* EGLSurface; |
| 13 |
| 14 namespace gfx { |
| 15 |
| 16 // Interface for EGL contexts. Adds an EGL specific accessor for retreiving |
| 17 // the surface. |
| 18 class BaseEGLContext : public GLContext { |
| 19 public: |
| 20 BaseEGLContext() {} |
| 21 virtual ~BaseEGLContext() {} |
| 22 |
| 23 // Implement GLContext. |
| 24 virtual EGLSurface GetSurface() = 0; |
| 25 |
| 26 private: |
| 27 DISALLOW_COPY_AND_ASSIGN(BaseEGLContext); |
| 28 }; |
| 29 |
| 30 // Encapsulates an EGL OpenGL ES context that renders to a view. |
| 31 class NativeViewEGLContext : public BaseEGLContext { |
| 32 public: |
| 33 explicit NativeViewEGLContext(void* window); |
| 34 virtual ~NativeViewEGLContext(); |
| 35 |
| 36 // Initialize an EGL context. |
| 37 bool Initialize(); |
| 38 |
| 39 // Implement GLContext. |
| 40 virtual void Destroy(); |
| 41 virtual bool MakeCurrent(); |
| 42 virtual bool IsCurrent(); |
| 43 virtual bool IsOffscreen(); |
| 44 virtual void SwapBuffers(); |
| 45 virtual gfx::Size GetSize(); |
| 46 virtual void* GetHandle(); |
| 47 |
| 48 // Implement BaseEGLContext. |
| 49 virtual EGLSurface GetSurface(); |
| 50 |
| 51 private: |
| 52 void* window_; |
| 53 EGLSurface surface_; |
| 54 EGLContext context_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(NativeViewEGLContext); |
| 57 }; |
| 58 |
| 59 // Encapsulates an EGL OpenGL ES context intended for offscreen use. It is |
| 60 // actually associated with a native window and will render to it. The caller |
| 61 // must bind an FBO to prevent this. Not using pbuffers because ANGLE does not |
| 62 // support them. |
| 63 class SecondaryEGLContext : public BaseEGLContext { |
| 64 public: |
| 65 SecondaryEGLContext(); |
| 66 virtual ~SecondaryEGLContext(); |
| 67 |
| 68 // Initialize an EGL context that shares a namespace with another. |
| 69 bool Initialize(GLContext* shared_context); |
| 70 |
| 71 // Implement GLContext. |
| 72 virtual void Destroy(); |
| 73 virtual bool MakeCurrent(); |
| 74 virtual bool IsCurrent(); |
| 75 virtual bool IsOffscreen(); |
| 76 virtual void SwapBuffers(); |
| 77 virtual gfx::Size GetSize(); |
| 78 virtual void* GetHandle(); |
| 79 |
| 80 // Implement BaseEGLContext. |
| 81 virtual EGLSurface GetSurface(); |
| 82 |
| 83 private: |
| 84 // All offscreen |
| 85 EGLSurface surface_; |
| 86 EGLContext context_; |
| 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext); |
| 89 }; |
| 90 |
| 91 } // namespace gfx |
| 92 |
| 93 #endif // APP_GFX_GL_GL_CONTEXT_EGL_H_ |
OLD | NEW |