| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/input/layer_scroll_offset_delegate.h" |
| 11 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 12 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
| 12 #include "content/port/common/input_event_ack_state.h" | 13 #include "content/port/common/input_event_ack_state.h" |
| 13 #include "content/public/browser/android/synchronous_compositor.h" | 14 #include "content/public/browser/android/synchronous_compositor.h" |
| 14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 15 | 16 |
| 17 namespace cc { |
| 18 class InputHandler; |
| 19 } |
| 20 |
| 16 namespace WebKit { | 21 namespace WebKit { |
| 17 class WebInputEvent; | 22 class WebInputEvent; |
| 18 } | 23 } |
| 19 | 24 |
| 20 namespace content { | 25 namespace content { |
| 26 class InputHandlerManager; |
| 21 | 27 |
| 22 // The purpose of this class is to act as the intermediary between the various | 28 // The purpose of this class is to act as the intermediary between the various |
| 23 // components that make up the 'synchronous compositor mode' implementation and | 29 // components that make up the 'synchronous compositor mode' implementation and |
| 24 // expose their functionality via the SynchronousCompositor interface. | 30 // expose their functionality via the SynchronousCompositor interface. |
| 25 // This class is created on the main thread but most of the APIs are called | 31 // This class is created on the main thread but most of the APIs are called |
| 26 // from the Compositor thread. | 32 // from the Compositor thread. |
| 27 class SynchronousCompositorImpl | 33 class SynchronousCompositorImpl |
| 28 : public SynchronousCompositor, | 34 : public cc::LayerScrollOffsetDelegate, |
| 35 public SynchronousCompositor, |
| 29 public SynchronousCompositorOutputSurfaceDelegate, | 36 public SynchronousCompositorOutputSurfaceDelegate, |
| 30 public WebContentsUserData<SynchronousCompositorImpl> { | 37 public WebContentsUserData<SynchronousCompositorImpl> { |
| 31 public: | 38 public: |
| 32 // When used from browser code, use both |process_id| and |routing_id|. | 39 // When used from browser code, use both |process_id| and |routing_id|. |
| 33 static SynchronousCompositorImpl* FromID(int process_id, int routing_id); | 40 static SynchronousCompositorImpl* FromID(int process_id, int routing_id); |
| 34 // When handling upcalls from renderer code, use this version; the process id | 41 // When handling upcalls from renderer code, use this version; the process id |
| 35 // is implicitly that of the in-process renderer. | 42 // is implicitly that of the in-process renderer. |
| 36 static SynchronousCompositorImpl* FromRoutingID(int routing_id); | 43 static SynchronousCompositorImpl* FromRoutingID(int routing_id); |
| 37 | 44 |
| 38 InputEventAckState HandleInputEvent(const WebKit::WebInputEvent& input_event); | 45 InputEventAckState HandleInputEvent(const WebKit::WebInputEvent& input_event); |
| 39 | 46 |
| 40 // SynchronousCompositor | 47 // SynchronousCompositor |
| 41 virtual void SetClient(SynchronousCompositorClient* compositor_client) | 48 virtual void SetClient(SynchronousCompositorClient* compositor_client) |
| 42 OVERRIDE; | 49 OVERRIDE; |
| 43 virtual bool InitializeHwDraw() OVERRIDE; | 50 virtual bool InitializeHwDraw() OVERRIDE; |
| 44 virtual bool DemandDrawHw( | 51 virtual bool DemandDrawHw( |
| 45 gfx::Size view_size, | 52 gfx::Size view_size, |
| 46 const gfx::Transform& transform, | 53 const gfx::Transform& transform, |
| 47 gfx::Rect clip) OVERRIDE; | 54 gfx::Rect clip) OVERRIDE; |
| 48 virtual bool DemandDrawSw(SkCanvas* canvas) OVERRIDE; | 55 virtual bool DemandDrawSw(SkCanvas* canvas) OVERRIDE; |
| 56 virtual void DidChangeRootLayerScrollOffset() OVERRIDE; |
| 49 | 57 |
| 50 // SynchronousCompositorOutputSurfaceDelegate | 58 // SynchronousCompositorOutputSurfaceDelegate |
| 51 virtual void DidBindOutputSurface( | 59 virtual void DidBindOutputSurface( |
| 52 SynchronousCompositorOutputSurface* output_surface) OVERRIDE; | 60 SynchronousCompositorOutputSurface* output_surface) OVERRIDE; |
| 53 virtual void DidDestroySynchronousOutputSurface( | 61 virtual void DidDestroySynchronousOutputSurface( |
| 54 SynchronousCompositorOutputSurface* output_surface) OVERRIDE; | 62 SynchronousCompositorOutputSurface* output_surface) OVERRIDE; |
| 55 virtual void SetContinuousInvalidate(bool enable) OVERRIDE; | 63 virtual void SetContinuousInvalidate(bool enable) OVERRIDE; |
| 56 | 64 |
| 65 // LayerScrollOffsetDelegate |
| 66 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE; |
| 67 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE; |
| 68 |
| 69 void SetInputHandler(cc::InputHandler* input_handler); |
| 70 |
| 57 private: | 71 private: |
| 58 explicit SynchronousCompositorImpl(WebContents* contents); | 72 explicit SynchronousCompositorImpl(WebContents* contents); |
| 59 virtual ~SynchronousCompositorImpl(); | 73 virtual ~SynchronousCompositorImpl(); |
| 60 friend class WebContentsUserData<SynchronousCompositorImpl>; | 74 friend class WebContentsUserData<SynchronousCompositorImpl>; |
| 61 | 75 |
| 62 void DidCreateSynchronousOutputSurface( | 76 void DidCreateSynchronousOutputSurface( |
| 63 SynchronousCompositorOutputSurface* output_surface); | 77 SynchronousCompositorOutputSurface* output_surface); |
| 64 bool CalledOnValidThread() const; | 78 bool CalledOnValidThread() const; |
| 65 | 79 |
| 66 SynchronousCompositorClient* compositor_client_; | 80 SynchronousCompositorClient* compositor_client_; |
| 67 SynchronousCompositorOutputSurface* output_surface_; | 81 SynchronousCompositorOutputSurface* output_surface_; |
| 68 WebContents* contents_; | 82 WebContents* contents_; |
| 83 cc::InputHandler* input_handler_; |
| 69 | 84 |
| 70 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); | 85 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); |
| 71 }; | 86 }; |
| 72 | 87 |
| 73 } // namespace content | 88 } // namespace content |
| 74 | 89 |
| 75 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ | 90 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
| OLD | NEW |