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

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

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

Powered by Google App Engine
This is Rietveld 408576698