| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DELEGATED_FRAME_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 virtual bool DelegatedFrameHostIsVisible() const = 0; | 62 virtual bool DelegatedFrameHostIsVisible() const = 0; |
| 63 | 63 |
| 64 // Returns the color that the resize gutters should be drawn with. Takes the | 64 // Returns the color that the resize gutters should be drawn with. Takes the |
| 65 // suggested color from the current page background. | 65 // suggested color from the current page background. |
| 66 virtual SkColor DelegatedFrameHostGetGutterColor(SkColor color) const = 0; | 66 virtual SkColor DelegatedFrameHostGetGutterColor(SkColor color) const = 0; |
| 67 virtual gfx::Size DelegatedFrameHostDesiredSizeInDIP() const = 0; | 67 virtual gfx::Size DelegatedFrameHostDesiredSizeInDIP() const = 0; |
| 68 | 68 |
| 69 virtual bool DelegatedFrameCanCreateResizeLock() const = 0; | 69 virtual bool DelegatedFrameCanCreateResizeLock() const = 0; |
| 70 virtual std::unique_ptr<CompositorResizeLock> | 70 virtual std::unique_ptr<CompositorResizeLock> |
| 71 DelegatedFrameHostCreateResizeLock() = 0; | 71 DelegatedFrameHostCreateResizeLock() = 0; |
| 72 virtual void DelegatedFrameHostResizeLockWasReleased() = 0; | |
| 73 | 72 |
| 74 virtual void DelegatedFrameHostSendReclaimCompositorResources( | 73 virtual void DelegatedFrameHostSendReclaimCompositorResources( |
| 75 bool is_swap_ack, | 74 bool is_swap_ack, |
| 76 const cc::ReturnedResourceArray& resources) = 0; | 75 const cc::ReturnedResourceArray& resources) = 0; |
| 77 | 76 |
| 78 virtual void OnBeginFrame(const cc::BeginFrameArgs& args) = 0; | 77 virtual void OnBeginFrame(const cc::BeginFrameArgs& args) = 0; |
| 79 virtual bool IsAutoResizeEnabled() const = 0; | 78 virtual bool IsAutoResizeEnabled() const = 0; |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state | 81 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 friend class DelegatedFrameHostClient; | 197 friend class DelegatedFrameHostClient; |
| 199 friend class RenderWidgetHostViewAuraCopyRequestTest; | 198 friend class RenderWidgetHostViewAuraCopyRequestTest; |
| 200 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, | 199 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, |
| 201 SkippedDelegatedFrames); | 200 SkippedDelegatedFrames); |
| 202 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, | 201 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, |
| 203 DiscardDelegatedFramesWithLocking); | 202 DiscardDelegatedFramesWithLocking); |
| 204 | 203 |
| 205 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { | 204 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { |
| 206 return frame_subscriber_.get(); | 205 return frame_subscriber_.get(); |
| 207 } | 206 } |
| 208 bool ShouldCreateResizeLock(); | |
| 209 void LockResources(); | 207 void LockResources(); |
| 210 void UnlockResources(); | 208 void UnlockResources(); |
| 211 void RequestCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request); | 209 void RequestCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request); |
| 212 | 210 |
| 213 bool ShouldSkipFrame(gfx::Size size_in_dip) const; | 211 bool ShouldSkipFrame(const gfx::Size& size_in_dip); |
| 214 | 212 |
| 215 // Lazily grab a resize lock if the aura window size doesn't match the current | 213 // Lazily grab a resize lock if the aura window size doesn't match the current |
| 216 // frame size, to give time to the renderer. | 214 // frame size, to give time to the renderer. |
| 217 void MaybeCreateResizeLock(); | 215 void MaybeCreateResizeLock(); |
| 218 | 216 |
| 219 // Checks if the resize lock can be released because we received an new frame. | 217 // Checks if the resize lock can be released because we received an new frame. |
| 220 void CheckResizeLock(); | 218 void CheckResizeLock(); |
| 221 | 219 |
| 222 SkColor GetGutterColor() const; | 220 SkColor GetGutterColor() const; |
| 223 | 221 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 float current_scale_factor_; | 285 float current_scale_factor_; |
| 288 cc::ReturnedResourceArray surface_returned_resources_; | 286 cc::ReturnedResourceArray surface_returned_resources_; |
| 289 | 287 |
| 290 // This lock is the one waiting for a frame of the right size to come back | 288 // This lock is the one waiting for a frame of the right size to come back |
| 291 // from the renderer/GPU process. It is set from the moment the aura window | 289 // from the renderer/GPU process. It is set from the moment the aura window |
| 292 // got resized, to the moment we committed the renderer frame of the same | 290 // got resized, to the moment we committed the renderer frame of the same |
| 293 // size. It keeps track of the size we expect from the renderer, and locks the | 291 // size. It keeps track of the size we expect from the renderer, and locks the |
| 294 // compositor, as well as the UI for a short time to give a chance to the | 292 // compositor, as well as the UI for a short time to give a chance to the |
| 295 // renderer of producing a frame of the right size. | 293 // renderer of producing a frame of the right size. |
| 296 std::unique_ptr<CompositorResizeLock> resize_lock_; | 294 std::unique_ptr<CompositorResizeLock> resize_lock_; |
| 295 bool create_resize_lock_after_commit_ = false; |
| 296 bool allow_one_renderer_frame_during_resize_lock_ = false; |
| 297 | 297 |
| 298 // Keeps track of the current frame size. | 298 // Keeps track of the current frame size. |
| 299 gfx::Size current_frame_size_in_dip_; | 299 gfx::Size current_frame_size_in_dip_; |
| 300 | 300 |
| 301 // This lock is for waiting for a front surface to become available to draw. | 301 // This lock is for waiting for a front surface to become available to draw. |
| 302 std::unique_ptr<ui::CompositorLock> released_front_lock_; | 302 std::unique_ptr<ui::CompositorLock> released_front_lock_; |
| 303 | 303 |
| 304 enum CanLockCompositorState { | |
| 305 YES_CAN_LOCK, | |
| 306 // We locked, so at some point we'll need to kick a frame. | |
| 307 YES_DID_LOCK, | |
| 308 // No. A lock timed out, we need to kick a new frame before locking again. | |
| 309 NO_PENDING_RENDERER_FRAME, | |
| 310 // No. We've got a frame, but it hasn't been committed. | |
| 311 NO_PENDING_COMMIT, | |
| 312 }; | |
| 313 CanLockCompositorState can_lock_compositor_; | |
| 314 | |
| 315 base::TimeTicks last_draw_ended_; | 304 base::TimeTicks last_draw_ended_; |
| 316 | 305 |
| 317 // Subscriber that listens to frame presentation events. | 306 // Subscriber that listens to frame presentation events. |
| 318 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; | 307 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; |
| 319 std::vector<scoped_refptr<OwnedMailbox>> idle_frame_subscriber_textures_; | 308 std::vector<scoped_refptr<OwnedMailbox>> idle_frame_subscriber_textures_; |
| 320 | 309 |
| 321 // Callback used to pass the output request to the layer or to a function | 310 // Callback used to pass the output request to the layer or to a function |
| 322 // specified by a test. | 311 // specified by a test. |
| 323 base::Callback<void(std::unique_ptr<cc::CopyOutputRequest>)> | 312 base::Callback<void(std::unique_ptr<cc::CopyOutputRequest>)> |
| 324 request_copy_of_output_callback_for_testing_; | 313 request_copy_of_output_callback_for_testing_; |
| 325 | 314 |
| 326 // YUV readback pipeline. | 315 // YUV readback pipeline. |
| 327 std::unique_ptr<display_compositor::ReadbackYUVInterface> | 316 std::unique_ptr<display_compositor::ReadbackYUVInterface> |
| 328 yuv_readback_pipeline_; | 317 yuv_readback_pipeline_; |
| 329 | 318 |
| 330 bool needs_begin_frame_ = false; | 319 bool needs_begin_frame_ = false; |
| 331 uint32_t latest_confirmed_begin_frame_source_id_ = 0; | 320 uint32_t latest_confirmed_begin_frame_source_id_ = 0; |
| 332 uint64_t latest_confirmed_begin_frame_sequence_number_ = | 321 uint64_t latest_confirmed_begin_frame_sequence_number_ = |
| 333 cc::BeginFrameArgs::kInvalidFrameNumber; | 322 cc::BeginFrameArgs::kInvalidFrameNumber; |
| 334 | 323 |
| 335 bool has_frame_ = false; | 324 bool has_frame_ = false; |
| 336 | 325 |
| 337 std::unique_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; | 326 std::unique_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; |
| 338 }; | 327 }; |
| 339 | 328 |
| 340 } // namespace content | 329 } // namespace content |
| 341 | 330 |
| 342 #endif // CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ | 331 #endif // CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ |
| OLD | NEW |