| 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 scoped_ptr<cc::BeginFrameSource> GetExternalBeginFrameSource(); |
| 54 |
| 55 bool IsInvokingComposite() const; |
| 56 |
| 57 SynchronousCompositorOutputSurface* output_surface() const { |
| 58 return output_surface_; |
| 59 } |
| 60 |
| 51 // SynchronousCompositor | 61 // SynchronousCompositor |
| 52 virtual void SetClient(SynchronousCompositorClient* compositor_client) | 62 virtual void SetClient(SynchronousCompositorClient* compositor_client) |
| 53 override; | 63 override; |
| 54 virtual bool InitializeHwDraw() override; | 64 virtual bool InitializeHwDraw() override; |
| 55 virtual void ReleaseHwDraw() override; | 65 virtual void ReleaseHwDraw() override; |
| 56 virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( | 66 virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( |
| 57 gfx::Size surface_size, | 67 gfx::Size surface_size, |
| 58 const gfx::Transform& transform, | 68 const gfx::Transform& transform, |
| 59 gfx::Rect viewport, | 69 gfx::Rect viewport, |
| 60 gfx::Rect clip, | 70 gfx::Rect clip, |
| 61 gfx::Rect viewport_rect_for_tile_priority, | 71 gfx::Rect viewport_rect_for_tile_priority, |
| 62 const gfx::Transform& transform_for_tile_priority) override; | 72 const gfx::Transform& transform_for_tile_priority) override; |
| 63 virtual bool DemandDrawSw(SkCanvas* canvas) override; | 73 virtual bool DemandDrawSw(SkCanvas* canvas) override; |
| 64 virtual void ReturnResources( | 74 virtual void ReturnResources( |
| 65 const cc::CompositorFrameAck& frame_ack) override; | 75 const cc::CompositorFrameAck& frame_ack) override; |
| 66 virtual void SetMemoryPolicy( | 76 virtual void SetMemoryPolicy( |
| 67 const SynchronousCompositorMemoryPolicy& policy) override; | 77 const SynchronousCompositorMemoryPolicy& policy) override; |
| 68 virtual void DidChangeRootLayerScrollOffset() override; | 78 virtual void DidChangeRootLayerScrollOffset() override; |
| 69 | 79 |
| 70 // SynchronousCompositorOutputSurfaceDelegate | 80 // SynchronousCompositorOutputSurfaceDelegate |
| 71 virtual void DidBindOutputSurface( | 81 virtual void DidBindOutputSurface( |
| 72 SynchronousCompositorOutputSurface* output_surface) override; | 82 SynchronousCompositorOutputSurface* output_surface) override; |
| 73 virtual void DidDestroySynchronousOutputSurface( | 83 virtual void DidDestroySynchronousOutputSurface( |
| 74 SynchronousCompositorOutputSurface* output_surface) override; | 84 SynchronousCompositorOutputSurface* output_surface) override; |
| 75 virtual void SetContinuousInvalidate(bool enable) override; | 85 virtual void UpdateContinuousInvalidate() override; |
| 76 virtual void DidActivatePendingTree() override; | 86 virtual void DidActivatePendingTree() override; |
| 87 virtual void BeginFrame() override; |
| 77 | 88 |
| 78 // LayerScrollOffsetDelegate | 89 // LayerScrollOffsetDelegate |
| 79 virtual gfx::ScrollOffset GetTotalScrollOffset() override; | 90 virtual gfx::ScrollOffset GetTotalScrollOffset() override; |
| 80 virtual void UpdateRootLayerState( | 91 virtual void UpdateRootLayerState( |
| 81 const gfx::ScrollOffset& total_scroll_offset, | 92 const gfx::ScrollOffset& total_scroll_offset, |
| 82 const gfx::ScrollOffset& max_scroll_offset, | 93 const gfx::ScrollOffset& max_scroll_offset, |
| 83 const gfx::SizeF& scrollable_size, | 94 const gfx::SizeF& scrollable_size, |
| 84 float page_scale_factor, | 95 float page_scale_factor, |
| 85 float min_page_scale_factor, | 96 float min_page_scale_factor, |
| 86 float max_page_scale_factor) override; | 97 float max_page_scale_factor) override; |
| 87 virtual bool IsExternalFlingActive() const override; | 98 virtual bool IsExternalFlingActive() const override; |
| 88 | 99 |
| 89 void SetInputHandler(cc::InputHandler* input_handler); | 100 void SetInputHandler(cc::InputHandler* input_handler); |
| 90 void DidOverscroll(const DidOverscrollParams& params); | 101 void DidOverscroll(const DidOverscrollParams& params); |
| 91 void DidStopFlinging(); | 102 void DidStopFlinging(); |
| 92 | 103 |
| 93 private: | 104 private: |
| 94 explicit SynchronousCompositorImpl(WebContents* contents); | 105 explicit SynchronousCompositorImpl(WebContents* contents); |
| 95 virtual ~SynchronousCompositorImpl(); | 106 virtual ~SynchronousCompositorImpl(); |
| 96 friend class WebContentsUserData<SynchronousCompositorImpl>; | 107 friend class WebContentsUserData<SynchronousCompositorImpl>; |
| 97 | 108 |
| 98 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); | 109 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); |
| 99 void DeliverMessages(); | 110 void DeliverMessages(); |
| 100 bool CalledOnValidThread() const; | 111 bool CalledOnValidThread() const; |
| 101 | 112 |
| 102 SynchronousCompositorClient* compositor_client_; | 113 SynchronousCompositorClient* compositor_client_; |
| 103 SynchronousCompositorOutputSurface* output_surface_; | 114 SynchronousCompositorOutputSurface* output_surface_; |
| 115 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_; |
| 104 WebContents* contents_; | 116 WebContents* contents_; |
| 105 cc::InputHandler* input_handler_; | 117 cc::InputHandler* input_handler_; |
| 106 | 118 |
| 107 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_; | 119 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_; |
| 108 | 120 |
| 109 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); | 121 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); |
| 110 }; | 122 }; |
| 111 | 123 |
| 112 } // namespace content | 124 } // namespace content |
| 113 | 125 |
| 114 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ | 126 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
| OLD | NEW |