OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <vector> |
| 6 |
| 7 #include "base/memory/ref_counted.h" |
| 8 #include "ui/gl/gl_bindings.h" |
| 9 #include "ui/gl/gl_context_stub_with_extensions.h" |
| 10 #include "ui/gl/gl_gl_api_implementation.h" |
| 11 #include "ui/gl/gl_implementation.h" |
| 12 |
| 13 namespace gfx { |
| 14 // We are pushing an implementation even though we do not support any GL on |
| 15 // Chromecast, because the caller GetAllowedGLImplementations assumes that this |
| 16 // function always adds at least one implementation and would perform an OOB |
| 17 // read anyway. |
| 18 // At this point, placing None as an implementation is incorrect but, this |
| 19 // will force the GPU process to fail its initialization and basically disable |
| 20 // all HW rendering which is the end result we are looking for. |
| 21 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
| 22 impls->push_back(kGLImplementationNone); |
| 23 } |
| 24 |
| 25 bool InitializeStaticGLBindings(GLImplementation implementation) { |
| 26 // Prevent reinitialization with a different implementation. Once the gpu |
| 27 // unit tests have initialized with kGLImplementationMock, we don't want to |
| 28 // later switch to another GL implementation. |
| 29 if (GetGLImplementation() != kGLImplementationNone) |
| 30 return true; |
| 31 |
| 32 switch (implementation) { |
| 33 case kGLImplementationMockGL: { |
| 34 SetGLImplementation(kGLImplementationMockGL); |
| 35 InitializeStaticGLBindingsGL(); |
| 36 break; |
| 37 } |
| 38 default: |
| 39 return false; |
| 40 } |
| 41 |
| 42 return true; |
| 43 } |
| 44 |
| 45 bool InitializeDynamicGLBindings(GLImplementation implementation, |
| 46 GLContext* context) { |
| 47 switch (implementation) { |
| 48 case kGLImplementationMockGL: |
| 49 if (!context) { |
| 50 scoped_refptr<GLContextStubWithExtensions> mock_context( |
| 51 new GLContextStubWithExtensions()); |
| 52 mock_context->SetGLVersionString("3.0"); |
| 53 InitializeDynamicGLBindingsGL(mock_context.get()); |
| 54 } else |
| 55 InitializeDynamicGLBindingsGL(context); |
| 56 break; |
| 57 default: |
| 58 return false; |
| 59 } |
| 60 |
| 61 return true; |
| 62 } |
| 63 |
| 64 void InitializeDebugGLBindings() { |
| 65 InitializeDebugGLBindingsGL(); |
| 66 } |
| 67 |
| 68 void ClearGLBindings() { |
| 69 ClearGLBindingsGL(); |
| 70 SetGLImplementation(kGLImplementationNone); |
| 71 |
| 72 UnloadGLNativeLibraries(); |
| 73 } |
| 74 |
| 75 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { |
| 76 return false; |
| 77 } |
| 78 |
| 79 } // namespace gfx |
OLD | NEW |