OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_H_ | 5 #ifndef CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_H_ |
6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_H_ | 6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "content/common/input/input_event_ack_state.h" | 12 #include "content/common/input/input_event_ack_state.h" |
13 #include "content/renderer/android/synchronous_compositor_output_surface.h" | 13 #include "content/renderer/android/synchronous_compositor_frame_sink.h" |
14 #include "ui/events/blink/synchronous_input_handler_proxy.h" | 14 #include "ui/events/blink/synchronous_input_handler_proxy.h" |
15 #include "ui/gfx/geometry/scroll_offset.h" | 15 #include "ui/gfx/geometry/scroll_offset.h" |
16 #include "ui/gfx/geometry/size_f.h" | 16 #include "ui/gfx/geometry/size_f.h" |
17 | 17 |
18 class SkCanvas; | 18 class SkCanvas; |
19 | 19 |
20 namespace IPC { | 20 namespace IPC { |
21 class Message; | 21 class Message; |
22 class Sender; | 22 class Sender; |
23 } // namespace IPC | 23 } // namespace IPC |
24 | 24 |
25 namespace blink { | 25 namespace blink { |
26 class WebInputEvent; | 26 class WebInputEvent; |
27 } // namespace blink | 27 } // namespace blink |
28 | 28 |
29 namespace cc { | 29 namespace cc { |
30 class CompositorFrame; | 30 class CompositorFrame; |
31 } // namespace cc | 31 } // namespace cc |
32 | 32 |
33 namespace content { | 33 namespace content { |
34 | 34 |
35 class SynchronousCompositorOutputSurface; | 35 class SynchronousCompositorFrameSink; |
36 struct SyncCompositorCommonRendererParams; | 36 struct SyncCompositorCommonRendererParams; |
37 struct SyncCompositorDemandDrawHwParams; | 37 struct SyncCompositorDemandDrawHwParams; |
38 struct SyncCompositorDemandDrawSwParams; | 38 struct SyncCompositorDemandDrawSwParams; |
39 struct SyncCompositorSetSharedMemoryParams; | 39 struct SyncCompositorSetSharedMemoryParams; |
40 | 40 |
41 class SynchronousCompositorProxy | 41 class SynchronousCompositorProxy : public ui::SynchronousInputHandler, |
42 : public ui::SynchronousInputHandler, | 42 public SynchronousCompositorFrameSinkClient { |
43 public SynchronousCompositorOutputSurfaceClient { | |
44 public: | 43 public: |
45 SynchronousCompositorProxy( | 44 SynchronousCompositorProxy( |
46 int routing_id, | 45 int routing_id, |
47 IPC::Sender* sender, | 46 IPC::Sender* sender, |
48 ui::SynchronousInputHandlerProxy* input_handler_proxy); | 47 ui::SynchronousInputHandlerProxy* input_handler_proxy); |
49 ~SynchronousCompositorProxy() override; | 48 ~SynchronousCompositorProxy() override; |
50 | 49 |
51 // ui::SynchronousInputHandler overrides. | 50 // ui::SynchronousInputHandler overrides. |
52 void SetNeedsSynchronousAnimateInput() override; | 51 void SetNeedsSynchronousAnimateInput() override; |
53 void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset, | 52 void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset, |
54 const gfx::ScrollOffset& max_scroll_offset, | 53 const gfx::ScrollOffset& max_scroll_offset, |
55 const gfx::SizeF& scrollable_size, | 54 const gfx::SizeF& scrollable_size, |
56 float page_scale_factor, | 55 float page_scale_factor, |
57 float min_page_scale_factor, | 56 float min_page_scale_factor, |
58 float max_page_scale_factor) override; | 57 float max_page_scale_factor) override; |
59 | 58 |
60 // SynchronousCompositorOutputSurfaceClient overrides. | 59 // SynchronousCompositorFrameSinkClient overrides. |
61 void DidActivatePendingTree() override; | 60 void DidActivatePendingTree() override; |
62 void Invalidate() override; | 61 void Invalidate() override; |
63 void SwapBuffers(uint32_t output_surface_id, | 62 void SwapBuffers(uint32_t compositor_frame_sink_id, |
64 cc::CompositorFrame frame) override; | 63 cc::CompositorFrame frame) override; |
65 | 64 |
66 void SetOutputSurface(SynchronousCompositorOutputSurface* output_surface); | 65 void SetCompositorFrameSink( |
| 66 SynchronousCompositorFrameSink* compositor_frame_sink); |
67 void OnMessageReceived(const IPC::Message& message); | 67 void OnMessageReceived(const IPC::Message& message); |
68 bool Send(IPC::Message* message); | 68 bool Send(IPC::Message* message); |
69 void PopulateCommonParams(SyncCompositorCommonRendererParams* params) const; | 69 void PopulateCommonParams(SyncCompositorCommonRendererParams* params) const; |
70 | 70 |
71 private: | 71 private: |
72 struct SharedMemoryWithSize; | 72 struct SharedMemoryWithSize; |
73 | 73 |
74 // IPC handlers. | 74 // IPC handlers. |
75 void OnComputeScroll(base::TimeTicks animation_time); | 75 void OnComputeScroll(base::TimeTicks animation_time); |
76 void DemandDrawHwAsync(const SyncCompositorDemandDrawHwParams& params); | 76 void DemandDrawHwAsync(const SyncCompositorDemandDrawHwParams& params); |
77 void DemandDrawHw(const SyncCompositorDemandDrawHwParams& params, | 77 void DemandDrawHw(const SyncCompositorDemandDrawHwParams& params, |
78 IPC::Message* reply_message); | 78 IPC::Message* reply_message); |
79 void SetSharedMemory( | 79 void SetSharedMemory( |
80 const SyncCompositorSetSharedMemoryParams& params, | 80 const SyncCompositorSetSharedMemoryParams& params, |
81 bool* success, | 81 bool* success, |
82 SyncCompositorCommonRendererParams* common_renderer_params); | 82 SyncCompositorCommonRendererParams* common_renderer_params); |
83 void ZeroSharedMemory(); | 83 void ZeroSharedMemory(); |
84 void DemandDrawSw(const SyncCompositorDemandDrawSwParams& params, | 84 void DemandDrawSw(const SyncCompositorDemandDrawSwParams& params, |
85 IPC::Message* reply_message); | 85 IPC::Message* reply_message); |
86 void SynchronouslyZoomBy( | 86 void SynchronouslyZoomBy( |
87 float zoom_delta, | 87 float zoom_delta, |
88 const gfx::Point& anchor, | 88 const gfx::Point& anchor, |
89 SyncCompositorCommonRendererParams* common_renderer_params); | 89 SyncCompositorCommonRendererParams* common_renderer_params); |
90 void SetScroll(const gfx::ScrollOffset& total_scroll_offset); | 90 void SetScroll(const gfx::ScrollOffset& total_scroll_offset); |
91 | 91 |
92 void SwapBuffersHwAsync(uint32_t output_surface_id, | 92 void SwapBuffersHwAsync(uint32_t compositor_frame_sink_id, |
93 cc::CompositorFrame frame); | 93 cc::CompositorFrame frame); |
94 void SwapBuffersHw(uint32_t output_surface_id, cc::CompositorFrame frame); | 94 void SwapBuffersHw(uint32_t compositor_frame_sink_id, |
| 95 cc::CompositorFrame frame); |
95 void SendDemandDrawHwReply(cc::CompositorFrame frame, | 96 void SendDemandDrawHwReply(cc::CompositorFrame frame, |
96 uint32_t output_surface_id, | 97 uint32_t compositor_frame_sink_id, |
97 IPC::Message* reply_message); | 98 IPC::Message* reply_message); |
98 void SendDemandDrawHwReplyAsync(cc::CompositorFrame frame, | 99 void SendDemandDrawHwReplyAsync(cc::CompositorFrame frame, |
99 uint32_t output_surface_id); | 100 uint32_t compositor_frame_sink_id); |
100 void DoDemandDrawSw(const SyncCompositorDemandDrawSwParams& params); | 101 void DoDemandDrawSw(const SyncCompositorDemandDrawSwParams& params); |
101 void SwapBuffersSw(cc::CompositorFrame frame); | 102 void SwapBuffersSw(cc::CompositorFrame frame); |
102 void SendDemandDrawSwReply(bool success, | 103 void SendDemandDrawSwReply(bool success, |
103 cc::CompositorFrame frame, | 104 cc::CompositorFrame frame, |
104 IPC::Message* reply_message); | 105 IPC::Message* reply_message); |
105 void SendAsyncRendererStateIfNeeded(); | 106 void SendAsyncRendererStateIfNeeded(); |
106 void DoDemandDrawHw(const SyncCompositorDemandDrawHwParams& params, | 107 void DoDemandDrawHw(const SyncCompositorDemandDrawHwParams& params, |
107 IPC::Message* reply_message); | 108 IPC::Message* reply_message); |
108 | 109 |
109 const int routing_id_; | 110 const int routing_id_; |
110 IPC::Sender* const sender_; | 111 IPC::Sender* const sender_; |
111 ui::SynchronousInputHandlerProxy* const input_handler_proxy_; | 112 ui::SynchronousInputHandlerProxy* const input_handler_proxy_; |
112 const bool use_in_process_zero_copy_software_draw_; | 113 const bool use_in_process_zero_copy_software_draw_; |
113 SynchronousCompositorOutputSurface* output_surface_; | 114 SynchronousCompositorFrameSink* compositor_frame_sink_; |
114 bool inside_receive_; | 115 bool inside_receive_; |
115 IPC::Message* hardware_draw_reply_; | 116 IPC::Message* hardware_draw_reply_; |
116 IPC::Message* software_draw_reply_; | 117 IPC::Message* software_draw_reply_; |
117 bool hardware_draw_reply_async_; | 118 bool hardware_draw_reply_async_; |
118 | 119 |
119 // From browser. | 120 // From browser. |
120 std::unique_ptr<SharedMemoryWithSize> software_draw_shm_; | 121 std::unique_ptr<SharedMemoryWithSize> software_draw_shm_; |
121 | 122 |
122 // To browser. | 123 // To browser. |
123 mutable uint32_t version_; // Mustable so PopulateCommonParams can be const. | 124 mutable uint32_t version_; // Mustable so PopulateCommonParams can be const. |
124 gfx::ScrollOffset total_scroll_offset_; // Modified by both. | 125 gfx::ScrollOffset total_scroll_offset_; // Modified by both. |
125 gfx::ScrollOffset max_scroll_offset_; | 126 gfx::ScrollOffset max_scroll_offset_; |
126 gfx::SizeF scrollable_size_; | 127 gfx::SizeF scrollable_size_; |
127 float page_scale_factor_; | 128 float page_scale_factor_; |
128 float min_page_scale_factor_; | 129 float min_page_scale_factor_; |
129 float max_page_scale_factor_; | 130 float max_page_scale_factor_; |
130 bool need_animate_scroll_; | 131 bool need_animate_scroll_; |
131 uint32_t need_invalidate_count_; | 132 uint32_t need_invalidate_count_; |
132 uint32_t did_activate_pending_tree_count_; | 133 uint32_t did_activate_pending_tree_count_; |
133 | 134 |
134 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorProxy); | 135 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorProxy); |
135 }; | 136 }; |
136 | 137 |
137 } // namespace content | 138 } // namespace content |
138 | 139 |
139 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_H_ | 140 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_H_ |
OLD | NEW |