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

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

Issue 226363004: Global GPU memory manager for android webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Type casts and private methods in BVR. 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
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 memory_policy_dirty_(false),
24 hardware_initialized_(false) { 25 hardware_initialized_(false) {
25 DCHECK(ui_loop_->BelongsToCurrentThread()); 26 DCHECK(ui_loop_->BelongsToCurrentThread());
26 DCHECK(client_on_ui_); 27 DCHECK(client_on_ui_);
27 } 28 }
28 29
29 SharedRendererState::~SharedRendererState() {} 30 SharedRendererState::~SharedRendererState() {}
30 31
31 void SharedRendererState::ClientRequestDrawGL() { 32 void SharedRendererState::ClientRequestDrawGL() {
32 if (ui_loop_->BelongsToCurrentThread()) { 33 if (ui_loop_->BelongsToCurrentThread()) {
33 ClientRequestDrawGLOnUIThread(); 34 ClientRequestDrawGLOnUIThread();
(...skipping 18 matching lines...) Expand all
52 DCHECK(ui_loop_->BelongsToCurrentThread()); 53 DCHECK(ui_loop_->BelongsToCurrentThread());
53 compositor_ = compositor; 54 compositor_ = compositor;
54 } 55 }
55 56
56 content::SynchronousCompositor* SharedRendererState::GetCompositor() { 57 content::SynchronousCompositor* SharedRendererState::GetCompositor() {
57 base::AutoLock lock(lock_); 58 base::AutoLock lock(lock_);
58 DCHECK(compositor_); 59 DCHECK(compositor_);
59 return compositor_; 60 return compositor_;
60 } 61 }
61 62
63 void SharedRendererState::SetMemoryPolicy(
64 const content::SynchronousCompositorMemoryPolicy new_policy) {
65 base::AutoLock lock(lock_);
66 if (memory_policy_ != new_policy) {
67 memory_policy_ = new_policy;
68 memory_policy_dirty_ = true;
69 }
70 }
71
72 content::SynchronousCompositorMemoryPolicy
73 SharedRendererState::GetMemoryPolicy() const {
74 base::AutoLock lock(lock_);
75 return memory_policy_;
76 }
77
62 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) { 78 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) {
63 base::AutoLock lock(lock_); 79 base::AutoLock lock(lock_);
64 draw_gl_input_ = input; 80 draw_gl_input_ = input;
65 } 81 }
66 82
67 DrawGLInput SharedRendererState::GetDrawGLInput() const { 83 DrawGLInput SharedRendererState::GetDrawGLInput() const {
68 base::AutoLock lock(lock_); 84 base::AutoLock lock(lock_);
69 return draw_gl_input_; 85 return draw_gl_input_;
70 } 86 }
71 87
(...skipping 23 matching lines...) Expand all
95 void SharedRendererState::SetHardwareInitialized(bool initialized) { 111 void SharedRendererState::SetHardwareInitialized(bool initialized) {
96 base::AutoLock lock(lock_); 112 base::AutoLock lock(lock_);
97 hardware_initialized_ = initialized; 113 hardware_initialized_ = initialized;
98 } 114 }
99 115
100 bool SharedRendererState::IsHardwareInitialized() const { 116 bool SharedRendererState::IsHardwareInitialized() const {
101 base::AutoLock lock(lock_); 117 base::AutoLock lock(lock_);
102 return hardware_initialized_; 118 return hardware_initialized_;
103 } 119 }
104 120
121 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) {
122 base::AutoLock lock(lock_);
123 memory_policy_dirty_ = is_dirty;
124 }
125
126 bool SharedRendererState::IsMemoryPolicyDirty() const {
127 base::AutoLock lock(lock_);
128 return memory_policy_dirty_;
129 }
130
105 } // namespace android_webview 131 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/shared_renderer_state.h ('k') | android_webview/lib/main/aw_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698