OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "android_webview/browser/test/fake_window.h" | 5 #include "android_webview/browser/test/fake_window.h" |
6 | 6 |
7 #include "android_webview/browser/browser_view_renderer.h" | 7 #include "android_webview/browser/browser_view_renderer.h" |
8 #include "android_webview/browser/child_frame.h" | 8 #include "android_webview/browser/child_frame.h" |
9 #include "android_webview/browser/render_thread_manager.h" | 9 #include "android_webview/browser/render_thread_manager.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "ui/gl/gl_bindings.h" | 14 #include "ui/gl/gl_bindings.h" |
| 15 #include "ui/gl/init/gl_factory.h" |
15 | 16 |
16 namespace android_webview { | 17 namespace android_webview { |
17 | 18 |
18 class FakeWindow::ScopedMakeCurrent { | 19 class FakeWindow::ScopedMakeCurrent { |
19 public: | 20 public: |
20 ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) { | 21 ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) { |
21 DCHECK(!view_root_->context_current_); | 22 DCHECK(!view_root_->context_current_); |
22 view_root_->context_current_ = true; | 23 view_root_->context_current_ = true; |
23 bool result = view_root_->context_->MakeCurrent(view_root_->surface_.get()); | 24 bool result = view_root_->context_->MakeCurrent(view_root_->surface_.get()); |
24 DCHECK(result); | 25 DCHECK(result); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 base::WaitableEvent completion(true, false); | 187 base::WaitableEvent completion(true, false); |
187 render_thread_loop_->PostTask( | 188 render_thread_loop_->PostTask( |
188 FROM_HERE, base::Bind(&FakeWindow::InitializeOnRT, base::Unretained(this), | 189 FROM_HERE, base::Bind(&FakeWindow::InitializeOnRT, base::Unretained(this), |
189 &completion)); | 190 &completion)); |
190 completion.Wait(); | 191 completion.Wait(); |
191 } | 192 } |
192 | 193 |
193 void FakeWindow::InitializeOnRT(base::WaitableEvent* sync) { | 194 void FakeWindow::InitializeOnRT(base::WaitableEvent* sync) { |
194 CheckCurrentlyOnRT(); | 195 CheckCurrentlyOnRT(); |
195 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(surface_size_); | 196 surface_ = gl::init::CreateOffscreenGLSurface(surface_size_); |
196 DCHECK(surface_); | 197 DCHECK(surface_); |
197 DCHECK(surface_->GetHandle()); | 198 DCHECK(surface_->GetHandle()); |
198 context_ = gfx::GLContext::CreateGLContext(nullptr, surface_.get(), | 199 context_ = gl::init::CreateGLContext(nullptr, surface_.get(), |
199 gfx::PreferDiscreteGpu); | 200 gfx::PreferDiscreteGpu); |
200 DCHECK(context_); | 201 DCHECK(context_); |
201 sync->Signal(); | 202 sync->Signal(); |
202 } | 203 } |
203 | 204 |
204 void FakeWindow::DestroyOnRT(base::WaitableEvent* sync) { | 205 void FakeWindow::DestroyOnRT(base::WaitableEvent* sync) { |
205 CheckCurrentlyOnRT(); | 206 CheckCurrentlyOnRT(); |
206 if (context_) { | 207 if (context_) { |
207 DCHECK(!context_->IsCurrent(surface_.get())); | 208 DCHECK(!context_->IsCurrent(surface_.get())); |
208 context_ = nullptr; | 209 context_ = nullptr; |
209 surface_ = nullptr; | 210 surface_ = nullptr; |
210 } | 211 } |
211 sync->Signal(); | 212 sync->Signal(); |
212 } | 213 } |
213 | 214 |
214 void FakeWindow::CheckCurrentlyOnRT() { | 215 void FakeWindow::CheckCurrentlyOnRT() { |
215 DCHECK(rt_checker_.CalledOnValidSequencedThread()); | 216 DCHECK(rt_checker_.CalledOnValidSequencedThread()); |
216 } | 217 } |
217 | 218 |
218 } // namespace android_webview | 219 } // namespace android_webview |
OLD | NEW |