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

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.h

Issue 2564403002: [android] Make RWHVAndroid a BeginFrameObserver. (Closed)
Patch Set: rebase Created 3 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 15 matching lines...) Expand all
26 #include "third_party/khronos/GLES2/gl2.h" 26 #include "third_party/khronos/GLES2/gl2.h"
27 #include "ui/android/context_provider_factory.h" 27 #include "ui/android/context_provider_factory.h"
28 #include "ui/android/resources/resource_manager_impl.h" 28 #include "ui/android/resources/resource_manager_impl.h"
29 #include "ui/android/resources/ui_resource_provider.h" 29 #include "ui/android/resources/ui_resource_provider.h"
30 #include "ui/android/window_android_compositor.h" 30 #include "ui/android/window_android_compositor.h"
31 31
32 struct ANativeWindow; 32 struct ANativeWindow;
33 33
34 namespace cc { 34 namespace cc {
35 class AnimationHost; 35 class AnimationHost;
36 class BeginFrameSource;
37 class Display; 36 class Display;
38 class Layer; 37 class Layer;
39 class LayerTreeHost; 38 class LayerTreeHost;
40 class OutputSurface; 39 class OutputSurface;
41 class VulkanContextProvider; 40 class VulkanContextProvider;
42 } 41 }
43 42
44 namespace content { 43 namespace content {
45 class CompositorClient; 44 class CompositorClient;
46 45
47 // ----------------------------------------------------------------------------- 46 // -----------------------------------------------------------------------------
48 // Browser-side compositor that manages a tree of content and UI layers. 47 // Browser-side compositor that manages a tree of content and UI layers.
49 // ----------------------------------------------------------------------------- 48 // -----------------------------------------------------------------------------
50 class CONTENT_EXPORT CompositorImpl 49 class CONTENT_EXPORT CompositorImpl
51 : public Compositor, 50 : public Compositor,
52 public cc::LayerTreeHostClient, 51 public cc::LayerTreeHostClient,
53 public cc::LayerTreeHostSingleThreadClient, 52 public cc::LayerTreeHostSingleThreadClient,
54 public ui::UIResourceProvider, 53 public ui::UIResourceProvider,
55 public ui::WindowAndroidCompositor { 54 public ui::WindowAndroidCompositor {
56 public: 55 public:
57 class VSyncObserver {
58 public:
59 virtual void OnVSync(base::TimeTicks timebase,
60 base::TimeDelta interval) = 0;
61 };
62
63 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); 56 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window);
64 ~CompositorImpl() override; 57 ~CompositorImpl() override;
65 58
66 static bool IsInitialized(); 59 static bool IsInitialized();
67 60
68 void AddObserver(VSyncObserver* observer);
69 void RemoveObserver(VSyncObserver* observer);
70 void OnNeedsBeginFramesChange(bool needs_begin_frames);
71
72 // ui::ResourceProvider implementation. 61 // ui::ResourceProvider implementation.
73 cc::UIResourceId CreateUIResource(cc::UIResourceClient* client) override; 62 cc::UIResourceId CreateUIResource(cc::UIResourceClient* client) override;
74 void DeleteUIResource(cc::UIResourceId resource_id) override; 63 void DeleteUIResource(cc::UIResourceId resource_id) override;
75 bool SupportsETC1NonPowerOfTwo() const override; 64 bool SupportsETC1NonPowerOfTwo() const override;
76 65
77 private: 66 private:
78 // Compositor implementation. 67 // Compositor implementation.
79 void SetRootLayer(scoped_refptr<cc::Layer> root) override; 68 void SetRootLayer(scoped_refptr<cc::Layer> root) override;
80 void SetSurface(jobject surface) override; 69 void SetSurface(jobject surface) override;
81 void setDeviceScaleFactor(float factor) override; 70 void setDeviceScaleFactor(float factor) override;
(...skipping 24 matching lines...) Expand all
106 void DidCompletePageScaleAnimation() override {} 95 void DidCompletePageScaleAnimation() override {}
107 96
108 // LayerTreeHostSingleThreadClient implementation. 97 // LayerTreeHostSingleThreadClient implementation.
109 void DidSubmitCompositorFrame() override; 98 void DidSubmitCompositorFrame() override;
110 void DidLoseCompositorFrameSink() override; 99 void DidLoseCompositorFrameSink() override;
111 100
112 // WindowAndroidCompositor implementation. 101 // WindowAndroidCompositor implementation.
113 void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) override; 102 void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) override;
114 void RequestCopyOfOutputOnRootLayer( 103 void RequestCopyOfOutputOnRootLayer(
115 std::unique_ptr<cc::CopyOutputRequest> request) override; 104 std::unique_ptr<cc::CopyOutputRequest> request) override;
116 void OnVSync(base::TimeTicks frame_time,
117 base::TimeDelta vsync_period) override;
118 void SetNeedsAnimate() override; 105 void SetNeedsAnimate() override;
119 cc::FrameSinkId GetFrameSinkId() override; 106 cc::FrameSinkId GetFrameSinkId() override;
120 107
121 void SetVisible(bool visible); 108 void SetVisible(bool visible);
122 void CreateLayerTreeHost(); 109 void CreateLayerTreeHost();
123 110
124 void HandlePendingCompositorFrameSinkRequest(); 111 void HandlePendingCompositorFrameSinkRequest();
125 112
126 #if defined(ENABLE_VULKAN) 113 #if defined(ENABLE_VULKAN)
127 void CreateVulkanOutputSurface(); 114 void CreateVulkanOutputSurface();
(...skipping 12 matching lines...) Expand all
140 cc::FrameSinkId frame_sink_id_; 127 cc::FrameSinkId frame_sink_id_;
141 128
142 // root_layer_ is the persistent internal root layer, while subroot_layer_ 129 // root_layer_ is the persistent internal root layer, while subroot_layer_
143 // is the one attached by the compositor client. 130 // is the one attached by the compositor client.
144 scoped_refptr<cc::Layer> subroot_layer_; 131 scoped_refptr<cc::Layer> subroot_layer_;
145 132
146 // Subtree for hidden layers with CopyOutputRequests on them. 133 // Subtree for hidden layers with CopyOutputRequests on them.
147 scoped_refptr<cc::Layer> readback_layer_tree_; 134 scoped_refptr<cc::Layer> readback_layer_tree_;
148 135
149 // Destruction order matters here: 136 // Destruction order matters here:
150 base::ObserverList<VSyncObserver, true> observer_list_;
151 std::unique_ptr<cc::AnimationHost> animation_host_; 137 std::unique_ptr<cc::AnimationHost> animation_host_;
152 std::unique_ptr<cc::LayerTreeHost> host_; 138 std::unique_ptr<cc::LayerTreeHost> host_;
153 ui::ResourceManagerImpl resource_manager_; 139 ui::ResourceManagerImpl resource_manager_;
154 140
155 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_;
156 std::unique_ptr<cc::Display> display_; 141 std::unique_ptr<cc::Display> display_;
157 142
158 gfx::Size size_; 143 gfx::Size size_;
159 bool has_transparent_background_; 144 bool has_transparent_background_;
160 float device_scale_factor_; 145 float device_scale_factor_;
161 146
162 ANativeWindow* window_; 147 ANativeWindow* window_;
163 gpu::SurfaceHandle surface_handle_; 148 gpu::SurfaceHandle surface_handle_;
164 149
165 CompositorClient* client_; 150 CompositorClient* client_;
166 151
167 gfx::NativeWindow root_window_; 152 gfx::NativeWindow root_window_;
168 153
169 // Whether we need to update animations on the next composite. 154 // Whether we need to update animations on the next composite.
170 bool needs_animate_; 155 bool needs_animate_;
171 156
172 // The number of SwapBuffer calls that have not returned and ACK'd from 157 // The number of SwapBuffer calls that have not returned and ACK'd from
173 // the GPU thread. 158 // the GPU thread.
174 unsigned int pending_swapbuffers_; 159 unsigned int pending_swapbuffers_;
175 160
176 size_t num_successive_context_creation_failures_; 161 size_t num_successive_context_creation_failures_;
177 162
178 // Whether there is an CompositorFrameSink request pending from the current 163 // Whether there is an CompositorFrameSink request pending from the current
179 // |host_|. Becomes |true| if RequestNewCompositorFrameSink is called, and 164 // |host_|. Becomes |true| if RequestNewCompositorFrameSink is called, and
180 // |false| if |host_| is deleted or we succeed in creating *and* initializing 165 // |false| if |host_| is deleted or we succeed in creating *and* initializing
181 // a CompositorFrameSink (which is essentially the contract with cc). 166 // a CompositorFrameSink (which is essentially the contract with cc).
182 bool compositor_frame_sink_request_pending_; 167 bool compositor_frame_sink_request_pending_;
183 168
184 gpu::Capabilities gpu_capabilities_; 169 gpu::Capabilities gpu_capabilities_;
185 bool needs_begin_frames_;
186 base::WeakPtrFactory<CompositorImpl> weak_factory_; 170 base::WeakPtrFactory<CompositorImpl> weak_factory_;
187 171
188 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); 172 DISALLOW_COPY_AND_ASSIGN(CompositorImpl);
189 }; 173 };
190 174
191 } // namespace content 175 } // namespace content
192 176
193 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 177 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698