OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/test/test_in_process_context_provider.h" | 5 #include "cc/test/test_in_process_context_provider.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "gpu/GLES2/gl2extchromium.h" | 8 #include "gpu/GLES2/gl2extchromium.h" |
9 #include "gpu/command_buffer/client/gl_in_process_context.h" | 9 #include "gpu/command_buffer/client/gl_in_process_context.h" |
10 #include "gpu/command_buffer/client/gles2_implementation.h" | 10 #include "gpu/command_buffer/client/gles2_implementation.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 static base::LazyInstance<GLES2Initializer> g_gles2_initializer = | 79 static base::LazyInstance<GLES2Initializer> g_gles2_initializer = |
80 LAZY_INSTANCE_INITIALIZER; | 80 LAZY_INSTANCE_INITIALIZER; |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 static void BindGrContextCallback(const GrGLInterface* interface) { | 84 static void BindGrContextCallback(const GrGLInterface* interface) { |
85 TestInProcessContextProvider* context_provider = | 85 TestInProcessContextProvider* context_provider = |
86 reinterpret_cast<TestInProcessContextProvider*>(interface->fCallbackData); | 86 reinterpret_cast<TestInProcessContextProvider*>(interface->fCallbackData); |
87 | 87 |
88 // Make sure the gles2 library is initialized first on exactly one thread. | |
89 g_gles2_initializer.Get(); | |
90 gles2::SetGLContext(context_provider->ContextGL()); | 88 gles2::SetGLContext(context_provider->ContextGL()); |
91 } | 89 } |
92 | 90 |
93 class GrContext* TestInProcessContextProvider::GrContext() { | 91 class GrContext* TestInProcessContextProvider::GrContext() { |
94 if (gr_context_) | 92 if (gr_context_) |
95 return gr_context_.get(); | 93 return gr_context_.get(); |
96 | 94 |
| 95 // The GrGLInterface factory will make GL calls using the C GLES2 interface. |
| 96 // Make sure the gles2 library is initialized first on exactly one thread. |
| 97 g_gles2_initializer.Get(); |
| 98 gles2::SetGLContext(ContextGL()); |
| 99 |
97 skia::RefPtr<GrGLInterface> interface = | 100 skia::RefPtr<GrGLInterface> interface = |
98 skia::AdoptRef(skia_bindings::CreateCommandBufferSkiaGLBinding()); | 101 skia::AdoptRef(skia_bindings::CreateCommandBufferSkiaGLBinding()); |
99 interface->fCallback = BindGrContextCallback; | 102 interface->fCallback = BindGrContextCallback; |
100 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); | 103 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); |
101 | 104 |
102 gr_context_ = skia::AdoptRef(GrContext::Create( | 105 gr_context_ = skia::AdoptRef(GrContext::Create( |
103 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); | 106 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); |
104 | 107 |
105 return gr_context_.get(); | 108 return gr_context_.get(); |
106 } | 109 } |
107 | 110 |
108 ContextProvider::Capabilities | 111 ContextProvider::Capabilities |
109 TestInProcessContextProvider::ContextCapabilities() { | 112 TestInProcessContextProvider::ContextCapabilities() { |
110 return ContextProvider::Capabilities(); | 113 return ContextProvider::Capabilities(); |
111 } | 114 } |
112 | 115 |
113 bool TestInProcessContextProvider::IsContextLost() { return false; } | 116 bool TestInProcessContextProvider::IsContextLost() { return false; } |
114 | 117 |
115 void TestInProcessContextProvider::VerifyContexts() {} | 118 void TestInProcessContextProvider::VerifyContexts() {} |
116 | 119 |
117 bool TestInProcessContextProvider::DestroyedOnMainThread() { return false; } | 120 bool TestInProcessContextProvider::DestroyedOnMainThread() { return false; } |
118 | 121 |
119 void TestInProcessContextProvider::SetLostContextCallback( | 122 void TestInProcessContextProvider::SetLostContextCallback( |
120 const LostContextCallback& lost_context_callback) {} | 123 const LostContextCallback& lost_context_callback) {} |
121 | 124 |
122 void TestInProcessContextProvider::SetMemoryPolicyChangedCallback( | 125 void TestInProcessContextProvider::SetMemoryPolicyChangedCallback( |
123 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {} | 126 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {} |
124 | 127 |
125 } // namespace cc | 128 } // namespace cc |
OLD | NEW |