OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ | 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
14 #include "content/common/input/input_event_ack_state.h" | 14 #include "content/common/input/input_event_ack_state.h" |
15 #include "content/public/browser/android/synchronous_compositor.h" | 15 #include "content/public/browser/android/synchronous_compositor.h" |
16 #include "content/public/browser/web_contents_user_data.h" | |
17 #include "content/renderer/input/synchronous_input_handler_proxy.h" | 16 #include "content/renderer/input/synchronous_input_handler_proxy.h" |
18 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
19 | 18 |
20 namespace cc { | 19 namespace cc { |
21 struct BeginFrameArgs; | 20 struct BeginFrameArgs; |
22 class InputHandler; | 21 class InputHandler; |
23 } | 22 } |
24 | 23 |
25 namespace blink { | 24 namespace blink { |
26 class WebInputEvent; | 25 class WebInputEvent; |
27 } | 26 } |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 class InputHandlerManager; | 29 class InputHandlerManager; |
| 30 class RenderWidgetHostViewAndroid; |
31 class SynchronousCompositorExternalBeginFrameSource; | 31 class SynchronousCompositorExternalBeginFrameSource; |
32 struct DidOverscrollParams; | 32 struct DidOverscrollParams; |
33 | 33 |
34 // The purpose of this class is to act as the intermediary between the various | 34 // The purpose of this class is to act as the intermediary between the various |
35 // components that make up the 'synchronous compositor mode' implementation and | 35 // components that make up the 'synchronous compositor mode' implementation and |
36 // expose their functionality via the SynchronousCompositor interface. | 36 // expose their functionality via the SynchronousCompositor interface. |
37 // This class is created on the main thread but most of the APIs are called | 37 // This class is created on the main thread but most of the APIs are called |
38 // from the Compositor thread. | 38 // from the Compositor thread. |
39 class SynchronousCompositorImpl | 39 class SynchronousCompositorImpl |
40 : public SynchronousInputHandler, | 40 : public SynchronousInputHandler, |
41 public SynchronousCompositor, | 41 public SynchronousCompositor { |
42 public WebContentsUserData<SynchronousCompositorImpl> { | |
43 public: | 42 public: |
44 // When used from browser code, use both |process_id| and |routing_id|. | 43 // For handling upcalls from renderer code; the process id |
45 static SynchronousCompositorImpl* FromID(int process_id, int routing_id); | |
46 // When handling upcalls from renderer code, use this version; the process id | |
47 // is implicitly that of the in-process renderer. | 44 // is implicitly that of the in-process renderer. |
48 static SynchronousCompositorImpl* FromRoutingID(int routing_id); | 45 static SynchronousCompositorImpl* FromRoutingID(int routing_id); |
49 | 46 |
| 47 static scoped_ptr<SynchronousCompositorImpl> Create( |
| 48 RenderWidgetHostViewAndroid* rwhva, |
| 49 WebContents* web_contents); |
| 50 ~SynchronousCompositorImpl() override; |
| 51 |
50 InputEventAckState HandleInputEvent(const blink::WebInputEvent& input_event); | 52 InputEventAckState HandleInputEvent(const blink::WebInputEvent& input_event); |
51 | 53 |
52 // Called by SynchronousCompositorRegistry. | 54 // Called by SynchronousCompositorRegistry. |
53 void DidInitializeRendererObjects( | 55 void DidInitializeRendererObjects( |
54 SynchronousCompositorOutputSurface* output_surface, | 56 SynchronousCompositorOutputSurface* output_surface, |
55 SynchronousCompositorExternalBeginFrameSource* begin_frame_source, | 57 SynchronousCompositorExternalBeginFrameSource* begin_frame_source, |
56 SynchronousInputHandlerProxy* synchronous_input_handler_proxy); | 58 SynchronousInputHandlerProxy* synchronous_input_handler_proxy); |
57 void DidDestroyRendererObjects(); | 59 void DidDestroyRendererObjects(); |
58 | 60 |
59 // Called by SynchronousCompositorExternalBeginFrameSource. | 61 // Called by SynchronousCompositorExternalBeginFrameSource. |
(...skipping 27 matching lines...) Expand all Loading... |
87 const gfx::ScrollOffset& max_scroll_offset, | 89 const gfx::ScrollOffset& max_scroll_offset, |
88 const gfx::SizeF& scrollable_size, | 90 const gfx::SizeF& scrollable_size, |
89 float page_scale_factor, | 91 float page_scale_factor, |
90 float min_page_scale_factor, | 92 float min_page_scale_factor, |
91 float max_page_scale_factor) override; | 93 float max_page_scale_factor) override; |
92 | 94 |
93 void DidOverscroll(const DidOverscrollParams& params); | 95 void DidOverscroll(const DidOverscrollParams& params); |
94 void DidStopFlinging(); | 96 void DidStopFlinging(); |
95 | 97 |
96 private: | 98 private: |
97 friend class WebContentsUserData<SynchronousCompositorImpl>; | 99 SynchronousCompositorImpl(RenderWidgetHostViewAndroid* rwhva, |
98 friend class SynchronousCompositor; | 100 SynchronousCompositorClient* client); |
99 explicit SynchronousCompositorImpl(WebContents* contents); | |
100 ~SynchronousCompositorImpl() override; | |
101 | |
102 void SetClient(SynchronousCompositorClient* compositor_client); | |
103 void RegisterWithClient(); | 101 void RegisterWithClient(); |
104 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); | 102 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); |
105 void DidActivatePendingTree(); | 103 void DidActivatePendingTree(); |
106 void DeliverMessages(); | 104 void DeliverMessages(); |
107 bool CalledOnValidThread() const; | 105 bool CalledOnValidThread() const; |
108 void UpdateNeedsBeginFrames(); | 106 void UpdateNeedsBeginFrames(); |
109 | 107 |
110 SynchronousCompositorClient* compositor_client_; | 108 RenderWidgetHostViewAndroid* const rwhva_; |
| 109 const int routing_id_; |
| 110 SynchronousCompositorClient* const compositor_client_; |
111 SynchronousCompositorOutputSurface* output_surface_; | 111 SynchronousCompositorOutputSurface* output_surface_; |
112 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_; | 112 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_; |
113 WebContents* contents_; | |
114 const int routing_id_; | |
115 SynchronousInputHandlerProxy* synchronous_input_handler_proxy_; | 113 SynchronousInputHandlerProxy* synchronous_input_handler_proxy_; |
116 bool registered_with_client_; | 114 bool registered_with_client_; |
117 bool is_active_; | 115 bool is_active_; |
118 bool renderer_needs_begin_frames_; | 116 bool renderer_needs_begin_frames_; |
119 bool need_animate_input_; | 117 bool need_animate_input_; |
120 | 118 |
121 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_; | 119 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_; |
122 | 120 |
123 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); | 121 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); |
124 }; | 122 }; |
125 | 123 |
126 } // namespace content | 124 } // namespace content |
127 | 125 |
128 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ | 126 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
OLD | NEW |