| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "cc/base/swap_promise.h" | 12 #include "cc/base/swap_promise.h" |
| 13 #include "cc/base/swap_promise_monitor.h" | 13 #include "cc/base/swap_promise_monitor.h" |
| 14 #include "cc/input/top_controls_state.h" | 14 #include "cc/input/top_controls_state.h" |
| 15 #include "cc/trees/layer_tree_host_client.h" | 15 #include "cc/trees/layer_tree_host_client.h" |
| 16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 17 #include "cc/trees/layer_tree_settings.h" | 17 #include "cc/trees/layer_tree_settings.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/renderer/gpu/compositor_dependencies.h" |
| 19 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" | 20 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
| 21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| 24 struct LatencyInfo; | 25 struct LatencyInfo; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace cc { | 28 namespace cc { |
| 28 class CopyOutputRequest; | 29 class CopyOutputRequest; |
| 29 class InputHandler; | 30 class InputHandler; |
| 30 class Layer; | 31 class Layer; |
| 31 class LayerTreeHost; | 32 class LayerTreeHost; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace content { | 35 namespace content { |
| 35 class RenderWidget; | 36 class RenderWidget; |
| 36 | 37 |
| 37 class CONTENT_EXPORT RenderWidgetCompositor | 38 class CONTENT_EXPORT RenderWidgetCompositor |
| 38 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), | 39 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), |
| 39 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 40 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 40 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 41 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
| 41 public: | 42 public: |
| 42 // Attempt to construct and initialize a compositor instance for the widget | 43 // Attempt to construct and initialize a compositor instance for the widget |
| 43 // with the given settings. Returns NULL if initialization fails. | 44 // with the given settings. Returns NULL if initialization fails. |
| 44 static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget, | 45 static scoped_ptr<RenderWidgetCompositor> Create( |
| 45 bool threaded); | 46 RenderWidget* widget, |
| 47 CompositorDependencies* compositor_deps); |
| 46 | 48 |
| 47 virtual ~RenderWidgetCompositor(); | 49 virtual ~RenderWidgetCompositor(); |
| 48 | 50 |
| 49 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); | 51 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); |
| 50 bool BeginMainFrameRequested() const; | 52 bool BeginMainFrameRequested() const; |
| 51 void SetNeedsDisplayOnAllLayers(); | 53 void SetNeedsDisplayOnAllLayers(); |
| 52 void SetRasterizeOnlyVisibleContent(); | 54 void SetRasterizeOnlyVisibleContent(); |
| 53 void UpdateTopControlsState(cc::TopControlsState constraints, | 55 void UpdateTopControlsState(cc::TopControlsState constraints, |
| 54 cc::TopControlsState current, | 56 cc::TopControlsState current, |
| 55 bool animate); | 57 bool animate); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void ScheduleAnimation() override; | 158 void ScheduleAnimation() override; |
| 157 void DidPostSwapBuffers() override; | 159 void DidPostSwapBuffers() override; |
| 158 void DidAbortSwapBuffers() override; | 160 void DidAbortSwapBuffers() override; |
| 159 | 161 |
| 160 enum { | 162 enum { |
| 161 OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK = 4, | 163 OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK = 4, |
| 162 MAX_OUTPUT_SURFACE_RETRIES = 5, | 164 MAX_OUTPUT_SURFACE_RETRIES = 5, |
| 163 }; | 165 }; |
| 164 | 166 |
| 165 protected: | 167 protected: |
| 166 RenderWidgetCompositor(RenderWidget* widget, bool threaded); | 168 RenderWidgetCompositor(RenderWidget* widget, |
| 169 CompositorDependencies* compositor_deps); |
| 167 | 170 |
| 168 void Initialize(const cc::LayerTreeSettings& settings); | 171 void Initialize(); |
| 169 | 172 |
| 170 cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); } | 173 cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); } |
| 171 | 174 |
| 172 private: | 175 private: |
| 173 int num_failed_recreate_attempts_; | 176 int num_failed_recreate_attempts_; |
| 174 bool threaded_; | |
| 175 RenderWidget* widget_; | 177 RenderWidget* widget_; |
| 178 CompositorDependencies* compositor_deps_; |
| 176 scoped_ptr<cc::LayerTreeHost> layer_tree_host_; | 179 scoped_ptr<cc::LayerTreeHost> layer_tree_host_; |
| 177 | 180 |
| 178 scoped_ptr<cc::CopyOutputRequest> temporary_copy_output_request_; | 181 scoped_ptr<cc::CopyOutputRequest> temporary_copy_output_request_; |
| 179 | 182 |
| 180 bool send_v8_idle_notification_after_commit_; | 183 bool send_v8_idle_notification_after_commit_; |
| 181 base::TimeTicks begin_main_frame_time_; | 184 base::TimeTicks begin_main_frame_time_; |
| 182 // The time interval between BeginMainFrame calls, provided by the scheduler. | 185 // The time interval between BeginMainFrame calls, provided by the scheduler. |
| 183 base::TimeDelta begin_main_frame_interval_; | 186 base::TimeDelta begin_main_frame_interval_; |
| 184 | 187 |
| 185 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; | 188 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; |
| 186 }; | 189 }; |
| 187 | 190 |
| 188 } // namespace content | 191 } // namespace content |
| 189 | 192 |
| 190 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ | 193 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| OLD | NEW |