Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
| 6 | #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "base/compiler_specific.h" |
| 10 | #include "base/memory/scoped_ptr.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 11 | #include "cc/input/layer_scroll_offset_delegate.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 12 | #include "content/browser/android/in_process/synchronous_compositor_output_surface.h" |
| 13 | #include "content/port/common/input_event_ack_state.h" |
| 14 | #include "content/public/browser/android/synchronous_compositor.h" |
| 15 | #include "content/public/browser/web_contents_user_data.h" |
| 16 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 17 | namespace cc { |
| 18 | class InputHandler; |
Ben Murdoch | 9ab5563 | 2013-07-18 11:57:30 +0100 | [diff] [blame] | 19 | struct DidOverscrollParams; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 20 | } |
| 21 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 22 | namespace WebKit { |
| 23 | class WebInputEvent; |
| 24 | } |
| 25 | |
| 26 | namespace content { |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 27 | class InputHandlerManager; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 28 | |
| 29 | // The purpose of this class is to act as the intermediary between the various |
| 30 | // components that make up the 'synchronous compositor mode' implementation and |
| 31 | // expose their functionality via the SynchronousCompositor interface. |
| 32 | // This class is created on the main thread but most of the APIs are called |
| 33 | // from the Compositor thread. |
| 34 | class SynchronousCompositorImpl |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 35 | : public cc::LayerScrollOffsetDelegate, |
| 36 | public SynchronousCompositor, |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 37 | public SynchronousCompositorOutputSurfaceDelegate, |
| 38 | public WebContentsUserData<SynchronousCompositorImpl> { |
| 39 | public: |
| 40 | // When used from browser code, use both |process_id| and |routing_id|. |
| 41 | static SynchronousCompositorImpl* FromID(int process_id, int routing_id); |
| 42 | // When handling upcalls from renderer code, use this version; the process id |
| 43 | // is implicitly that of the in-process renderer. |
| 44 | static SynchronousCompositorImpl* FromRoutingID(int routing_id); |
| 45 | |
| 46 | InputEventAckState HandleInputEvent(const WebKit::WebInputEvent& input_event); |
| 47 | |
| 48 | // SynchronousCompositor |
| 49 | virtual void SetClient(SynchronousCompositorClient* compositor_client) |
| 50 | OVERRIDE; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 51 | virtual bool InitializeHwDraw( |
| 52 | scoped_refptr<gfx::GLSurface> surface) OVERRIDE; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 53 | virtual void ReleaseHwDraw() OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 54 | virtual bool DemandDrawHw( |
| 55 | gfx::Size view_size, |
| 56 | const gfx::Transform& transform, |
Ben Murdoch | fb25065 | 2013-07-31 11:42:55 +0100 | [diff] [blame] | 57 | gfx::Rect clip, |
| 58 | bool stencil_enabled) OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 59 | virtual bool DemandDrawSw(SkCanvas* canvas) OVERRIDE; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 60 | virtual void DidChangeRootLayerScrollOffset() OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 61 | |
| 62 | // SynchronousCompositorOutputSurfaceDelegate |
| 63 | virtual void DidBindOutputSurface( |
| 64 | SynchronousCompositorOutputSurface* output_surface) OVERRIDE; |
| 65 | virtual void DidDestroySynchronousOutputSurface( |
| 66 | SynchronousCompositorOutputSurface* output_surface) OVERRIDE; |
| 67 | virtual void SetContinuousInvalidate(bool enable) OVERRIDE; |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 68 | virtual void UpdateFrameMetaData( |
| 69 | const cc::CompositorFrameMetadata& frame_info) OVERRIDE; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 70 | virtual void DidActivatePendingTree() OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 71 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 72 | // LayerScrollOffsetDelegate |
| 73 | virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE; |
| 74 | virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE; |
| 75 | |
| 76 | void SetInputHandler(cc::InputHandler* input_handler); |
Ben Murdoch | 9ab5563 | 2013-07-18 11:57:30 +0100 | [diff] [blame] | 77 | void DidOverscroll(const cc::DidOverscrollParams& params); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 78 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 79 | private: |
| 80 | explicit SynchronousCompositorImpl(WebContents* contents); |
| 81 | virtual ~SynchronousCompositorImpl(); |
| 82 | friend class WebContentsUserData<SynchronousCompositorImpl>; |
| 83 | |
| 84 | void DidCreateSynchronousOutputSurface( |
| 85 | SynchronousCompositorOutputSurface* output_surface); |
| 86 | bool CalledOnValidThread() const; |
| 87 | |
| 88 | SynchronousCompositorClient* compositor_client_; |
| 89 | SynchronousCompositorOutputSurface* output_surface_; |
| 90 | WebContents* contents_; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 91 | cc::InputHandler* input_handler_; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 92 | |
| 93 | DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); |
| 94 | }; |
| 95 | |
| 96 | } // namespace content |
| 97 | |
| 98 | #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ |