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

Side by Side Diff: ui/gfx/gl/gl_surface_egl.h

Issue 6839008: Split EGLContext in GLContextEGL and GLSurfaceEGL. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | « ui/gfx/gl/gl_surface.cc ('k') | ui/gfx/gl/gl_surface_egl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_GL_GL_CONTEXT_EGL_H_ 5 #ifndef UI_GFX_GL_GL_SURFACE_EGL_H_
6 #define UI_GFX_GL_GL_CONTEXT_EGL_H_ 6 #define UI_GFX_GL_GL_SURFACE_EGL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
Alexey Marinichev 2011/04/13 23:45:07 Should surfaces be refcounted? If they shouldn't,
apatrick_chromium 2011/04/13 23:51:58 No that was a hack for windows that is not needed
10 #include "ui/gfx/gl/gl_context.h" 10 #include "ui/gfx/gl/gl_surface.h"
11 #include "ui/gfx/size.h" 11 #include "ui/gfx/size.h"
12 12
13 typedef void* EGLConfig;
13 typedef void* EGLDisplay; 14 typedef void* EGLDisplay;
14 typedef void* EGLContext;
15 typedef void* EGLSurface; 15 typedef void* EGLSurface;
16 16
17 namespace gfx { 17 namespace gfx {
18 18
19 // Takes ownership of an EGL surface and reference counts it so it can be shared 19 // Interface for EGL contexts.
20 // by multiple EGL contexts and destroyed with the last. 20 class GLSurfaceEGL : public GLSurface {
21 class SharedEGLSurface : public base::RefCounted<SharedEGLSurface> {
22 public: 21 public:
23 explicit SharedEGLSurface(EGLSurface surface); 22 GLSurfaceEGL();
24 ~SharedEGLSurface(); 23 virtual ~GLSurfaceEGL();
25 24
26 EGLSurface egl_surface() const; 25 static bool InitializeOneOff();
26 static EGLDisplay GetDisplay();
27 static EGLConfig GetConfig();
27 28
28 private: 29 private:
29 EGLSurface surface_; 30 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL);
30 DISALLOW_COPY_AND_ASSIGN(SharedEGLSurface);
31 }; 31 };
32 32
33 // Interface for EGL contexts. Adds an EGL specific accessor for retreiving 33 // Encapsulates an EGL surface bound to a view.
34 // the surface. 34 class NativeViewGLSurfaceEGL : public GLSurfaceEGL {
35 class BaseEGLContext : public GLContext {
36 public: 35 public:
37 BaseEGLContext() {} 36 explicit NativeViewGLSurfaceEGL(void* window);
38 virtual ~BaseEGLContext() {} 37 virtual ~NativeViewGLSurfaceEGL();
39
40 static bool InitializeOneOff();
41
42 static EGLDisplay GetDisplay();
43
44 // Get the associated EGL surface.
45 virtual SharedEGLSurface* GetSurface() = 0;
46
47 // Implement GLContext.
48 virtual std::string GetExtensions();
49
50 private:
51 DISALLOW_COPY_AND_ASSIGN(BaseEGLContext);
52 };
53
54 // Encapsulates an EGL OpenGL ES context that renders to a view.
55 class NativeViewEGLContext : public BaseEGLContext {
56 public:
57 explicit NativeViewEGLContext(void* window);
58 virtual ~NativeViewEGLContext();
59 38
60 // Initialize an EGL context. 39 // Initialize an EGL context.
61 bool Initialize(); 40 bool Initialize();
62 41
63 // Implement GLContext. 42 // Implement GLSurface.
64 virtual void Destroy(); 43 virtual void Destroy();
65 virtual bool MakeCurrent();
66 virtual bool IsCurrent();
67 virtual bool IsOffscreen(); 44 virtual bool IsOffscreen();
68 virtual bool SwapBuffers(); 45 virtual bool SwapBuffers();
69 virtual gfx::Size GetSize(); 46 virtual gfx::Size GetSize();
70 virtual void* GetHandle(); 47 virtual EGLSurface GetHandle();
71 virtual void SetSwapInterval(int interval);
72
73 // Implement BaseEGLContext.
74 virtual SharedEGLSurface* GetSurface();
75 48
76 private: 49 private:
77 void* window_; 50 void* window_;
78 scoped_refptr<SharedEGLSurface> surface_; 51 EGLSurface surface_;
79 EGLContext context_;
80 52
81 DISALLOW_COPY_AND_ASSIGN(NativeViewEGLContext); 53 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL);
82 }; 54 };
83 55
84 // Encapsulates an EGL OpenGL ES context intended for offscreen use. It is 56 // Encapsulates a pbuffer EGL surface.
85 // actually associated with a native window or a pbuffer on supporting platforms 57 class PbufferGLSurfaceEGL : public GLSurfaceEGL {
86 // and will render to it. The caller must bind an FBO to prevent this.
87 // TODO(apatrick): implement pbuffers in ANGLE and change this to
88 // PbufferEGLContext and use it on all EGL platforms.
89 class SecondaryEGLContext : public BaseEGLContext {
90 public: 58 public:
91 SecondaryEGLContext(); 59 explicit PbufferGLSurfaceEGL(const gfx::Size& size);
92 virtual ~SecondaryEGLContext(); 60 virtual ~PbufferGLSurfaceEGL();
93 61
94 // Initialize an EGL context that shares a namespace with another. 62 // Initialize an EGL context that shares a namespace with another.
95 bool Initialize(GLContext* shared_context); 63 bool Initialize();
96 64
97 // Implement GLContext. 65 // Implement GLSurface.
98 virtual void Destroy(); 66 virtual void Destroy();
99 virtual bool MakeCurrent();
100 virtual bool IsCurrent();
101 virtual bool IsOffscreen(); 67 virtual bool IsOffscreen();
102 virtual bool SwapBuffers(); 68 virtual bool SwapBuffers();
103 virtual gfx::Size GetSize(); 69 virtual gfx::Size GetSize();
104 virtual void* GetHandle(); 70 virtual EGLSurface GetHandle();
105 virtual void SetSwapInterval(int interval);
106
107 // Implement BaseEGLContext.
108 virtual SharedEGLSurface* GetSurface();
109 71
110 private: 72 private:
111 scoped_refptr<SharedEGLSurface> surface_; 73 gfx::Size size_;
112 EGLContext context_; 74 EGLSurface surface_;
113 75
114 DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext); 76 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL);
115 }; 77 };
116 78
117 } // namespace gfx 79 } // namespace gfx
118 80
119 #endif // UI_GFX_GL_GL_CONTEXT_EGL_H_ 81 #endif // UI_GFX_GL_GL_SURFACE_EGL_H_
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_surface.cc ('k') | ui/gfx/gl/gl_surface_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698