Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: blimp/client/compositor/blimp_compositor.h

Issue 1295243003: Initial commit of the blimp/ folder and target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address final nits. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_
6 #define BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/trees/layer_tree_host_client.h"
12 #include "cc/trees/layer_tree_settings.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/native_widget_types.h"
15
16 namespace base {
17 class SingleThreadTaskRunner;
18 class Thread;
19 }
20
21 namespace cc {
22 class LayerTreeHost;
23 }
24
25 namespace blimp {
26
27 // BlimpCompositor provides the basic framework and setup to host a
28 // LayerTreeHost (compositor). The rendering surface this compositor draws to
29 // is defined by the gfx::AcceleratedWidget returned by
30 // BlimpCompositor::GetWindow().
31 class BlimpCompositor : public cc::LayerTreeHostClient {
32 public:
33 ~BlimpCompositor() override;
34
35 void SetVisible(bool visible);
36 void SetSize(const gfx::Size& size);
37
38 // LayerTreeHostClient implementation.
39 void WillBeginMainFrame() override;
40 void DidBeginMainFrame() override;
41 void BeginMainFrame(const cc::BeginFrameArgs& args) override;
42 void BeginMainFrameNotExpectedSoon() override;
43 void Layout() override;
44 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
45 const gfx::Vector2dF& outer_delta,
46 const gfx::Vector2dF& elastic_overscroll_delta,
47 float page_scale,
48 float top_controls_delta) override;
49 void RequestNewOutputSurface() override;
50 void DidInitializeOutputSurface() override;
51 void DidFailToInitializeOutputSurface() override;
52 void WillCommit() override;
53 void DidCommit() override;
54 void DidCommitAndDrawFrame() override;
55 void DidCompleteSwapBuffers() override;
56 void DidCompletePageScaleAnimation() override;
57 void RecordFrameTimingEvents(
58 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
59 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events)
60 override;
61
62 protected:
63 // |dp_to_px| is the scale factor required to move from dp (device pixels) to
64 // px.
65 explicit BlimpCompositor(float dp_to_px);
66
67 // Returns a widget for use in constructing this compositor's OutputSurface.
68 // Will only ever be called while this compositor is visible.
69 virtual gfx::AcceleratedWidget GetWindow() = 0;
70
71 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost. Can be
72 // overridden to provide custom settings parameters.
73 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings);
74
75 private:
76 // Creates (if necessary) and returns a TaskRunner for a thread meant to run
77 // compositor rendering.
78 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner();
79
80 gfx::Size viewport_size_;
81
82 // The scale factor used to convert dp units (device independent pixels) to
83 // pixels.
84 float device_scale_factor_;
85 scoped_ptr<cc::LayerTreeHost> host_;
86 scoped_ptr<cc::LayerTreeSettings> settings_;
87
88 // Lazily created thread that will run the compositor rendering tasks.
89 scoped_ptr<base::Thread> compositor_thread_;
90
91 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor);
92 };
93
94 } // namespace blimp
95
96 #endif // BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698