| OLD | NEW |
| 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_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 return frame_subscriber_.get(); | 360 return frame_subscriber_.get(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 virtual bool ShouldCreateResizeLock(); | 363 virtual bool ShouldCreateResizeLock(); |
| 364 virtual scoped_ptr<ResizeLock> CreateResizeLock(bool defer_compositor_lock); | 364 virtual scoped_ptr<ResizeLock> CreateResizeLock(bool defer_compositor_lock); |
| 365 | 365 |
| 366 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); | 366 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); |
| 367 | 367 |
| 368 // Exposed for tests. | 368 // Exposed for tests. |
| 369 aura::Window* window() { return window_; } | 369 aura::Window* window() { return window_; } |
| 370 gfx::Size current_frame_size() const { return current_frame_size_; } | 370 gfx::Size current_frame_size_in_dip() const { |
| 371 return current_frame_size_in_dip_; |
| 372 } |
| 371 void LockResources(); | 373 void LockResources(); |
| 372 void UnlockResources(); | 374 void UnlockResources(); |
| 373 | 375 |
| 374 // Overridden from ui::CompositorObserver: | 376 // Overridden from ui::CompositorObserver: |
| 375 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; | 377 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; |
| 376 virtual void OnCompositingStarted(ui::Compositor* compositor, | 378 virtual void OnCompositingStarted(ui::Compositor* compositor, |
| 377 base::TimeTicks start_time) OVERRIDE; | 379 base::TimeTicks start_time) OVERRIDE; |
| 378 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; | 380 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; |
| 379 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; | 381 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; |
| 380 virtual void OnCompositingLockStateChanged( | 382 virtual void OnCompositingLockStateChanged( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // space is required by the aura::Window. | 432 // space is required by the aura::Window. |
| 431 void InternalSetBounds(const gfx::Rect& rect); | 433 void InternalSetBounds(const gfx::Rect& rect); |
| 432 | 434 |
| 433 // Lazily grab a resize lock if the aura window size doesn't match the current | 435 // Lazily grab a resize lock if the aura window size doesn't match the current |
| 434 // frame size, to give time to the renderer. | 436 // frame size, to give time to the renderer. |
| 435 void MaybeCreateResizeLock(); | 437 void MaybeCreateResizeLock(); |
| 436 | 438 |
| 437 // Checks if the resize lock can be released because we received an new frame. | 439 // Checks if the resize lock can be released because we received an new frame. |
| 438 void CheckResizeLock(); | 440 void CheckResizeLock(); |
| 439 | 441 |
| 440 void UpdateExternalTexture(); | |
| 441 ui::InputMethod* GetInputMethod() const; | 442 ui::InputMethod* GetInputMethod() const; |
| 442 | 443 |
| 443 // Returns whether the widget needs an input grab to work properly. | 444 // Returns whether the widget needs an input grab to work properly. |
| 444 bool NeedsInputGrab(); | 445 bool NeedsInputGrab(); |
| 445 | 446 |
| 446 // Confirm existing composition text in the webpage and ask the input method | 447 // Confirm existing composition text in the webpage and ask the input method |
| 447 // to cancel its ongoing composition session. | 448 // to cancel its ongoing composition session. |
| 448 void FinishImeCompositionSession(); | 449 void FinishImeCompositionSession(); |
| 449 | 450 |
| 450 // This method computes movementX/Y and keeps track of mouse location for | 451 // This method computes movementX/Y and keeps track of mouse location for |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 // Dismisses a Web Popup on a mouse or touch press outside the popup and its | 522 // Dismisses a Web Popup on a mouse or touch press outside the popup and its |
| 522 // parent. | 523 // parent. |
| 523 void ApplyEventFilterForPopupExit(ui::LocatedEvent* event); | 524 void ApplyEventFilterForPopupExit(ui::LocatedEvent* event); |
| 524 | 525 |
| 525 // Converts |rect| from window coordinate to screen coordinate. | 526 // Converts |rect| from window coordinate to screen coordinate. |
| 526 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; | 527 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; |
| 527 | 528 |
| 528 // Converts |rect| from screen coordinate to window coordinate. | 529 // Converts |rect| from screen coordinate to window coordinate. |
| 529 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; | 530 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; |
| 530 | 531 |
| 531 typedef base::Callback<void(bool, const scoped_refptr<ui::Texture>&)> | |
| 532 BufferPresentedCallback; | |
| 533 | |
| 534 // The common entry point for buffer updates from renderer | |
| 535 // and GPU process. | |
| 536 void BuffersSwapped(const gfx::Size& surface_size, | |
| 537 const gfx::Rect& damage_rect, | |
| 538 float surface_scale_factor, | |
| 539 const gpu::Mailbox& mailbox, | |
| 540 const std::vector<ui::LatencyInfo>& latency_info, | |
| 541 const BufferPresentedCallback& ack_callback); | |
| 542 | |
| 543 bool SwapBuffersPrepare(const gfx::Rect& surface_rect, | |
| 544 float surface_scale_factor, | |
| 545 const gfx::Rect& damage_rect, | |
| 546 const gpu::Mailbox& mailbox, | |
| 547 const BufferPresentedCallback& ack_callback); | |
| 548 | |
| 549 void SwapBuffersCompleted( | |
| 550 const BufferPresentedCallback& ack_callback, | |
| 551 const scoped_refptr<ui::Texture>& texture_to_return); | |
| 552 | |
| 553 void SwapDelegatedFrame( | 532 void SwapDelegatedFrame( |
| 554 uint32 output_surface_id, | 533 uint32 output_surface_id, |
| 555 scoped_ptr<cc::DelegatedFrameData> frame_data, | 534 scoped_ptr<cc::DelegatedFrameData> frame_data, |
| 556 float frame_device_scale_factor, | 535 float frame_device_scale_factor, |
| 557 const std::vector<ui::LatencyInfo>& latency_info); | 536 const std::vector<ui::LatencyInfo>& latency_info); |
| 558 void SendDelegatedFrameAck(uint32 output_surface_id); | 537 void SendDelegatedFrameAck(uint32 output_surface_id); |
| 559 void SendReturnedDelegatedResources(uint32 output_surface_id); | 538 void SendReturnedDelegatedResources(uint32 output_surface_id); |
| 560 | 539 |
| 561 // DelegatedFrameEvictorClient implementation. | 540 // DelegatedFrameEvictorClient implementation. |
| 562 virtual void EvictDelegatedFrame() OVERRIDE; | 541 virtual void EvictDelegatedFrame() OVERRIDE; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 bool has_composition_text_; | 613 bool has_composition_text_; |
| 635 | 614 |
| 636 // Whether return characters should be passed on to the RenderWidgetHostImpl. | 615 // Whether return characters should be passed on to the RenderWidgetHostImpl. |
| 637 bool accept_return_character_; | 616 bool accept_return_character_; |
| 638 | 617 |
| 639 // Current tooltip text. | 618 // Current tooltip text. |
| 640 base::string16 tooltip_; | 619 base::string16 tooltip_; |
| 641 | 620 |
| 642 std::vector<base::Closure> on_compositing_did_commit_callbacks_; | 621 std::vector<base::Closure> on_compositing_did_commit_callbacks_; |
| 643 | 622 |
| 644 // The current frontbuffer texture. | |
| 645 scoped_refptr<ui::Texture> current_surface_; | |
| 646 | |
| 647 // This holds the current software framebuffer, if any. | 623 // This holds the current software framebuffer, if any. |
| 648 scoped_ptr<SoftwareFrameManager> software_frame_manager_; | 624 scoped_ptr<SoftwareFrameManager> software_frame_manager_; |
| 649 | 625 |
| 650 // The vsync manager we are observing for changes, if any. | 626 // The vsync manager we are observing for changes, if any. |
| 651 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; | 627 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; |
| 652 | 628 |
| 653 // With delegated renderer, this is the last output surface, used to | 629 // With delegated renderer, this is the last output surface, used to |
| 654 // disambiguate resources with the same id coming from different output | 630 // disambiguate resources with the same id coming from different output |
| 655 // surfaces. | 631 // surfaces. |
| 656 uint32 last_output_surface_id_; | 632 uint32 last_output_surface_id_; |
| 657 | 633 |
| 658 // The number of delegated frame acks that are pending, to delay resource | 634 // The number of delegated frame acks that are pending, to delay resource |
| 659 // returns until the acks are sent. | 635 // returns until the acks are sent. |
| 660 int pending_delegated_ack_count_; | 636 int pending_delegated_ack_count_; |
| 661 | 637 |
| 662 // The damage in the previously presented buffer. | |
| 663 SkRegion previous_damage_; | |
| 664 | |
| 665 // Pending damage from previous frames that we skipped. | |
| 666 SkRegion skipped_damage_; | |
| 667 | |
| 668 // True after a delegated frame has been skipped, until a frame is not | 638 // True after a delegated frame has been skipped, until a frame is not |
| 669 // skipped. | 639 // skipped. |
| 670 bool skipped_frames_; | 640 bool skipped_frames_; |
| 671 | 641 |
| 672 // Holds delegated resources that have been given to a DelegatedFrameProvider, | 642 // Holds delegated resources that have been given to a DelegatedFrameProvider, |
| 673 // and gives back resources when they are no longer in use for return to the | 643 // and gives back resources when they are no longer in use for return to the |
| 674 // renderer. | 644 // renderer. |
| 675 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; | 645 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; |
| 676 | 646 |
| 677 // Provides delegated frame updates to the cc::DelegatedRendererLayer. | 647 // Provides delegated frame updates to the cc::DelegatedRendererLayer. |
| 678 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; | 648 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; |
| 679 | 649 |
| 680 // The size of the last frame that was swapped (even if we skipped it). | 650 // The size and scale of the last software compositing frame that was swapped. |
| 681 // Used to determine when the skipped_damage_ needs to be reset due to | 651 gfx::Size last_swapped_software_frame_size_; |
| 682 // size changes between front- and backbuffer. | 652 float last_swapped_software_frame_scale_factor_; |
| 683 gfx::Size last_swapped_surface_size_; | |
| 684 float last_swapped_surface_scale_factor_; | |
| 685 | 653 |
| 686 // If non-NULL we're in OnPaint() and this is the supplied canvas. | 654 // If non-NULL we're in OnPaint() and this is the supplied canvas. |
| 687 gfx::Canvas* paint_canvas_; | 655 gfx::Canvas* paint_canvas_; |
| 688 | 656 |
| 689 // Used to record the last position of the mouse. | 657 // Used to record the last position of the mouse. |
| 690 // While the mouse is locked, they store the last known position just as mouse | 658 // While the mouse is locked, they store the last known position just as mouse |
| 691 // lock was entered. | 659 // lock was entered. |
| 692 // Relative to the upper-left corner of the view. | 660 // Relative to the upper-left corner of the view. |
| 693 gfx::Point unlocked_mouse_position_; | 661 gfx::Point unlocked_mouse_position_; |
| 694 // Relative to the upper-left corner of the screen. | 662 // Relative to the upper-left corner of the screen. |
| 695 gfx::Point unlocked_global_mouse_position_; | 663 gfx::Point unlocked_global_mouse_position_; |
| 696 // Last cursor position relative to screen. Used to compute movementX/Y. | 664 // Last cursor position relative to screen. Used to compute movementX/Y. |
| 697 gfx::Point global_mouse_position_; | 665 gfx::Point global_mouse_position_; |
| 698 // In mouse locked mode, we syntheticaly move the mouse cursor to the center | 666 // In mouse locked mode, we syntheticaly move the mouse cursor to the center |
| 699 // of the window when it reaches the window borders to avoid it going outside. | 667 // of the window when it reaches the window borders to avoid it going outside. |
| 700 // This flag is used to differentiate between these synthetic mouse move | 668 // This flag is used to differentiate between these synthetic mouse move |
| 701 // events vs. normal mouse move events. | 669 // events vs. normal mouse move events. |
| 702 bool synthetic_move_sent_; | 670 bool synthetic_move_sent_; |
| 703 | 671 |
| 704 // Signals that the accelerated compositing has been turned on or off. | |
| 705 // This is used to signal to turn off the external texture as soon as the | |
| 706 // software backing store is updated. | |
| 707 bool accelerated_compositing_state_changed_; | |
| 708 | |
| 709 // This lock is the one waiting for a frame of the right size to come back | 672 // This lock is the one waiting for a frame of the right size to come back |
| 710 // from the renderer/GPU process. It is set from the moment the aura window | 673 // from the renderer/GPU process. It is set from the moment the aura window |
| 711 // got resized, to the moment we committed the renderer frame of the same | 674 // got resized, to the moment we committed the renderer frame of the same |
| 712 // size. It keeps track of the size we expect from the renderer, and locks the | 675 // size. It keeps track of the size we expect from the renderer, and locks the |
| 713 // compositor, as well as the UI for a short time to give a chance to the | 676 // compositor, as well as the UI for a short time to give a chance to the |
| 714 // renderer of producing a frame of the right size. | 677 // renderer of producing a frame of the right size. |
| 715 scoped_ptr<ResizeLock> resize_lock_; | 678 scoped_ptr<ResizeLock> resize_lock_; |
| 716 | 679 |
| 717 // Keeps track of the current frame size. | 680 // Keeps track of the current frame size. |
| 718 gfx::Size current_frame_size_; | 681 gfx::Size current_frame_size_in_dip_; |
| 719 | 682 |
| 720 // This lock is for waiting for a front surface to become available to draw. | 683 // This lock is for waiting for a front surface to become available to draw. |
| 721 scoped_refptr<ui::CompositorLock> released_front_lock_; | 684 scoped_refptr<ui::CompositorLock> released_front_lock_; |
| 722 | 685 |
| 723 // Used to track the state of the window we're created from. Only used when | 686 // Used to track the state of the window we're created from. Only used when |
| 724 // created fullscreen. | 687 // created fullscreen. |
| 725 scoped_ptr<aura::WindowTracker> host_tracker_; | 688 scoped_ptr<aura::WindowTracker> host_tracker_; |
| 726 | 689 |
| 727 enum CanLockCompositorState { | 690 enum CanLockCompositorState { |
| 728 YES, | 691 YES, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 // etc. | 755 // etc. |
| 793 scoped_ptr<content::LegacyRenderWidgetHostHWND> | 756 scoped_ptr<content::LegacyRenderWidgetHostHWND> |
| 794 legacy_render_widget_host_HWND_; | 757 legacy_render_widget_host_HWND_; |
| 795 #endif | 758 #endif |
| 796 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 759 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
| 797 }; | 760 }; |
| 798 | 761 |
| 799 } // namespace content | 762 } // namespace content |
| 800 | 763 |
| 801 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 764 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
| OLD | NEW |