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

Side by Side Diff: blimp/client/compositor/blimp_context_provider.cc

Issue 1414683003: Fix gpu command buffer use after free by GrContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fixup Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/client/compositor/blimp_context_provider.h" 5 #include "blimp/client/compositor/blimp_context_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "gpu/command_buffer/client/gl_in_process_context.h" 10 #include "gpu/command_buffer/client/gl_in_process_context.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DCHECK(context_thread_checker_.CalledOnValidThread()); 106 DCHECK(context_thread_checker_.CalledOnValidThread());
107 107
108 if (gr_context_) 108 if (gr_context_)
109 return gr_context_.get(); 109 return gr_context_.get();
110 110
111 // The GrGLInterface factory will make GL calls using the C GLES2 interface. 111 // The GrGLInterface factory will make GL calls using the C GLES2 interface.
112 // Make sure the gles2 library is initialized first on exactly one thread. 112 // Make sure the gles2 library is initialized first on exactly one thread.
113 g_gles2_initializer.Get(); 113 g_gles2_initializer.Get();
114 gles2::SetGLContext(ContextGL()); 114 gles2::SetGLContext(ContextGL());
115 115
116 skia::RefPtr<GrGLInterface> interface = 116 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(new GrGLInterface);
117 skia::AdoptRef(skia_bindings::CreateCommandBufferSkiaGLBinding()); 117 skia_bindings::InitCommandBufferSkiaGLBinding(interface.get());
118 interface->fCallback = BindGrContextCallback; 118 interface->fCallback = BindGrContextCallback;
119 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); 119 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
120 120
121 gr_context_ = skia::AdoptRef(GrContext::Create( 121 gr_context_ = skia::AdoptRef(GrContext::Create(
122 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); 122 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get())));
123 123
124 return gr_context_.get(); 124 return gr_context_.get();
125 } 125 }
126 126
127 void BlimpContextProvider::InvalidateGrContext(uint32_t state) { 127 void BlimpContextProvider::InvalidateGrContext(uint32_t state) {
(...skipping 26 matching lines...) Expand all
154 154
155 void BlimpContextProvider::OnLostContext() { 155 void BlimpContextProvider::OnLostContext() {
156 DCHECK(context_thread_checker_.CalledOnValidThread()); 156 DCHECK(context_thread_checker_.CalledOnValidThread());
157 if (!lost_context_callback_.is_null()) 157 if (!lost_context_callback_.is_null())
158 base::ResetAndReturn(&lost_context_callback_).Run(); 158 base::ResetAndReturn(&lost_context_callback_).Run();
159 if (gr_context_) 159 if (gr_context_)
160 gr_context_->abandonContext(); 160 gr_context_->abandonContext();
161 } 161 }
162 162
163 } // namespace blimp 163 } // namespace blimp
OLDNEW
« no previous file with comments | « android_webview/browser/aw_render_thread_context_provider.cc ('k') | cc/test/test_in_process_context_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698