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

Side by Side Diff: android_webview/browser/shared_renderer_state.cc

Issue 255023004: Add synchronous requestDrawGL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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/shared_renderer_state.h" 5 #include "android_webview/browser/shared_renderer_state.h"
6 6
7 #include "android_webview/browser/browser_view_renderer_client.h" 7 #include "android_webview/browser/browser_view_renderer_client.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 10
11 namespace android_webview { 11 namespace android_webview {
12 12
13 DrawGLInput::DrawGLInput() : frame_id(0), width(0), height(0) {} 13 DrawGLInput::DrawGLInput() : frame_id(0), width(0), height(0) {}
14 14
15 DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {} 15 DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {}
16 16
17 SharedRendererState::SharedRendererState( 17 SharedRendererState::SharedRendererState(
18 scoped_refptr<base::MessageLoopProxy> ui_loop, 18 scoped_refptr<base::MessageLoopProxy> ui_loop,
19 BrowserViewRendererClient* client) 19 BrowserViewRendererClient* client)
20 : ui_loop_(ui_loop), 20 : ui_loop_(ui_loop),
21 client_on_ui_(client), 21 client_on_ui_(client),
22 weak_factory_on_ui_thread_(this), 22 weak_factory_on_ui_thread_(this),
23 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()) { 23 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()),
24 hardware_initialized_(false) {
24 DCHECK(ui_loop_->BelongsToCurrentThread()); 25 DCHECK(ui_loop_->BelongsToCurrentThread());
25 DCHECK(client_on_ui_); 26 DCHECK(client_on_ui_);
26 } 27 }
27 28
28 SharedRendererState::~SharedRendererState() {} 29 SharedRendererState::~SharedRendererState() {}
29 30
30 void SharedRendererState::ClientRequestDrawGL() { 31 void SharedRendererState::ClientRequestDrawGL() {
31 if (ui_loop_->BelongsToCurrentThread()) { 32 if (ui_loop_->BelongsToCurrentThread()) {
32 ClientRequestDrawGLOnUIThread(); 33 ClientRequestDrawGLOnUIThread();
33 } else { 34 } else {
34 ui_loop_->PostTask( 35 ui_loop_->PostTask(
35 FROM_HERE, 36 FROM_HERE,
36 base::Bind(&SharedRendererState::ClientRequestDrawGLOnUIThread, 37 base::Bind(&SharedRendererState::ClientRequestDrawGLOnUIThread,
37 ui_thread_weak_ptr_)); 38 ui_thread_weak_ptr_));
38 } 39 }
39 } 40 }
40 41
41 void SharedRendererState::ClientRequestDrawGLOnUIThread() { 42 void SharedRendererState::ClientRequestDrawGLOnUIThread() {
42 DCHECK(ui_loop_->BelongsToCurrentThread()); 43 DCHECK(ui_loop_->BelongsToCurrentThread());
43 if (!client_on_ui_->RequestDrawGL(NULL)) { 44 if (!client_on_ui_->RequestDrawGL(NULL, false)) {
44 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; 45 LOG(ERROR) << "Failed to request GL process. Deadlock likely";
45 } 46 }
46 } 47 }
47 48
48 void SharedRendererState::SetCompositorOnUiThread( 49 void SharedRendererState::SetCompositorOnUiThread(
49 content::SynchronousCompositor* compositor) { 50 content::SynchronousCompositor* compositor) {
50 base::AutoLock lock(lock_); 51 base::AutoLock lock(lock_);
51 DCHECK(ui_loop_->BelongsToCurrentThread()); 52 DCHECK(ui_loop_->BelongsToCurrentThread());
52 compositor_ = compositor; 53 compositor_ = compositor;
53 } 54 }
54 55
55 content::SynchronousCompositor* SharedRendererState::GetCompositor() { 56 content::SynchronousCompositor* SharedRendererState::GetCompositor() {
56 base::AutoLock lock(lock_); 57 base::AutoLock lock(lock_);
57 DCHECK(compositor_); 58 DCHECK(compositor_);
58 return compositor_; 59 return compositor_;
59 } 60 }
60 61
61 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) { 62 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) {
62 base::AutoLock lock(lock_); 63 base::AutoLock lock(lock_);
63 draw_gl_input_ = input; 64 draw_gl_input_ = input;
64 } 65 }
65 66
66 DrawGLInput SharedRendererState::GetDrawGLInput() const { 67 DrawGLInput SharedRendererState::GetDrawGLInput() const {
67 base::AutoLock lock(lock_); 68 base::AutoLock lock(lock_);
68 return draw_gl_input_; 69 return draw_gl_input_;
69 } 70 }
70 71
72 void SharedRendererState::ClearClosureQueue() {
73 base::AutoLock lock(lock_);
74 std::queue<base::Closure> empty;
75 std::swap(closure_queue_, empty);
76 }
77
78 void SharedRendererState::AppendClosure(const base::Closure& closure) {
79 base::AutoLock lock(lock_);
80 closure_queue_.push(closure);
81 }
82
83 base::Closure SharedRendererState::PopFrontClosure() {
84 base::Closure closure;
85
86 base::AutoLock lock(lock_);
87 if (!closure_queue_.empty()) {
88 closure = closure_queue_.front();
89 closure_queue_.pop();
90 }
91
92 return closure;
93 }
94
95 void SharedRendererState::SetHardwareInitialized(bool initialized) {
96 base::AutoLock lock(lock_);
97 hardware_initialized_ = initialized;
98 }
99
100 bool SharedRendererState::IsHardwareInitialized() const {
101 base::AutoLock lock(lock_);
102 return hardware_initialized_;
103 }
104
71 } // namespace android_webview 105 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/shared_renderer_state.h ('k') | android_webview/buildbot/aosp_manifest.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698