synchronous_compositor_impl.h revision 9ab5563a3196760eb381d102cbb2bc0f7abc6a50
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/basictypes.h" 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/compiler_specific.h" 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "cc/input/layer_scroll_offset_delegate.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/android/in_process/synchronous_compositor_output_surface.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/port/common/input_event_ack_state.h" 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/browser/android/synchronous_compositor.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/browser/web_contents_user_data.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 177d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)namespace cc { 187d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class InputHandler; 199ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdochstruct DidOverscrollParams; 207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} 217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace WebKit { 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class WebInputEvent; 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content { 277d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class InputHandlerManager; 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// The purpose of this class is to act as the intermediary between the various 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// components that make up the 'synchronous compositor mode' implementation and 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// expose their functionality via the SynchronousCompositor interface. 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This class is created on the main thread but most of the APIs are called 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// from the Compositor thread. 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class SynchronousCompositorImpl 357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) : public cc::LayerScrollOffsetDelegate, 367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) public SynchronousCompositor, 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public SynchronousCompositorOutputSurfaceDelegate, 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public WebContentsUserData<SynchronousCompositorImpl> { 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // When used from browser code, use both |process_id| and |routing_id|. 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static SynchronousCompositorImpl* FromID(int process_id, int routing_id); 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // When handling upcalls from renderer code, use this version; the process id 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // is implicitly that of the in-process renderer. 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static SynchronousCompositorImpl* FromRoutingID(int routing_id); 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) InputEventAckState HandleInputEvent(const WebKit::WebInputEvent& input_event); 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // SynchronousCompositor 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void SetClient(SynchronousCompositorClient* compositor_client) 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) OVERRIDE; 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual bool InitializeHwDraw() OVERRIDE; 527dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void ReleaseHwDraw() OVERRIDE; 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual bool DemandDrawHw( 54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gfx::Size view_size, 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const gfx::Transform& transform, 56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gfx::Rect clip) OVERRIDE; 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual bool DemandDrawSw(SkCanvas* canvas) OVERRIDE; 587d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual void DidChangeRootLayerScrollOffset() OVERRIDE; 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // SynchronousCompositorOutputSurfaceDelegate 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void DidBindOutputSurface( 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SynchronousCompositorOutputSurface* output_surface) OVERRIDE; 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void DidDestroySynchronousOutputSurface( 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SynchronousCompositorOutputSurface* output_surface) OVERRIDE; 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void SetContinuousInvalidate(bool enable) OVERRIDE; 665e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) virtual void UpdateFrameMetaData( 675e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) const cc::CompositorFrameMetadata& frame_info) OVERRIDE; 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 697d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // LayerScrollOffsetDelegate 707d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE; 717d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE; 727d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 737d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) void SetInputHandler(cc::InputHandler* input_handler); 749ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch void DidOverscroll(const cc::DidOverscrollParams& params); 757d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) explicit SynchronousCompositorImpl(WebContents* contents); 78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual ~SynchronousCompositorImpl(); 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) friend class WebContentsUserData<SynchronousCompositorImpl>; 80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void DidCreateSynchronousOutputSurface( 82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SynchronousCompositorOutputSurface* output_surface); 83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool CalledOnValidThread() const; 84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SynchronousCompositorClient* compositor_client_; 86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SynchronousCompositorOutputSurface* output_surface_; 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) WebContents* contents_; 887d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) cc::InputHandler* input_handler_; 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl); 91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace content 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_ 96