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

Side by Side Diff: cc/test/test_in_process_context_provider.cc

Issue 1671283002: Bind GrContext to GLES2Interface rather than C GLES interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix dependency in gyp and gn? Created 4 years, 9 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
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } 76 bool TestInProcessContextProvider::BindToCurrentThread() { return true; }
77 77
78 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { 78 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() {
79 return context_->GetImplementation(); 79 return context_->GetImplementation();
80 } 80 }
81 81
82 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { 82 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() {
83 return context_->GetImplementation(); 83 return context_->GetImplementation();
84 } 84 }
85 85
86 namespace {
87
88 // Singleton used to initialize and terminate the gles2 library.
89 class GLES2Initializer {
90 public:
91 GLES2Initializer() { ::gles2::Initialize(); }
92
93 ~GLES2Initializer() { ::gles2::Terminate(); }
94
95 private:
96 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
97 };
98
99 static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
100 LAZY_INSTANCE_INITIALIZER;
101
102 } // namespace
103
104 static void BindGrContextCallback(const GrGLInterface* interface) {
105 TestInProcessContextProvider* context_provider =
106 reinterpret_cast<TestInProcessContextProvider*>(interface->fCallbackData);
107
108 gles2::SetGLContext(context_provider->ContextGL());
109 }
110
111 class GrContext* TestInProcessContextProvider::GrContext() { 86 class GrContext* TestInProcessContextProvider::GrContext() {
112 if (gr_context_) 87 if (gr_context_)
113 return gr_context_.get(); 88 return gr_context_.get();
114 89
115 // The GrGLInterface factory will make GL calls using the C GLES2 interface.
116 // Make sure the gles2 library is initialized first on exactly one thread.
117 g_gles2_initializer.Get();
118 gles2::SetGLContext(ContextGL());
119
120 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(new GrGLInterface); 90 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(new GrGLInterface);
121 skia_bindings::InitCommandBufferSkiaGLBinding(interface.get()); 91 skia_bindings::InitGLES2InterfaceBindings(interface.get(), ContextGL());
122 interface->fCallback = BindGrContextCallback;
123 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
124 92
125 gr_context_ = skia::AdoptRef(GrContext::Create( 93 gr_context_ = skia::AdoptRef(GrContext::Create(
126 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); 94 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get())));
127 95
128 return gr_context_.get(); 96 return gr_context_.get();
129 } 97 }
130 98
131 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { 99 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) {
132 if (gr_context_) 100 if (gr_context_)
133 gr_context_.get()->resetContext(state); 101 gr_context_.get()->resetContext(state);
(...skipping 27 matching lines...) Expand all
161 129
162 void TestInProcessContextProvider::DeleteCachedResources() { 130 void TestInProcessContextProvider::DeleteCachedResources() {
163 if (gr_context_) 131 if (gr_context_)
164 gr_context_->freeGpuResources(); 132 gr_context_->freeGpuResources();
165 } 133 }
166 134
167 void TestInProcessContextProvider::SetLostContextCallback( 135 void TestInProcessContextProvider::SetLostContextCallback(
168 const LostContextCallback& lost_context_callback) {} 136 const LostContextCallback& lost_context_callback) {}
169 137
170 } // namespace cc 138 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698