Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / android / in_process / synchronous_compositor_impl.h
blob587f4a80ec2cfabec62084d569e74d71fa563da6
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.
5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/input/layer_scroll_offset_delegate.h"
14 #include "content/browser/android/in_process/synchronous_compositor_output_surface.h"
15 #include "content/common/input/input_event_ack_state.h"
16 #include "content/public/browser/android/synchronous_compositor.h"
17 #include "content/public/browser/web_contents_user_data.h"
18 #include "ipc/ipc_message.h"
20 namespace cc {
21 struct BeginFrameArgs;
22 class InputHandler;
25 namespace blink {
26 class WebInputEvent;
29 namespace content {
30 class InputHandlerManager;
31 class SynchronousCompositorExternalBeginFrameSource;
32 struct DidOverscrollParams;
34 // The purpose of this class is to act as the intermediary between the various
35 // components that make up the 'synchronous compositor mode' implementation and
36 // expose their functionality via the SynchronousCompositor interface.
37 // This class is created on the main thread but most of the APIs are called
38 // from the Compositor thread.
39 class SynchronousCompositorImpl
40 : public cc::LayerScrollOffsetDelegate,
41 public SynchronousCompositor,
42 public WebContentsUserData<SynchronousCompositorImpl> {
43 public:
44 // When used from browser code, use both |process_id| and |routing_id|.
45 static SynchronousCompositorImpl* FromID(int process_id, int routing_id);
46 // When handling upcalls from renderer code, use this version; the process id
47 // is implicitly that of the in-process renderer.
48 static SynchronousCompositorImpl* FromRoutingID(int routing_id);
50 InputEventAckState HandleInputEvent(const blink::WebInputEvent& input_event);
52 // Called by SynchronousCompositorRegistry.
53 void DidInitializeRendererObjects(
54 SynchronousCompositorOutputSurface* output_surface,
55 SynchronousCompositorExternalBeginFrameSource* begin_frame_source,
56 cc::InputHandler* input_handler);
57 void DidDestroyRendererObjects();
59 // Called by SynchronousCompositorExternalBeginFrameSource.
60 void OnNeedsBeginFramesChange(bool needs_begin_frames);
62 // Called by SynchronousCompositorOutputSurface.
63 void PostInvalidate();
65 // Called by RenderWidgetHostViewAndroid.
66 void BeginFrame(const cc::BeginFrameArgs& args);
68 // SynchronousCompositor
69 scoped_ptr<cc::CompositorFrame> DemandDrawHw(
70 gfx::Size surface_size,
71 const gfx::Transform& transform,
72 gfx::Rect viewport,
73 gfx::Rect clip,
74 gfx::Rect viewport_rect_for_tile_priority,
75 const gfx::Transform& transform_for_tile_priority) override;
76 bool DemandDrawSw(SkCanvas* canvas) override;
77 void ReturnResources(const cc::CompositorFrameAck& frame_ack) override;
78 void SetMemoryPolicy(size_t bytes_limit) override;
79 void DidChangeRootLayerScrollOffset() override;
80 void SetIsActive(bool is_active) override;
82 // LayerScrollOffsetDelegate
83 gfx::ScrollOffset GetTotalScrollOffset() override;
84 void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset,
85 const gfx::ScrollOffset& max_scroll_offset,
86 const gfx::SizeF& scrollable_size,
87 float page_scale_factor,
88 float min_page_scale_factor,
89 float max_page_scale_factor) override;
90 bool IsExternalFlingActive() const override;
92 void DidOverscroll(const DidOverscrollParams& params);
93 void DidStopFlinging();
95 private:
96 friend class WebContentsUserData<SynchronousCompositorImpl>;
97 friend class SynchronousCompositor;
98 explicit SynchronousCompositorImpl(WebContents* contents);
99 ~SynchronousCompositorImpl() override;
101 void SetClient(SynchronousCompositorClient* compositor_client);
102 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info);
103 void NotifyDidDestroyCompositorToClient();
104 void DidActivatePendingTree();
105 void DeliverMessages();
106 bool CalledOnValidThread() const;
107 void UpdateNeedsBeginFrames();
108 void SetInputHandler(cc::InputHandler* input_handler);
110 SynchronousCompositorClient* compositor_client_;
111 SynchronousCompositorOutputSurface* output_surface_;
112 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_;
113 WebContents* contents_;
114 const int routing_id_;
115 cc::InputHandler* input_handler_;
116 bool is_active_;
117 bool renderer_needs_begin_frames_;
119 base::WeakPtrFactory<SynchronousCompositorImpl> weak_ptr_factory_;
121 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorImpl);
124 } // namespace content
126 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_IMPL_H_