OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gl_context_stub.h" | 5 #include "ui/gl/gl_context_stub.h" |
6 | 6 |
7 #include "ui/gl/gl_gl_api_implementation.h" | 7 #include "ui/gl/gl_gl_api_implementation.h" |
| 8 #include "ui/gl/gl_stub_api.h" |
8 | 9 |
9 namespace gl { | 10 namespace gl { |
10 | 11 |
11 GLContextStub::GLContextStub() : GLContextReal(nullptr) {} | 12 GLContextStub::GLContextStub() : GLContextStub(nullptr) {} |
12 GLContextStub::GLContextStub(GLShareGroup* share_group) | 13 GLContextStub::GLContextStub(GLShareGroup* share_group) |
13 : GLContextReal(share_group) {} | 14 : GLContextReal(share_group), |
| 15 use_stub_api_(false), |
| 16 version_str_("OpenGL ES 3.0"), |
| 17 extensions_("GL_EXT_framebuffer_object") {} |
14 | 18 |
15 bool GLContextStub::Initialize(GLSurface* compatible_surface, | 19 bool GLContextStub::Initialize(GLSurface* compatible_surface, |
16 const GLContextAttribs& attribs) { | 20 const GLContextAttribs& attribs) { |
17 return true; | 21 return true; |
18 } | 22 } |
19 | 23 |
20 bool GLContextStub::MakeCurrent(GLSurface* surface) { | 24 bool GLContextStub::MakeCurrent(GLSurface* surface) { |
21 SetGLToStubGLApi(); | 25 BindGLApi(); |
22 SetCurrent(surface); | 26 SetCurrent(surface); |
23 InitializeDynamicBindings(); | 27 InitializeDynamicBindings(); |
24 return true; | 28 return true; |
25 } | 29 } |
26 | 30 |
27 void GLContextStub::ReleaseCurrent(GLSurface* surface) { | 31 void GLContextStub::ReleaseCurrent(GLSurface* surface) { |
28 SetCurrent(nullptr); | 32 SetCurrent(nullptr); |
29 } | 33 } |
30 | 34 |
31 bool GLContextStub::IsCurrent(GLSurface* surface) { | 35 bool GLContextStub::IsCurrent(GLSurface* surface) { |
32 return GetRealCurrent() == this; | 36 return GetRealCurrent() == this; |
33 } | 37 } |
34 | 38 |
35 void* GLContextStub::GetHandle() { | 39 void* GLContextStub::GetHandle() { |
36 return nullptr; | 40 return nullptr; |
37 } | 41 } |
38 | 42 |
39 void GLContextStub::OnSetSwapInterval(int interval) { | 43 void GLContextStub::OnSetSwapInterval(int interval) { |
40 } | 44 } |
41 | 45 |
| 46 std::string GLContextStub::GetGLVersion() { |
| 47 return version_str_; |
| 48 } |
| 49 |
42 std::string GLContextStub::GetGLRenderer() { | 50 std::string GLContextStub::GetGLRenderer() { |
43 return std::string("CHROMIUM"); | 51 return std::string("CHROMIUM"); |
44 } | 52 } |
45 | 53 |
| 54 bool GLContextStub::WasAllocatedUsingRobustnessExtension() { |
| 55 return HasExtension("GL_ARB_robustness") || |
| 56 HasExtension("GL_KHR_robustness") || HasExtension("GL_EXT_robustness"); |
| 57 } |
| 58 |
| 59 std::string GLContextStub::GetExtensions() { |
| 60 return extensions_; |
| 61 } |
| 62 |
| 63 void GLContextStub::SetUseStubApi(bool stub_api) { |
| 64 use_stub_api_ = stub_api; |
| 65 } |
| 66 |
| 67 void GLContextStub::SetExtensionsString(const char* extensions) { |
| 68 extensions_ = extensions; |
| 69 } |
| 70 |
| 71 void GLContextStub::SetGLVersionString(const char* version_str) { |
| 72 version_str_ = std::string(version_str ? version_str : ""); |
| 73 } |
| 74 |
46 GLContextStub::~GLContextStub() {} | 75 GLContextStub::~GLContextStub() {} |
47 | 76 |
| 77 GLApi* GLContextStub::CreateGLApi(DriverGL* driver) { |
| 78 if (use_stub_api_) { |
| 79 GLStubApi* stub_api = new GLStubApi(); |
| 80 if (!version_str_.empty()) { |
| 81 stub_api->set_version(version_str_); |
| 82 } |
| 83 if (!extensions_.empty()) { |
| 84 stub_api->set_extensions(extensions_); |
| 85 } |
| 86 return stub_api; |
| 87 } |
| 88 |
| 89 return GLContext::CreateGLApi(driver); |
| 90 } |
| 91 |
48 } // namespace gl | 92 } // namespace gl |
OLD | NEW |