OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ui/gl/init/gl_factory.h" | 5 #include "ui/gl/init/gl_factory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Used to render into an already current context+surface, | 27 // Used to render into an already current context+surface, |
28 // that we do not have ownership of (draw callback). | 28 // that we do not have ownership of (draw callback). |
29 // TODO(boliu): Make this inherit from GLContextEGL. | 29 // TODO(boliu): Make this inherit from GLContextEGL. |
30 class GLNonOwnedContext : public GLContextReal { | 30 class GLNonOwnedContext : public GLContextReal { |
31 public: | 31 public: |
32 explicit GLNonOwnedContext(GLShareGroup* share_group); | 32 explicit GLNonOwnedContext(GLShareGroup* share_group); |
33 | 33 |
34 // Implement GLContext. | 34 // Implement GLContext. |
35 bool Initialize(GLSurface* compatible_surface, | 35 bool Initialize(GLSurface* compatible_surface, |
36 GpuPreference gpu_preference) override; | 36 const GLContextAttribs& attribs) override; |
37 bool MakeCurrent(GLSurface* surface) override; | 37 bool MakeCurrent(GLSurface* surface) override; |
38 void ReleaseCurrent(GLSurface* surface) override {} | 38 void ReleaseCurrent(GLSurface* surface) override {} |
39 bool IsCurrent(GLSurface* surface) override { return true; } | 39 bool IsCurrent(GLSurface* surface) override { return true; } |
40 void* GetHandle() override { return nullptr; } | 40 void* GetHandle() override { return nullptr; } |
41 void OnSetSwapInterval(int interval) override {} | 41 void OnSetSwapInterval(int interval) override {} |
42 std::string GetExtensions() override; | 42 std::string GetExtensions() override; |
43 | 43 |
44 protected: | 44 protected: |
45 ~GLNonOwnedContext() override {} | 45 ~GLNonOwnedContext() override {} |
46 | 46 |
47 private: | 47 private: |
48 EGLDisplay display_; | 48 EGLDisplay display_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(GLNonOwnedContext); | 50 DISALLOW_COPY_AND_ASSIGN(GLNonOwnedContext); |
51 }; | 51 }; |
52 | 52 |
53 GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group) | 53 GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group) |
54 : GLContextReal(share_group), display_(nullptr) {} | 54 : GLContextReal(share_group), display_(nullptr) {} |
55 | 55 |
56 bool GLNonOwnedContext::Initialize(GLSurface* compatible_surface, | 56 bool GLNonOwnedContext::Initialize(GLSurface* compatible_surface, |
57 GpuPreference gpu_preference) { | 57 const GLContextAttribs& attribs) { |
58 display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); | 58 display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
59 return true; | 59 return true; |
60 } | 60 } |
61 | 61 |
62 bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) { | 62 bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) { |
63 SetRealGLApi(); | 63 SetRealGLApi(); |
64 SetCurrent(surface); | 64 SetCurrent(surface); |
65 InitializeDynamicBindings(); | 65 InitializeDynamicBindings(); |
66 return true; | 66 return true; |
67 } | 67 } |
(...skipping 19 matching lines...) Expand all Loading... |
87 switch (GetGLImplementation()) { | 87 switch (GetGLImplementation()) { |
88 case kGLImplementationEGLGLES2: | 88 case kGLImplementationEGLGLES2: |
89 return GetGLWindowSystemBindingInfoEGL(info); | 89 return GetGLWindowSystemBindingInfoEGL(info); |
90 default: | 90 default: |
91 return false; | 91 return false; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, | 95 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, |
96 GLSurface* compatible_surface, | 96 GLSurface* compatible_surface, |
97 GpuPreference gpu_preference) { | 97 const GLContextAttribs& attribs) { |
98 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); | 98 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); |
99 switch (GetGLImplementation()) { | 99 switch (GetGLImplementation()) { |
100 case kGLImplementationMockGL: | 100 case kGLImplementationMockGL: |
101 return scoped_refptr<GLContext>(new GLContextStub(share_group)); | 101 return scoped_refptr<GLContext>(new GLContextStub(share_group)); |
102 case kGLImplementationOSMesaGL: | 102 case kGLImplementationOSMesaGL: |
103 return InitializeGLContext(new GLContextOSMesa(share_group), | 103 return InitializeGLContext(new GLContextOSMesa(share_group), |
104 compatible_surface, gpu_preference); | 104 compatible_surface, attribs); |
105 default: | 105 default: |
106 if (compatible_surface->GetHandle()) { | 106 if (compatible_surface->GetHandle()) { |
107 return InitializeGLContext(new GLContextEGL(share_group), | 107 return InitializeGLContext(new GLContextEGL(share_group), |
108 compatible_surface, gpu_preference); | 108 compatible_surface, attribs); |
109 } else { | 109 } else { |
110 return InitializeGLContext(new GLNonOwnedContext(share_group), | 110 return InitializeGLContext(new GLNonOwnedContext(share_group), |
111 compatible_surface, gpu_preference); | 111 compatible_surface, attribs); |
112 } | 112 } |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { | 116 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { |
117 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); | 117 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); |
118 CHECK_NE(kGLImplementationNone, GetGLImplementation()); | 118 CHECK_NE(kGLImplementationNone, GetGLImplementation()); |
119 switch (GetGLImplementation()) { | 119 switch (GetGLImplementation()) { |
120 case kGLImplementationOSMesaGL: | 120 case kGLImplementationOSMesaGL: |
121 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); | 121 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); |
(...skipping 29 matching lines...) Expand all Loading... |
151 case kGLImplementationMockGL: | 151 case kGLImplementationMockGL: |
152 return new GLSurfaceStub; | 152 return new GLSurfaceStub; |
153 default: | 153 default: |
154 NOTREACHED(); | 154 NOTREACHED(); |
155 return nullptr; | 155 return nullptr; |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 } // namespace init | 159 } // namespace init |
160 } // namespace gl | 160 } // namespace gl |
OLD | NEW |