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

Side by Side Diff: chromecast/ui/gl/gl_implementation_cast.cc

Issue 223143003: Initial checkin of chromecast content embedder (cast_shell) and related build scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an additional function in gl_surface_cast.cc Created 6 years, 8 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698