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

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

Issue 408803002: aw: Release hardware onTrimMemory(MODERATE) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: auto reset Created 6 years, 5 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 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "cc/output/compositor_frame.h" 11 #include "cc/output/compositor_frame.h"
12 #include "cc/output/compositor_frame_ack.h" 12 #include "cc/output/compositor_frame_ack.h"
13 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/vector2d.h" 14 #include "ui/gfx/geometry/vector2d.h"
15 15
16 namespace cc { 16 namespace cc {
17 class CompositorFrameAck; 17 class CompositorFrameAck;
18 } 18 }
19 19
20 namespace gpu { 20 namespace gpu {
21 class GLInProcessContext; 21 class GLInProcessContext;
22 } 22 }
23 23
24 namespace android_webview { 24 namespace android_webview {
25 25
26 class BrowserViewRendererClient; 26 class BrowserViewRendererClient;
27 class InsideHardwareReleaseReset;
27 28
28 // Set by BrowserViewRenderer and read by HardwareRenderer. 29 // Set by BrowserViewRenderer and read by HardwareRenderer.
29 struct DrawGLInput { 30 struct DrawGLInput {
30 gfx::Vector2d scroll_offset; 31 gfx::Vector2d scroll_offset;
31 int width; 32 int width;
32 int height; 33 int height;
33 cc::CompositorFrame frame; 34 cc::CompositorFrame frame;
34 35
35 DrawGLInput(); 36 DrawGLInput();
36 ~DrawGLInput(); 37 ~DrawGLInput();
37 }; 38 };
38 39
39 // This class is used to pass data between UI thread and RenderThread. 40 // This class is used to pass data between UI thread and RenderThread.
40 class SharedRendererState { 41 class SharedRendererState {
41 public: 42 public:
42 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop, 43 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop,
43 BrowserViewRendererClient* client); 44 BrowserViewRendererClient* client);
44 ~SharedRendererState(); 45 ~SharedRendererState();
45 46
46 void ClientRequestDrawGL(); 47 void ClientRequestDrawGL();
47 48
48 void SetDrawGLInput(scoped_ptr<DrawGLInput> input); 49 void SetDrawGLInput(scoped_ptr<DrawGLInput> input);
49 scoped_ptr<DrawGLInput> PassDrawGLInput(); 50 scoped_ptr<DrawGLInput> PassDrawGLInput();
50 51
51 // Set by UI and read by RT. 52 bool IsInsideHardwareRelease() const;
52 void SetHardwareAllowed(bool allowed);
53 bool IsHardwareAllowed() const;
54 53
55 void SetSharedContext(gpu::GLInProcessContext* context); 54 void SetSharedContext(gpu::GLInProcessContext* context);
56 gpu::GLInProcessContext* GetSharedContext() const; 55 gpu::GLInProcessContext* GetSharedContext() const;
57 56
58 void InsertReturnedResources(const cc::ReturnedResourceArray& resources); 57 void InsertReturnedResources(const cc::ReturnedResourceArray& resources);
59 void SwapReturnedResources(cc::ReturnedResourceArray* resources); 58 void SwapReturnedResources(cc::ReturnedResourceArray* resources);
60 bool ReturnedResourcesEmpty() const; 59 bool ReturnedResourcesEmpty() const;
61 60
62 private: 61 private:
62 friend class InsideHardwareReleaseReset;
hush (inactive) 2014/07/21 23:16:14 You don't need friend class here because you have
boliu 2014/07/21 23:17:16 I moved the setter to private?
hush (inactive) 2014/07/21 23:20:07 Ahh.. yes. Thanks! lgtm On 2014/07/21 23:17:16, bo
63
63 void ClientRequestDrawGLOnUIThread(); 64 void ClientRequestDrawGLOnUIThread();
65 void SetInsideHardwareRelease(bool inside);
64 66
65 scoped_refptr<base::MessageLoopProxy> ui_loop_; 67 scoped_refptr<base::MessageLoopProxy> ui_loop_;
66 BrowserViewRendererClient* client_on_ui_; 68 BrowserViewRendererClient* client_on_ui_;
67 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; 69 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
68 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; 70 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
69 71
70 // Accessed by both UI and RT thread. 72 // Accessed by both UI and RT thread.
71 mutable base::Lock lock_; 73 mutable base::Lock lock_;
72 scoped_ptr<DrawGLInput> draw_gl_input_; 74 scoped_ptr<DrawGLInput> draw_gl_input_;
73 bool hardware_allowed_; 75 bool inside_hardware_release_;
74 gpu::GLInProcessContext* share_context_; 76 gpu::GLInProcessContext* share_context_;
75 cc::ReturnedResourceArray returned_resources_; 77 cc::ReturnedResourceArray returned_resources_;
78
79 DISALLOW_COPY_AND_ASSIGN(SharedRendererState);
80 };
81
82 class InsideHardwareReleaseReset {
83 public:
84 explicit InsideHardwareReleaseReset(
85 SharedRendererState* shared_renderer_state);
86 ~InsideHardwareReleaseReset();
87
88 private:
89 SharedRendererState* shared_renderer_state_;
90
91 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset);
76 }; 92 };
77 93
78 } // namespace android_webview 94 } // namespace android_webview
79 95
80 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 96 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
OLDNEW
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | android_webview/browser/shared_renderer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698