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 288983007: aw: Fix hardware init/tear down in pop up flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fix 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 compositor_(NULL), 24 compositor_(NULL),
25 memory_policy_dirty_(false), 25 memory_policy_dirty_(false),
26 hardware_allowed_(false),
26 hardware_initialized_(false) { 27 hardware_initialized_(false) {
27 DCHECK(ui_loop_->BelongsToCurrentThread()); 28 DCHECK(ui_loop_->BelongsToCurrentThread());
28 DCHECK(client_on_ui_); 29 DCHECK(client_on_ui_);
29 } 30 }
30 31
31 SharedRendererState::~SharedRendererState() {} 32 SharedRendererState::~SharedRendererState() {}
32 33
33 void SharedRendererState::ClientRequestDrawGL() { 34 void SharedRendererState::ClientRequestDrawGL() {
34 if (ui_loop_->BelongsToCurrentThread()) { 35 if (ui_loop_->BelongsToCurrentThread()) {
35 ClientRequestDrawGLOnUIThread(); 36 ClientRequestDrawGLOnUIThread();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) { 80 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) {
80 base::AutoLock lock(lock_); 81 base::AutoLock lock(lock_);
81 draw_gl_input_ = input; 82 draw_gl_input_ = input;
82 } 83 }
83 84
84 DrawGLInput SharedRendererState::GetDrawGLInput() const { 85 DrawGLInput SharedRendererState::GetDrawGLInput() const {
85 base::AutoLock lock(lock_); 86 base::AutoLock lock(lock_);
86 return draw_gl_input_; 87 return draw_gl_input_;
87 } 88 }
88 89
89 void SharedRendererState::ClearClosureQueue() { 90 void SharedRendererState::SetHardwareAllowed(bool allowed) {
90 base::AutoLock lock(lock_); 91 base::AutoLock lock(lock_);
91 std::queue<base::Closure> empty; 92 hardware_allowed_ = allowed;
92 std::swap(closure_queue_, empty);
93 } 93 }
94 94
95 void SharedRendererState::AppendClosure(const base::Closure& closure) { 95 bool SharedRendererState::IsHardwareAllowed() const {
96 base::AutoLock lock(lock_); 96 base::AutoLock lock(lock_);
97 closure_queue_.push(closure); 97 return hardware_allowed_;
98 }
99
100 base::Closure SharedRendererState::PopFrontClosure() {
101 base::Closure closure;
102
103 base::AutoLock lock(lock_);
104 if (!closure_queue_.empty()) {
105 closure = closure_queue_.front();
106 closure_queue_.pop();
107 }
108
109 return closure;
110 } 98 }
111 99
112 void SharedRendererState::SetHardwareInitialized(bool initialized) { 100 void SharedRendererState::SetHardwareInitialized(bool initialized) {
113 base::AutoLock lock(lock_); 101 base::AutoLock lock(lock_);
114 hardware_initialized_ = initialized; 102 hardware_initialized_ = initialized;
115 } 103 }
116 104
117 bool SharedRendererState::IsHardwareInitialized() const { 105 bool SharedRendererState::IsHardwareInitialized() const {
118 base::AutoLock lock(lock_); 106 base::AutoLock lock(lock_);
119 return hardware_initialized_; 107 return hardware_initialized_;
120 } 108 }
121 109
122 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) { 110 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) {
123 base::AutoLock lock(lock_); 111 base::AutoLock lock(lock_);
124 memory_policy_dirty_ = is_dirty; 112 memory_policy_dirty_ = is_dirty;
125 } 113 }
126 114
127 bool SharedRendererState::IsMemoryPolicyDirty() const { 115 bool SharedRendererState::IsMemoryPolicyDirty() const {
128 base::AutoLock lock(lock_); 116 base::AutoLock lock(lock_);
129 return memory_policy_dirty_; 117 return memory_policy_dirty_;
130 } 118 }
131 119
132 } // namespace android_webview 120 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/shared_renderer_state.h ('k') | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698