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 "cc/input/layer_scroll_offset_delegate.h" | 13 #include "cc/input/layer_scroll_offset_delegate.h" |
14 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" |
15 #include "content/common/input/input_event_ack_state.h" | 15 #include "content/common/input/input_event_ack_state.h" |
16 #include "content/public/browser/android/synchronous_compositor.h" | 16 #include "content/public/browser/android/synchronous_compositor.h" |
17 #include "content/public/browser/web_contents_user_data.h" | 17 #include "content/public/browser/web_contents_user_data.h" |
18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 class BeginFrameSource; | |
21 class InputHandler; | 22 class InputHandler; |
22 } | 23 } |
23 | 24 |
24 namespace blink { | 25 namespace blink { |
25 class WebInputEvent; | 26 class WebInputEvent; |
26 } | 27 } |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 class InputHandlerManager; | 30 class InputHandlerManager; |
31 class SynchronousCompositorExternalBeginFrameSource; | |
30 struct DidOverscrollParams; | 32 struct DidOverscrollParams; |
31 | 33 |
32 // 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 |
33 // components that make up the 'synchronous compositor mode' implementation and | 35 // components that make up the 'synchronous compositor mode' implementation and |
34 // expose their functionality via the SynchronousCompositor interface. | 36 // expose their functionality via the SynchronousCompositor interface. |
35 // 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 |
36 // from the Compositor thread. | 38 // from the Compositor thread. |
37 class SynchronousCompositorImpl | 39 class SynchronousCompositorImpl |
38 : public cc::LayerScrollOffsetDelegate, | 40 : public cc::LayerScrollOffsetDelegate, |
39 public SynchronousCompositor, | 41 public SynchronousCompositor, |
40 public SynchronousCompositorOutputSurfaceDelegate, | 42 public SynchronousCompositorOutputSurfaceDelegate, |
41 public WebContentsUserData<SynchronousCompositorImpl> { | 43 public WebContentsUserData<SynchronousCompositorImpl> { |
42 public: | 44 public: |
43 // When used from browser code, use both |process_id| and |routing_id|. | 45 // When used from browser code, use both |process_id| and |routing_id|. |
44 static SynchronousCompositorImpl* FromID(int process_id, int routing_id); | 46 static SynchronousCompositorImpl* FromID(int process_id, int routing_id); |
45 // When handling upcalls from renderer code, use this version; the process id | 47 // When handling upcalls from renderer code, use this version; the process id |
46 // is implicitly that of the in-process renderer. | 48 // is implicitly that of the in-process renderer. |
47 static SynchronousCompositorImpl* FromRoutingID(int routing_id); | 49 static SynchronousCompositorImpl* FromRoutingID(int routing_id); |
48 | 50 |
49 InputEventAckState HandleInputEvent(const blink::WebInputEvent& input_event); | 51 InputEventAckState HandleInputEvent(const blink::WebInputEvent& input_event); |
50 | 52 |
53 void SetExternalBeginFrameSource( | |
boliu
2014/10/24 17:42:41
nit: Group methods called by FrameSource together,
simonhong
2014/10/29 14:47:13
Done.
| |
54 SynchronousCompositorExternalBeginFrameSource* begin_frame_source); | |
55 | |
56 void SetContinuousInvalidate(bool needs_begin_frames) const; | |
57 | |
58 bool invoking_composite() const { return invoking_composite_; } | |
59 | |
60 SynchronousCompositorOutputSurface* output_surface() const { | |
boliu
2014/10/24 17:42:41
not used, remove
simonhong
2014/10/29 14:47:13
Done.
| |
61 return output_surface_; | |
62 } | |
63 | |
51 // SynchronousCompositor | 64 // SynchronousCompositor |
52 virtual void SetClient(SynchronousCompositorClient* compositor_client) | 65 virtual void SetClient(SynchronousCompositorClient* compositor_client) |
53 override; | 66 override; |
54 virtual bool InitializeHwDraw() override; | 67 virtual bool InitializeHwDraw() override; |
55 virtual void ReleaseHwDraw() override; | 68 virtual void ReleaseHwDraw() override; |
56 virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( | 69 virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( |
57 gfx::Size surface_size, | 70 gfx::Size surface_size, |
58 const gfx::Transform& transform, | 71 const gfx::Transform& transform, |
59 gfx::Rect viewport, | 72 gfx::Rect viewport, |
60 gfx::Rect clip, | 73 gfx::Rect clip, |
61 gfx::Rect viewport_rect_for_tile_priority, | 74 gfx::Rect viewport_rect_for_tile_priority, |
62 const gfx::Transform& transform_for_tile_priority) override; | 75 const gfx::Transform& transform_for_tile_priority) override; |
63 virtual bool DemandDrawSw(SkCanvas* canvas) override; | 76 virtual bool DemandDrawSw(SkCanvas* canvas) override; |
64 virtual void ReturnResources( | 77 virtual void ReturnResources( |
65 const cc::CompositorFrameAck& frame_ack) override; | 78 const cc::CompositorFrameAck& frame_ack) override; |
66 virtual void SetMemoryPolicy( | 79 virtual void SetMemoryPolicy( |
67 const SynchronousCompositorMemoryPolicy& policy) override; | 80 const SynchronousCompositorMemoryPolicy& policy) override; |
68 virtual void DidChangeRootLayerScrollOffset() override; | 81 virtual void DidChangeRootLayerScrollOffset() override; |
69 | 82 |
70 // SynchronousCompositorOutputSurfaceDelegate | 83 // SynchronousCompositorOutputSurfaceDelegate |
71 virtual void DidBindOutputSurface( | 84 virtual void DidBindOutputSurface( |
72 SynchronousCompositorOutputSurface* output_surface) override; | 85 SynchronousCompositorOutputSurface* output_surface) override; |
73 virtual void DidDestroySynchronousOutputSurface( | 86 virtual void DidDestroySynchronousOutputSurface( |
74 SynchronousCompositorOutputSurface* output_surface) override; | 87 SynchronousCompositorOutputSurface* output_surface) override; |
75 virtual void SetContinuousInvalidate(bool enable) override; | |
76 virtual void DidActivatePendingTree() override; | 88 virtual void DidActivatePendingTree() override; |
89 virtual void RequestBeginFrame() override; | |
77 | 90 |
78 // LayerScrollOffsetDelegate | 91 // LayerScrollOffsetDelegate |
79 virtual gfx::ScrollOffset GetTotalScrollOffset() override; | 92 virtual gfx::ScrollOffset GetTotalScrollOffset() override; |
80 virtual void UpdateRootLayerState( | 93 virtual void UpdateRootLayerState( |
81 const gfx::ScrollOffset& total_scroll_offset, | 94 const gfx::ScrollOffset& total_scroll_offset, |
82 const gfx::ScrollOffset& max_scroll_offset, | 95 const gfx::ScrollOffset& max_scroll_offset, |
83 const gfx::SizeF& scrollable_size, | 96 const gfx::SizeF& scrollable_size, |
84 float page_scale_factor, | 97 float page_scale_factor, |
85 float min_page_scale_factor, | 98 float min_page_scale_factor, |
86 float max_page_scale_factor) override; | 99 float max_page_scale_factor) override; |
87 virtual bool IsExternalFlingActive() const override; | 100 virtual bool IsExternalFlingActive() const override; |
88 | 101 |
89 void SetInputHandler(cc::InputHandler* input_handler); | 102 void SetInputHandler(cc::InputHandler* input_handler); |
90 void DidOverscroll(const DidOverscrollParams& params); | 103 void DidOverscroll(const DidOverscrollParams& params); |
91 void DidStopFlinging(); | 104 void DidStopFlinging(); |
92 | 105 |
93 private: | 106 private: |
94 explicit SynchronousCompositorImpl(WebContents* contents); | 107 explicit SynchronousCompositorImpl(WebContents* contents); |
95 virtual ~SynchronousCompositorImpl(); | 108 virtual ~SynchronousCompositorImpl(); |
96 friend class WebContentsUserData<SynchronousCompositorImpl>; | 109 friend class WebContentsUserData<SynchronousCompositorImpl>; |
97 | 110 |
98 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); | 111 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); |
99 void DeliverMessages(); | 112 void DeliverMessages(); |
113 void BeginFrame() const; | |
boliu
2014/10/24 17:42:41
Not called or defined. Remove
simonhong
2014/10/29 14:47:13
Done.
| |
100 bool CalledOnValidThread() const; | 114 bool CalledOnValidThread() const; |
101 | 115 |
102 SynchronousCompositorClient* compositor_client_; | 116 SynchronousCompositorClient* compositor_client_; |
103 SynchronousCompositorOutputSurface* output_surface_; | 117 SynchronousCompositorOutputSurface* output_surface_; |
118 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_; | |
104 WebContents* contents_; | 119 WebContents* contents_; |
105 cc::InputHandler* input_handler_; | 120 cc::InputHandler* input_handler_; |
121 bool invoking_composite_; | |
106 | 122 |
107 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_; | 123 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_; |
108 | 124 |
109 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); | 125 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); |
110 }; | 126 }; |
111 | 127 |
112 } // namespace content | 128 } // namespace content |
113 | 129 |
114 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ | 130 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
OLD | NEW |