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

Unified Diff: ui/gl/gl_context_stub.cc

Issue 2629633003: Refactor GL bindings so there is no global GLApi or DriverGL. (Closed)
Patch Set: rebase Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_context_stub.h ('k') | ui/gl/gl_context_stub_with_extensions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_context_stub.cc
diff --git a/ui/gl/gl_context_stub.cc b/ui/gl/gl_context_stub.cc
index a72f08080cc06d5b3f7c341c6bd1e9480a046316..1c54f9dd42c1d4263c6a4862b8b38998ebe62ce0 100644
--- a/ui/gl/gl_context_stub.cc
+++ b/ui/gl/gl_context_stub.cc
@@ -5,12 +5,16 @@
#include "ui/gl/gl_context_stub.h"
#include "ui/gl/gl_gl_api_implementation.h"
+#include "ui/gl/gl_stub_api.h"
namespace gl {
-GLContextStub::GLContextStub() : GLContextReal(nullptr) {}
+GLContextStub::GLContextStub() : GLContextStub(nullptr) {}
GLContextStub::GLContextStub(GLShareGroup* share_group)
- : GLContextReal(share_group) {}
+ : GLContextReal(share_group),
+ use_stub_api_(false),
+ version_str_("OpenGL ES 3.0"),
+ extensions_("GL_EXT_framebuffer_object") {}
bool GLContextStub::Initialize(GLSurface* compatible_surface,
const GLContextAttribs& attribs) {
@@ -18,7 +22,7 @@ bool GLContextStub::Initialize(GLSurface* compatible_surface,
}
bool GLContextStub::MakeCurrent(GLSurface* surface) {
- SetGLToStubGLApi();
+ BindGLApi();
SetCurrent(surface);
InitializeDynamicBindings();
return true;
@@ -39,10 +43,50 @@ void* GLContextStub::GetHandle() {
void GLContextStub::OnSetSwapInterval(int interval) {
}
+std::string GLContextStub::GetGLVersion() {
+ return version_str_;
+}
+
std::string GLContextStub::GetGLRenderer() {
return std::string("CHROMIUM");
}
+bool GLContextStub::WasAllocatedUsingRobustnessExtension() {
+ return HasExtension("GL_ARB_robustness") ||
+ HasExtension("GL_KHR_robustness") || HasExtension("GL_EXT_robustness");
+}
+
+std::string GLContextStub::GetExtensions() {
+ return extensions_;
+}
+
+void GLContextStub::SetUseStubApi(bool stub_api) {
+ use_stub_api_ = stub_api;
+}
+
+void GLContextStub::SetExtensionsString(const char* extensions) {
+ extensions_ = extensions;
+}
+
+void GLContextStub::SetGLVersionString(const char* version_str) {
+ version_str_ = std::string(version_str ? version_str : "");
+}
+
GLContextStub::~GLContextStub() {}
+GLApi* GLContextStub::CreateGLApi(DriverGL* driver) {
+ if (use_stub_api_) {
+ GLStubApi* stub_api = new GLStubApi();
+ if (!version_str_.empty()) {
+ stub_api->set_version(version_str_);
+ }
+ if (!extensions_.empty()) {
+ stub_api->set_extensions(extensions_);
+ }
+ return stub_api;
+ }
+
+ return GLContext::CreateGLApi(driver);
+}
+
} // namespace gl
« no previous file with comments | « ui/gl/gl_context_stub.h ('k') | ui/gl/gl_context_stub_with_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698