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

Side by Side Diff: blimp/client/app/compositor/browser_compositor.h

Issue 2274323002: Expose Blimp dependencies to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@khushal_baseline_1
Patch Set: Addressed Khushal's initial comments Created 4 years, 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_ 5 #ifndef BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_
6 #define BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_ 6 #define BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/weak_ptr.h"
10 #include "cc/trees/layer_tree_host_client.h" 11 #include "cc/trees/layer_tree_host_client.h"
11 #include "cc/trees/layer_tree_host_single_thread_client.h" 12 #include "cc/trees/layer_tree_host_single_thread_client.h"
12 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
14 15
15 namespace cc { 16 namespace cc {
16 class Display; 17 class Display;
17 class Layer; 18 class Layer;
18 class LayerTreeHost; 19 class LayerTreeHost;
19 class SurfaceIdAllocator; 20 class SurfaceIdAllocator;
20 class SurfaceManager; 21 class SurfaceManager;
21 } // namespace cc 22 } // namespace cc
22 23
23 namespace blimp { 24 namespace blimp {
24 namespace client { 25 namespace client {
25 class BlimpGpuMemoryBufferManager; 26 class CompositorDependencies;
26 27
27 // The parent compositor that embeds the content from the BlimpCompositor for 28 // The parent compositor that embeds the content from the BlimpCompositor for
28 // the current page. 29 // the current page.
29 class BrowserCompositor : public cc::LayerTreeHostClient, 30 class BrowserCompositor : public cc::LayerTreeHostClient,
30 public cc::LayerTreeHostSingleThreadClient { 31 public cc::LayerTreeHostSingleThreadClient {
31 public: 32 public:
32 // TODO(dtrainor): Move these to the CompositorDeps and share them with the 33 explicit BrowserCompositor(CompositorDependencies* compositor_dependencies);
33 // BlimpCompositor.
34 static cc::SurfaceManager* GetSurfaceManager();
35 static BlimpGpuMemoryBufferManager* GetGpuMemoryBufferManager();
36 static uint32_t AllocateSurfaceClientId();
37
38 BrowserCompositor();
39 ~BrowserCompositor() override; 34 ~BrowserCompositor() override;
40 35
41 // Sets the layer with the content from the renderer compositor. 36 // Sets the layer with the content from the renderer compositor.
42 void SetContentLayer(scoped_refptr<cc::Layer> content_layer); 37 void SetContentLayer(scoped_refptr<cc::Layer> content_layer);
43 38
44 // Sets the size for the display. Should be in physical pixels. 39 // Sets the size for the display. Should be in physical pixels.
45 void SetSize(const gfx::Size& size_in_px); 40 void SetSize(const gfx::Size& size_in_px);
46 41
47 // Sets the widget that the |cc::Display| draws to. On proving it the widget, 42 // Sets the widget that the |cc::Display| draws to. On proving it the widget,
48 // the compositor will become visible and start drawing to the widget. When 43 // the compositor will become visible and start drawing to the widget. When
49 // the widget goes away, we become invisible and drop all resources being 44 // the widget goes away, we become invisible and drop all resources being
50 // used to draw to the screen. 45 // used to draw to the screen.
51 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); 46 void SetAcceleratedWidget(gfx::AcceleratedWidget widget);
52 47
48 // Called when the a ContextProvider has been created by the
49 // CompositorDependencies class. If |host_| is waiting on an OutputSurface
50 // this will build one for it.
51 void OnContextProviderCreated(scoped_refptr<cc::ContextProvider> provider);
52
53 // A callback to get notifed when the compositor performs a successful swap. 53 // A callback to get notifed when the compositor performs a successful swap.
54 void set_did_complete_swap_buffers_callback(base::Closure callback) { 54 void set_did_complete_swap_buffers_callback(base::Closure callback) {
55 did_complete_swap_buffers_ = callback; 55 did_complete_swap_buffers_ = callback;
56 } 56 }
57 57
58 private: 58 private:
59 // LayerTreeHostClient implementation. 59 // LayerTreeHostClient implementation.
60 void WillBeginMainFrame() override {} 60 void WillBeginMainFrame() override {}
61 void DidBeginMainFrame() override {} 61 void DidBeginMainFrame() override {}
62 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} 62 void BeginMainFrame(const cc::BeginFrameArgs& args) override {}
(...skipping 10 matching lines...) Expand all
73 void WillCommit() override {} 73 void WillCommit() override {}
74 void DidCommit() override {} 74 void DidCommit() override {}
75 void DidCommitAndDrawFrame() override {} 75 void DidCommitAndDrawFrame() override {}
76 void DidCompleteSwapBuffers() override; 76 void DidCompleteSwapBuffers() override;
77 void DidCompletePageScaleAnimation() override {} 77 void DidCompletePageScaleAnimation() override {}
78 78
79 // LayerTreeHostSingleThreadClient implementation. 79 // LayerTreeHostSingleThreadClient implementation.
80 void DidPostSwapBuffers() override {} 80 void DidPostSwapBuffers() override {}
81 void DidAbortSwapBuffers() override {} 81 void DidAbortSwapBuffers() override {}
82 82
83 void HandlePendingOutputSurfaceRequest(); 83 CompositorDependencies* compositor_dependencies_;
84 84
85 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 85 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
86 gfx::AcceleratedWidget widget_; 86 gfx::AcceleratedWidget widget_;
87 bool output_surface_request_pending_; 87 bool output_surface_request_pending_;
88 std::unique_ptr<cc::Display> display_; 88 std::unique_ptr<cc::Display> display_;
89 89
90 gfx::Size viewport_size_in_px_; 90 gfx::Size viewport_size_in_px_;
91 91
92 std::unique_ptr<cc::LayerTreeHost> host_; 92 std::unique_ptr<cc::LayerTreeHost> host_;
93 scoped_refptr<cc::Layer> root_layer_; 93 scoped_refptr<cc::Layer> root_layer_;
94 94
95 base::Closure did_complete_swap_buffers_; 95 base::Closure did_complete_swap_buffers_;
96 96
97 base::WeakPtrFactory<BrowserCompositor> weak_ptr_factory_;
98
97 DISALLOW_COPY_AND_ASSIGN(BrowserCompositor); 99 DISALLOW_COPY_AND_ASSIGN(BrowserCompositor);
98 }; 100 };
99 101
100 } // namespace client 102 } // namespace client
101 } // namespace blimp 103 } // namespace blimp
102 104
103 #endif // BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_ 105 #endif // BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698