Index: chromecast/ui/gl/gl_implementation_cast.cc |
diff --git a/chromecast/ui/gl/gl_implementation_cast.cc b/chromecast/ui/gl/gl_implementation_cast.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7b35e47a861a10b41d70486f4620eb12fdb99269 |
--- /dev/null |
+++ b/chromecast/ui/gl/gl_implementation_cast.cc |
@@ -0,0 +1,79 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <vector> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "ui/gl/gl_bindings.h" |
+#include "ui/gl/gl_context_stub_with_extensions.h" |
+#include "ui/gl/gl_gl_api_implementation.h" |
+#include "ui/gl/gl_implementation.h" |
+ |
+namespace gfx { |
+// We are pushing an implementation even though we do not support any GL on |
+// Chromecast, because the caller GetAllowedGLImplementations assumes that this |
+// function always adds at least one implementation and would perform an OOB |
+// read anyway. |
+// At this point, placing None as an implementation is incorrect but, this |
+// will force the GPU process to fail its initialization and basically disable |
+// all HW rendering which is the end result we are looking for. |
+void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
+ impls->push_back(kGLImplementationNone); |
+} |
+ |
+bool InitializeStaticGLBindings(GLImplementation implementation) { |
+ // Prevent reinitialization with a different implementation. Once the gpu |
+ // unit tests have initialized with kGLImplementationMock, we don't want to |
+ // later switch to another GL implementation. |
+ if (GetGLImplementation() != kGLImplementationNone) |
+ return true; |
+ |
+ switch (implementation) { |
+ case kGLImplementationMockGL: { |
+ SetGLImplementation(kGLImplementationMockGL); |
+ InitializeStaticGLBindingsGL(); |
+ break; |
+ } |
+ default: |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+bool InitializeDynamicGLBindings(GLImplementation implementation, |
+ GLContext* context) { |
+ switch (implementation) { |
+ case kGLImplementationMockGL: |
+ if (!context) { |
+ scoped_refptr<GLContextStubWithExtensions> mock_context( |
+ new GLContextStubWithExtensions()); |
+ mock_context->SetGLVersionString("3.0"); |
+ InitializeDynamicGLBindingsGL(mock_context.get()); |
+ } else |
+ InitializeDynamicGLBindingsGL(context); |
+ break; |
+ default: |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+void InitializeDebugGLBindings() { |
+ InitializeDebugGLBindingsGL(); |
+} |
+ |
+void ClearGLBindings() { |
+ ClearGLBindingsGL(); |
+ SetGLImplementation(kGLImplementationNone); |
+ |
+ UnloadGLNativeLibraries(); |
+} |
+ |
+bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { |
+ return false; |
+} |
+ |
+} // namespace gfx |