| 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/top_controls_state.h" | 14 #include "cc/input/top_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/remote_proto_channel.h" | 20 #include "cc/trees/remote_proto_channel.h" |
| 21 #include "cc/trees/swap_promise_monitor.h" | 21 #include "cc/trees/swap_promise_monitor.h" |
| 22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 23 #include "content/renderer/gpu/compositor_dependencies.h" | 23 #include "content/renderer/gpu/compositor_dependencies.h" |
| 24 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" | 24 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 26 | 26 |
| 27 namespace ui { | 27 namespace base { |
| 28 class LatencyInfo; | 28 class CommandLine; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace cc { | 31 namespace cc { |
| 32 class CopyOutputRequest; | 32 class CopyOutputRequest; |
| 33 class InputHandler; | 33 class InputHandler; |
| 34 class Layer; | 34 class Layer; |
| 35 class LayerTreeHost; | 35 class LayerTreeHost; |
| 36 | |
| 37 namespace proto { | 36 namespace proto { |
| 38 class CompositorMessage; | 37 class CompositorMessage; |
| 39 } | 38 } |
| 39 } |
| 40 | 40 |
| 41 namespace ui { |
| 42 class LatencyInfo; |
| 41 } | 43 } |
| 42 | 44 |
| 43 namespace content { | 45 namespace content { |
| 44 | 46 |
| 45 class RenderWidgetCompositorDelegate; | 47 class RenderWidgetCompositorDelegate; |
| 46 | 48 |
| 47 class CONTENT_EXPORT RenderWidgetCompositor | 49 class CONTENT_EXPORT RenderWidgetCompositor |
| 48 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), | 50 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), |
| 49 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 51 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 50 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), | 52 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), |
| 51 NON_EXPORTED_BASE(public cc::RemoteProtoChannel) { | 53 NON_EXPORTED_BASE(public cc::RemoteProtoChannel) { |
| 52 public: | 54 public: |
| 53 // Attempt to construct and initialize a compositor instance for the widget | 55 // Attempt to construct and initialize a compositor instance for the widget |
| 54 // with the given settings. Returns NULL if initialization fails. | 56 // with the given settings. Returns NULL if initialization fails. |
| 55 static std::unique_ptr<RenderWidgetCompositor> Create( | 57 static std::unique_ptr<RenderWidgetCompositor> Create( |
| 56 RenderWidgetCompositorDelegate* delegate, | 58 RenderWidgetCompositorDelegate* delegate, |
| 57 float device_scale_factor, | 59 float device_scale_factor, |
| 58 CompositorDependencies* compositor_deps); | 60 CompositorDependencies* compositor_deps); |
| 59 | 61 |
| 60 ~RenderWidgetCompositor() override; | 62 ~RenderWidgetCompositor() override; |
| 61 | 63 |
| 64 static cc::LayerTreeSettings GenerateLayerTreeSettings( |
| 65 const base::CommandLine& cmd, |
| 66 CompositorDependencies* compositor_deps, |
| 67 float device_scale_factor); |
| 68 static cc::ManagedMemoryPolicy GetGpuMemoryPolicy( |
| 69 const cc::ManagedMemoryPolicy& policy); |
| 70 |
| 62 void SetNeverVisible(); | 71 void SetNeverVisible(); |
| 63 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); | 72 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); |
| 64 bool BeginMainFrameRequested() const; | 73 bool BeginMainFrameRequested() const; |
| 65 void SetNeedsDisplayOnAllLayers(); | 74 void SetNeedsDisplayOnAllLayers(); |
| 66 void SetRasterizeOnlyVisibleContent(); | 75 void SetRasterizeOnlyVisibleContent(); |
| 67 void SetNeedsRedrawRect(gfx::Rect damage_rect); | 76 void SetNeedsRedrawRect(gfx::Rect damage_rect); |
| 68 // Like setNeedsRedraw but forces the frame to be drawn, without early-outs. | 77 // Like setNeedsRedraw but forces the frame to be drawn, without early-outs. |
| 69 // Redraw will be forced after the next commit | 78 // Redraw will be forced after the next commit |
| 70 void SetNeedsForcedRedraw(); | 79 void SetNeedsForcedRedraw(); |
| 71 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped | 80 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 void SetNeedsCommit(); | 92 void SetNeedsCommit(); |
| 84 void NotifyInputThrottledUntilCommit(); | 93 void NotifyInputThrottledUntilCommit(); |
| 85 const cc::Layer* GetRootLayer() const; | 94 const cc::Layer* GetRootLayer() const; |
| 86 int ScheduleMicroBenchmark( | 95 int ScheduleMicroBenchmark( |
| 87 const std::string& name, | 96 const std::string& name, |
| 88 std::unique_ptr<base::Value> value, | 97 std::unique_ptr<base::Value> value, |
| 89 const base::Callback<void(std::unique_ptr<base::Value>)>& callback); | 98 const base::Callback<void(std::unique_ptr<base::Value>)>& callback); |
| 90 bool SendMessageToMicroBenchmark(int id, std::unique_ptr<base::Value> value); | 99 bool SendMessageToMicroBenchmark(int id, std::unique_ptr<base::Value> value); |
| 91 void SetSurfaceIdNamespace(uint32_t surface_id_namespace); | 100 void SetSurfaceIdNamespace(uint32_t surface_id_namespace); |
| 92 void OnHandleCompositorProto(const std::vector<uint8_t>& proto); | 101 void OnHandleCompositorProto(const std::vector<uint8_t>& proto); |
| 93 cc::ManagedMemoryPolicy GetGpuMemoryPolicy( | |
| 94 const cc::ManagedMemoryPolicy& policy); | |
| 95 void SetPaintedDeviceScaleFactor(float device_scale); | 102 void SetPaintedDeviceScaleFactor(float device_scale); |
| 96 | 103 |
| 97 // WebLayerTreeView implementation. | 104 // WebLayerTreeView implementation. |
| 98 void setRootLayer(const blink::WebLayer& layer) override; | 105 void setRootLayer(const blink::WebLayer& layer) override; |
| 99 void clearRootLayer() override; | 106 void clearRootLayer() override; |
| 100 void attachCompositorAnimationTimeline( | 107 void attachCompositorAnimationTimeline( |
| 101 cc::AnimationTimeline* compositor_timeline) override; | 108 cc::AnimationTimeline* compositor_timeline) override; |
| 102 void detachCompositorAnimationTimeline( | 109 void detachCompositorAnimationTimeline( |
| 103 cc::AnimationTimeline* compositor_timeline) override; | 110 cc::AnimationTimeline* compositor_timeline) override; |
| 104 void setViewportSize(const blink::WebSize& device_viewport_size) override; | 111 void setViewportSize(const blink::WebSize& device_viewport_size) override; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 210 |
| 204 private: | 211 private: |
| 205 void LayoutAndUpdateLayers(); | 212 void LayoutAndUpdateLayers(); |
| 206 void InvokeLayoutAndPaintCallback(); | 213 void InvokeLayoutAndPaintCallback(); |
| 207 bool CompositeIsSynchronous() const; | 214 bool CompositeIsSynchronous() const; |
| 208 void SynchronouslyComposite(); | 215 void SynchronouslyComposite(); |
| 209 | 216 |
| 210 int num_failed_recreate_attempts_; | 217 int num_failed_recreate_attempts_; |
| 211 RenderWidgetCompositorDelegate* const delegate_; | 218 RenderWidgetCompositorDelegate* const delegate_; |
| 212 CompositorDependencies* const compositor_deps_; | 219 CompositorDependencies* const compositor_deps_; |
| 220 const bool threaded_; |
| 213 std::unique_ptr<cc::LayerTreeHost> layer_tree_host_; | 221 std::unique_ptr<cc::LayerTreeHost> layer_tree_host_; |
| 214 bool never_visible_; | 222 bool never_visible_; |
| 215 | 223 |
| 216 blink::WebLayoutAndPaintAsyncCallback* layout_and_paint_async_callback_; | 224 blink::WebLayoutAndPaintAsyncCallback* layout_and_paint_async_callback_; |
| 217 std::unique_ptr<cc::CopyOutputRequest> temporary_copy_output_request_; | 225 std::unique_ptr<cc::CopyOutputRequest> temporary_copy_output_request_; |
| 218 | 226 |
| 219 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_; | 227 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_; |
| 220 | 228 |
| 221 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; | 229 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; |
| 222 }; | 230 }; |
| 223 | 231 |
| 224 } // namespace content | 232 } // namespace content |
| 225 | 233 |
| 226 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ | 234 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| OLD | NEW |