| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ | 5 #ifndef CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| 6 #define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ | 6 #define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "cc/input/browser_controls_state.h" | 14 #include "cc/input/browser_controls_state.h" |
| 15 #include "cc/output/managed_memory_policy.h" | 15 #include "cc/output/managed_memory_policy.h" |
| 16 #include "cc/output/swap_promise.h" | 16 #include "cc/output/swap_promise.h" |
| 17 #include "cc/trees/layer_tree_host_client.h" | 17 #include "cc/trees/layer_tree_host_client.h" |
| 18 #include "cc/trees/layer_tree_host_single_thread_client.h" | 18 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 19 #include "cc/trees/layer_tree_settings.h" | 19 #include "cc/trees/layer_tree_settings.h" |
| 20 #include "cc/trees/swap_promise_monitor.h" | 20 #include "cc/trees/swap_promise_monitor.h" |
| 21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
| 22 #include "content/public/renderer/remote_proto_channel.h" | |
| 23 #include "content/renderer/gpu/compositor_dependencies.h" | 22 #include "content/renderer/gpu/compositor_dependencies.h" |
| 24 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" | 23 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class CommandLine; | 27 class CommandLine; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace cc { | 30 namespace cc { |
| 32 | 31 |
| 33 class AnimationHost; | 32 class AnimationHost; |
| 34 class InputHandler; | 33 class InputHandler; |
| 35 class Layer; | 34 class Layer; |
| 36 class LayerTreeHost; | 35 class LayerTreeHost; |
| 37 namespace proto { | |
| 38 class CompositorMessage; | |
| 39 } | |
| 40 } | 36 } |
| 41 | 37 |
| 42 namespace gfx { | 38 namespace gfx { |
| 43 class ColorSpace; | 39 class ColorSpace; |
| 44 } | 40 } |
| 45 | 41 |
| 46 namespace ui { | 42 namespace ui { |
| 47 class LatencyInfo; | 43 class LatencyInfo; |
| 48 } | 44 } |
| 49 | 45 |
| 50 namespace content { | 46 namespace content { |
| 51 | 47 |
| 52 class RenderWidgetCompositorDelegate; | 48 class RenderWidgetCompositorDelegate; |
| 53 struct ScreenInfo; | 49 struct ScreenInfo; |
| 54 | 50 |
| 55 class CONTENT_EXPORT RenderWidgetCompositor | 51 class CONTENT_EXPORT RenderWidgetCompositor |
| 56 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), | 52 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), |
| 57 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 53 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 58 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), | 54 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
| 59 public RemoteProtoChannel { | |
| 60 public: | 55 public: |
| 61 // Attempt to construct and initialize a compositor instance for the widget | 56 // Attempt to construct and initialize a compositor instance for the widget |
| 62 // with the given settings. Returns NULL if initialization fails. | 57 // with the given settings. Returns NULL if initialization fails. |
| 63 static std::unique_ptr<RenderWidgetCompositor> Create( | 58 static std::unique_ptr<RenderWidgetCompositor> Create( |
| 64 RenderWidgetCompositorDelegate* delegate, | 59 RenderWidgetCompositorDelegate* delegate, |
| 65 float device_scale_factor, | 60 float device_scale_factor, |
| 66 const ScreenInfo& screen_info, | 61 const ScreenInfo& screen_info, |
| 67 CompositorDependencies* compositor_deps); | 62 CompositorDependencies* compositor_deps); |
| 68 | 63 |
| 69 ~RenderWidgetCompositor() override; | 64 ~RenderWidgetCompositor() override; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 99 void SetNeedsUpdateLayers(); | 94 void SetNeedsUpdateLayers(); |
| 100 void SetNeedsCommit(); | 95 void SetNeedsCommit(); |
| 101 void NotifyInputThrottledUntilCommit(); | 96 void NotifyInputThrottledUntilCommit(); |
| 102 const cc::Layer* GetRootLayer() const; | 97 const cc::Layer* GetRootLayer() const; |
| 103 int ScheduleMicroBenchmark( | 98 int ScheduleMicroBenchmark( |
| 104 const std::string& name, | 99 const std::string& name, |
| 105 std::unique_ptr<base::Value> value, | 100 std::unique_ptr<base::Value> value, |
| 106 const base::Callback<void(std::unique_ptr<base::Value>)>& callback); | 101 const base::Callback<void(std::unique_ptr<base::Value>)>& callback); |
| 107 bool SendMessageToMicroBenchmark(int id, std::unique_ptr<base::Value> value); | 102 bool SendMessageToMicroBenchmark(int id, std::unique_ptr<base::Value> value); |
| 108 void SetFrameSinkId(const cc::FrameSinkId& frame_sink_id); | 103 void SetFrameSinkId(const cc::FrameSinkId& frame_sink_id); |
| 109 void OnHandleCompositorProto(const std::vector<uint8_t>& proto); | |
| 110 void SetPaintedDeviceScaleFactor(float device_scale); | 104 void SetPaintedDeviceScaleFactor(float device_scale); |
| 111 void SetDeviceColorSpace(const gfx::ColorSpace& color_space); | 105 void SetDeviceColorSpace(const gfx::ColorSpace& color_space); |
| 112 | 106 |
| 113 // WebLayerTreeView implementation. | 107 // WebLayerTreeView implementation. |
| 114 void setRootLayer(const blink::WebLayer& layer) override; | 108 void setRootLayer(const blink::WebLayer& layer) override; |
| 115 void clearRootLayer() override; | 109 void clearRootLayer() override; |
| 116 cc::AnimationHost* compositorAnimationHost() override; | 110 cc::AnimationHost* compositorAnimationHost() override; |
| 117 void setViewportSize(const blink::WebSize& device_viewport_size) override; | 111 void setViewportSize(const blink::WebSize& device_viewport_size) override; |
| 118 blink::WebSize getViewportSize() const override; | 112 blink::WebSize getViewportSize() const override; |
| 119 virtual blink::WebFloatPoint adjustEventPointForPinchZoom( | 113 virtual blink::WebFloatPoint adjustEventPointForPinchZoom( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void DidCommit() override; | 184 void DidCommit() override; |
| 191 void DidCommitAndDrawFrame() override; | 185 void DidCommitAndDrawFrame() override; |
| 192 void DidReceiveCompositorFrameAck() override; | 186 void DidReceiveCompositorFrameAck() override; |
| 193 void DidCompletePageScaleAnimation() override; | 187 void DidCompletePageScaleAnimation() override; |
| 194 | 188 |
| 195 // cc::LayerTreeHostSingleThreadClient implementation. | 189 // cc::LayerTreeHostSingleThreadClient implementation. |
| 196 void RequestScheduleAnimation() override; | 190 void RequestScheduleAnimation() override; |
| 197 void DidSubmitCompositorFrame() override; | 191 void DidSubmitCompositorFrame() override; |
| 198 void DidLoseCompositorFrameSink() override; | 192 void DidLoseCompositorFrameSink() override; |
| 199 | 193 |
| 200 // RemoteProtoChannel implementation. | |
| 201 void SetProtoReceiver(ProtoReceiver* receiver) override; | |
| 202 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override; | |
| 203 | |
| 204 enum { | 194 enum { |
| 205 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK = 4, | 195 COMPOSITOR_FRAME_SINK_RETRIES_BEFORE_FALLBACK = 4, |
| 206 MAX_COMPOSITOR_FRAME_SINK_RETRIES = 5, | 196 MAX_COMPOSITOR_FRAME_SINK_RETRIES = 5, |
| 207 }; | 197 }; |
| 208 | 198 |
| 209 protected: | 199 protected: |
| 210 friend class RenderViewImplScaleFactorTest; | 200 friend class RenderViewImplScaleFactorTest; |
| 211 | 201 |
| 212 RenderWidgetCompositor(RenderWidgetCompositorDelegate* delegate, | 202 RenderWidgetCompositor(RenderWidgetCompositorDelegate* delegate, |
| 213 CompositorDependencies* compositor_deps); | 203 CompositorDependencies* compositor_deps); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 224 int num_failed_recreate_attempts_; | 214 int num_failed_recreate_attempts_; |
| 225 RenderWidgetCompositorDelegate* const delegate_; | 215 RenderWidgetCompositorDelegate* const delegate_; |
| 226 CompositorDependencies* const compositor_deps_; | 216 CompositorDependencies* const compositor_deps_; |
| 227 const bool threaded_; | 217 const bool threaded_; |
| 228 std::unique_ptr<cc::AnimationHost> animation_host_; | 218 std::unique_ptr<cc::AnimationHost> animation_host_; |
| 229 std::unique_ptr<cc::LayerTreeHost> layer_tree_host_; | 219 std::unique_ptr<cc::LayerTreeHost> layer_tree_host_; |
| 230 bool never_visible_; | 220 bool never_visible_; |
| 231 | 221 |
| 232 blink::WebLayoutAndPaintAsyncCallback* layout_and_paint_async_callback_; | 222 blink::WebLayoutAndPaintAsyncCallback* layout_and_paint_async_callback_; |
| 233 | 223 |
| 234 RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_; | |
| 235 | |
| 236 cc::FrameSinkId frame_sink_id_; | 224 cc::FrameSinkId frame_sink_id_; |
| 237 | 225 |
| 238 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; | 226 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; |
| 239 }; | 227 }; |
| 240 | 228 |
| 241 } // namespace content | 229 } // namespace content |
| 242 | 230 |
| 243 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ | 231 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| OLD | NEW |