| 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 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "ui/aura/root_window.h" | 40 #include "ui/aura/root_window.h" |
| 41 #include "ui/aura/window.h" | 41 #include "ui/aura/window.h" |
| 42 #include "ui/aura/window_observer.h" | 42 #include "ui/aura/window_observer.h" |
| 43 #include "ui/aura/window_tracker.h" | 43 #include "ui/aura/window_tracker.h" |
| 44 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 44 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 45 #include "ui/base/events/event.h" | 45 #include "ui/base/events/event.h" |
| 46 #include "ui/base/gestures/gesture_recognizer.h" | 46 #include "ui/base/gestures/gesture_recognizer.h" |
| 47 #include "ui/base/hit_test.h" | 47 #include "ui/base/hit_test.h" |
| 48 #include "ui/base/ime/input_method.h" | 48 #include "ui/base/ime/input_method.h" |
| 49 #include "ui/base/ui_base_types.h" | 49 #include "ui/base/ui_base_types.h" |
| 50 #include "ui/compositor/compositor.h" | |
| 51 #include "ui/compositor/layer.h" | 50 #include "ui/compositor/layer.h" |
| 52 #include "ui/gfx/canvas.h" | 51 #include "ui/gfx/canvas.h" |
| 53 #include "ui/gfx/display.h" | 52 #include "ui/gfx/display.h" |
| 54 #include "ui/gfx/rect_conversions.h" | 53 #include "ui/gfx/rect_conversions.h" |
| 55 #include "ui/gfx/screen.h" | 54 #include "ui/gfx/screen.h" |
| 56 #include "ui/gfx/skia_util.h" | 55 #include "ui/gfx/skia_util.h" |
| 57 | 56 |
| 58 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 59 #include "ui/base/win/hidden_window.h" | 58 #include "ui/base/win/hidden_window.h" |
| 60 #endif | 59 #endif |
| 61 | 60 |
| 61 using gfx::RectToSkIRect; |
| 62 using gfx::SkIRectToRect; |
| 63 |
| 62 using WebKit::WebScreenInfo; | 64 using WebKit::WebScreenInfo; |
| 63 using WebKit::WebTouchEvent; | 65 using WebKit::WebTouchEvent; |
| 64 | 66 |
| 65 namespace content { | 67 namespace content { |
| 66 namespace { | 68 namespace { |
| 67 | 69 |
| 68 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting | 70 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting |
| 69 // the border of the view, in order to get valid movement information. However, | 71 // the border of the view, in order to get valid movement information. However, |
| 70 // forcing the cursor back to the center of the view after each mouse move | 72 // forcing the cursor back to the center of the view after each mouse move |
| 71 // doesn't work well. It reduces the frequency of useful mouse move messages | 73 // doesn't work well. It reduces the frequency of useful mouse move messages |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 private: | 270 private: |
| 269 aura::RootWindow* root_window_; | 271 aura::RootWindow* root_window_; |
| 270 gfx::Size new_size_; | 272 gfx::Size new_size_; |
| 271 scoped_refptr<ui::CompositorLock> compositor_lock_; | 273 scoped_refptr<ui::CompositorLock> compositor_lock_; |
| 272 base::WeakPtrFactory<ResizeLock> weak_ptr_factory_; | 274 base::WeakPtrFactory<ResizeLock> weak_ptr_factory_; |
| 273 bool defer_compositor_lock_; | 275 bool defer_compositor_lock_; |
| 274 | 276 |
| 275 DISALLOW_COPY_AND_ASSIGN(ResizeLock); | 277 DISALLOW_COPY_AND_ASSIGN(ResizeLock); |
| 276 }; | 278 }; |
| 277 | 279 |
| 280 RenderWidgetHostViewAura::BufferPresentedParams::BufferPresentedParams( |
| 281 int route_id, |
| 282 int gpu_host_id, |
| 283 uint64 surface_handle) |
| 284 : route_id(route_id), |
| 285 gpu_host_id(gpu_host_id), |
| 286 surface_handle(surface_handle) { |
| 287 } |
| 288 |
| 289 RenderWidgetHostViewAura::BufferPresentedParams::~BufferPresentedParams() { |
| 290 } |
| 291 |
| 278 //////////////////////////////////////////////////////////////////////////////// | 292 //////////////////////////////////////////////////////////////////////////////// |
| 279 // RenderWidgetHostViewAura, public: | 293 // RenderWidgetHostViewAura, public: |
| 280 | 294 |
| 281 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 295 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| 282 : host_(RenderWidgetHostImpl::From(host)), | 296 : host_(RenderWidgetHostImpl::From(host)), |
| 283 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 297 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 284 in_shutdown_(false), | 298 in_shutdown_(false), |
| 285 is_fullscreen_(false), | 299 is_fullscreen_(false), |
| 286 popup_parent_host_view_(NULL), | 300 popup_parent_host_view_(NULL), |
| 287 popup_child_host_view_(NULL), | 301 popup_child_host_view_(NULL), |
| 288 is_loading_(false), | 302 is_loading_(false), |
| 289 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 303 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 290 can_compose_inline_(true), | 304 can_compose_inline_(true), |
| 291 has_composition_text_(false), | 305 has_composition_text_(false), |
| 292 device_scale_factor_(1.0f), | 306 device_scale_factor_(1.0f), |
| 293 current_surface_(0), | 307 current_surface_(0), |
| 294 current_surface_is_protected_(true), | |
| 295 current_surface_in_use_by_compositor_(true), | |
| 296 protection_state_id_(0), | |
| 297 surface_route_id_(0), | |
| 298 paint_canvas_(NULL), | 308 paint_canvas_(NULL), |
| 299 synthetic_move_sent_(false), | 309 synthetic_move_sent_(false), |
| 300 accelerated_compositing_state_changed_(false), | 310 accelerated_compositing_state_changed_(false), |
| 301 can_lock_compositor_(YES) { | 311 can_lock_compositor_(YES) { |
| 302 host_->SetView(this); | 312 host_->SetView(this); |
| 303 window_observer_.reset(new WindowObserver(this)); | 313 window_observer_.reset(new WindowObserver(this)); |
| 304 window_->AddObserver(window_observer_.get()); | 314 window_->AddObserver(window_observer_.get()); |
| 305 aura::client::SetTooltipText(window_, &tooltip_); | 315 aura::client::SetTooltipText(window_, &tooltip_); |
| 306 aura::client::SetActivationDelegate(window_, this); | 316 aura::client::SetActivationDelegate(window_, this); |
| 307 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 317 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 void RenderWidgetHostViewAura::WasShown() { | 398 void RenderWidgetHostViewAura::WasShown() { |
| 389 if (!host_->is_hidden()) | 399 if (!host_->is_hidden()) |
| 390 return; | 400 return; |
| 391 host_->WasShown(); | 401 host_->WasShown(); |
| 392 | 402 |
| 393 if (!current_surface_ && host_->is_accelerated_compositing_active() && | 403 if (!current_surface_ && host_->is_accelerated_compositing_active() && |
| 394 !released_front_lock_.get()) { | 404 !released_front_lock_.get()) { |
| 395 released_front_lock_ = GetCompositor()->GetCompositorLock(); | 405 released_front_lock_ = GetCompositor()->GetCompositorLock(); |
| 396 } | 406 } |
| 397 | 407 |
| 398 AdjustSurfaceProtection(); | |
| 399 | |
| 400 #if defined(OS_WIN) | 408 #if defined(OS_WIN) |
| 401 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 409 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 402 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 410 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
| 403 #endif | 411 #endif |
| 404 } | 412 } |
| 405 | 413 |
| 406 void RenderWidgetHostViewAura::WasHidden() { | 414 void RenderWidgetHostViewAura::WasHidden() { |
| 407 if (host_->is_hidden()) | 415 if (host_->is_hidden()) |
| 408 return; | 416 return; |
| 409 host_->WasHidden(); | 417 host_->WasHidden(); |
| 410 | 418 |
| 411 released_front_lock_ = NULL; | 419 released_front_lock_ = NULL; |
| 412 | 420 |
| 413 if (ShouldReleaseFrontSurface() && | |
| 414 host_->is_accelerated_compositing_active()) { | |
| 415 current_surface_ = 0; | |
| 416 UpdateExternalTexture(); | |
| 417 } | |
| 418 | |
| 419 AdjustSurfaceProtection(); | |
| 420 | |
| 421 #if defined(OS_WIN) | 421 #if defined(OS_WIN) |
| 422 aura::RootWindow* root_window = window_->GetRootWindow(); | 422 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 423 if (root_window) { | 423 if (root_window) { |
| 424 HWND parent = root_window->GetAcceleratedWidget(); | 424 HWND parent = root_window->GetAcceleratedWidget(); |
| 425 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 425 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 426 | 426 |
| 427 EnumChildWindows(parent, HideWindowsCallback, lparam); | 427 EnumChildWindows(parent, HideWindowsCallback, lparam); |
| 428 } | 428 } |
| 429 #endif | 429 #endif |
| 430 } | 430 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 718 |
| 719 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 719 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 720 GLHelper* gl_helper = factory->GetGLHelper(); | 720 GLHelper* gl_helper = factory->GetGLHelper(); |
| 721 if (!gl_helper) | 721 if (!gl_helper) |
| 722 return; | 722 return; |
| 723 | 723 |
| 724 unsigned char* addr = static_cast<unsigned char*>( | 724 unsigned char* addr = static_cast<unsigned char*>( |
| 725 output->GetBitmap().getPixels()); | 725 output->GetBitmap().getPixels()); |
| 726 scoped_callback_runner.Release(); | 726 scoped_callback_runner.Release(); |
| 727 // Wrap the callback with an internal handler so that we can inject our | 727 // Wrap the callback with an internal handler so that we can inject our |
| 728 // own completion handlers (where we can call AdjustSurfaceProtection). | 728 // own completion handlers (where we can try to free the frontbuffer). |
| 729 base::Callback<void(bool)> wrapper_callback = base::Bind( | 729 base::Callback<void(bool)> wrapper_callback = base::Bind( |
| 730 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished, | 730 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished, |
| 731 AsWeakPtr(), | 731 AsWeakPtr(), |
| 732 callback); | 732 callback); |
| 733 ++pending_thumbnail_tasks_; | 733 ++pending_thumbnail_tasks_; |
| 734 | 734 |
| 735 // Convert |src_subrect| from the views coordinate (upper-left origin) into | 735 // Convert |src_subrect| from the views coordinate (upper-left origin) into |
| 736 // the OpenGL coordinate (lower-left origin). | 736 // the OpenGL coordinate (lower-left origin). |
| 737 gfx::Rect src_subrect_in_gl = src_subrect; | 737 gfx::Rect src_subrect_in_gl = src_subrect; |
| 738 src_subrect_in_gl.set_y(GetViewBounds().height() - src_subrect.bottom()); | 738 src_subrect_in_gl.set_y(GetViewBounds().height() - src_subrect.bottom()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 751 // switching to software mode or receive a buffers swapped notification | 751 // switching to software mode or receive a buffers swapped notification |
| 752 // if switching to accelerated mode. | 752 // if switching to accelerated mode. |
| 753 // Sometimes (e.g. on a page load) the renderer will spuriously disable then | 753 // Sometimes (e.g. on a page load) the renderer will spuriously disable then |
| 754 // re-enable accelerated compositing, causing us to flash. | 754 // re-enable accelerated compositing, causing us to flash. |
| 755 // TODO(piman): factor the enable/disable accelerated compositing message into | 755 // TODO(piman): factor the enable/disable accelerated compositing message into |
| 756 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have | 756 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have |
| 757 // fewer inconsistent temporary states. | 757 // fewer inconsistent temporary states. |
| 758 accelerated_compositing_state_changed_ = true; | 758 accelerated_compositing_state_changed_ = true; |
| 759 } | 759 } |
| 760 | 760 |
| 761 bool RenderWidgetHostViewAura::ShouldFastACK(uint64 surface_id) { | 761 bool RenderWidgetHostViewAura::ShouldSkipFrame(const gfx::Size& size) { |
| 762 ui::Texture* container = image_transport_clients_[surface_id]; | |
| 763 DCHECK(container); | |
| 764 | |
| 765 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 762 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
| 766 can_lock_compositor_ == NO_PENDING_COMMIT || | 763 can_lock_compositor_ == NO_PENDING_COMMIT || |
| 767 resize_locks_.empty()) | 764 resize_locks_.empty()) |
| 768 return false; | 765 return false; |
| 769 | 766 |
| 770 gfx::Size container_size = ConvertSizeToDIP(this, container->size()); | 767 gfx::Size container_size = ConvertSizeToDIP(this, size); |
| 771 ResizeLockList::iterator it = resize_locks_.begin(); | 768 ResizeLockList::iterator it = resize_locks_.begin(); |
| 772 while (it != resize_locks_.end()) { | 769 while (it != resize_locks_.end()) { |
| 773 if ((*it)->expected_size() == container_size) | 770 if ((*it)->expected_size() == container_size) |
| 774 break; | 771 break; |
| 775 ++it; | 772 ++it; |
| 776 } | 773 } |
| 777 | 774 |
| 778 // We could be getting an unexpected frame due to an animation | 775 // We could be getting an unexpected frame due to an animation |
| 779 // (i.e. we start resizing but we get an old size frame first). | 776 // (i.e. we start resizing but we get an old size frame first). |
| 780 return it == resize_locks_.end() || ++it != resize_locks_.end(); | 777 return it == resize_locks_.end() || ++it != resize_locks_.end(); |
| 781 } | 778 } |
| 782 | 779 |
| 783 void RenderWidgetHostViewAura::UpdateExternalTexture() { | 780 void RenderWidgetHostViewAura::UpdateExternalTexture() { |
| 784 // Delay processing accelerated compositing state change till here where we | 781 // Delay processing accelerated compositing state change till here where we |
| 785 // act upon the state change. (Clear the external texture if switching to | 782 // act upon the state change. (Clear the external texture if switching to |
| 786 // software mode or set the external texture if going to accelerated mode). | 783 // software mode or set the external texture if going to accelerated mode). |
| 787 if (accelerated_compositing_state_changed_) | 784 if (accelerated_compositing_state_changed_) |
| 788 accelerated_compositing_state_changed_ = false; | 785 accelerated_compositing_state_changed_ = false; |
| 789 | 786 |
| 790 if (current_surface_ != 0 && host_->is_accelerated_compositing_active()) { | 787 if (current_surface_ != 0 && host_->is_accelerated_compositing_active()) { |
| 791 ui::Texture* container = image_transport_clients_[current_surface_]; | 788 ui::Texture* container = image_transport_clients_[current_surface_]; |
| 792 window_->SetExternalTexture(container); | 789 window_->SetExternalTexture(container); |
| 793 current_surface_in_use_by_compositor_ = true; | |
| 794 | 790 |
| 795 if (!container) { | 791 if (!container) { |
| 796 resize_locks_.clear(); | 792 resize_locks_.clear(); |
| 797 } else { | 793 } else { |
| 798 ResizeLockList::iterator it = resize_locks_.begin(); | 794 ResizeLockList::iterator it = resize_locks_.begin(); |
| 799 while (it != resize_locks_.end()) { | 795 while (it != resize_locks_.end()) { |
| 800 gfx::Size container_size = ConvertSizeToDIP(this, | 796 gfx::Size container_size = ConvertSizeToDIP(this, |
| 801 container->size()); | 797 container->size()); |
| 802 if ((*it)->expected_size() == container_size) | 798 if ((*it)->expected_size() == container_size) |
| 803 break; | 799 break; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 819 it2->get()->UnlockCompositor(); | 815 it2->get()->UnlockCompositor(); |
| 820 } | 816 } |
| 821 if (!compositor->HasObserver(this)) | 817 if (!compositor->HasObserver(this)) |
| 822 compositor->AddObserver(this); | 818 compositor->AddObserver(this); |
| 823 } | 819 } |
| 824 resize_locks_.erase(resize_locks_.begin(), it); | 820 resize_locks_.erase(resize_locks_.begin(), it); |
| 825 } | 821 } |
| 826 } | 822 } |
| 827 } else { | 823 } else { |
| 828 window_->SetExternalTexture(NULL); | 824 window_->SetExternalTexture(NULL); |
| 829 if (ShouldReleaseFrontSurface() && | |
| 830 host_->is_accelerated_compositing_active()) { | |
| 831 // We need to wait for a commit to clear to guarantee that all we | |
| 832 // will not issue any more GL referencing the previous surface. | |
| 833 ui::Compositor* compositor = GetCompositor(); | |
| 834 if (compositor) { | |
| 835 can_lock_compositor_ = NO_PENDING_COMMIT; | |
| 836 on_compositing_did_commit_callbacks_.push_back( | |
| 837 base::Bind(&RenderWidgetHostViewAura:: | |
| 838 SetSurfaceNotInUseByCompositor, | |
| 839 AsWeakPtr())); | |
| 840 if (!compositor->HasObserver(this)) | |
| 841 compositor->AddObserver(this); | |
| 842 } | |
| 843 } | |
| 844 resize_locks_.clear(); | 825 resize_locks_.clear(); |
| 845 } | 826 } |
| 846 } | 827 } |
| 847 | 828 |
| 829 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| 830 const gfx::Rect& surface_rect, |
| 831 const gfx::Rect& damage_rect, |
| 832 BufferPresentedParams* params) { |
| 833 DCHECK(params->surface_handle); |
| 834 DCHECK(!params->texture_to_produce); |
| 835 |
| 836 if (last_swapped_surface_size_ != surface_rect.size()) { |
| 837 // The surface could have shrunk since we skipped an update, in which |
| 838 // case we can expect a full update. |
| 839 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
| 840 skipped_damage_.setEmpty(); |
| 841 last_swapped_surface_size_ = surface_rect.size(); |
| 842 } |
| 843 |
| 844 if (ShouldSkipFrame(surface_rect.size())) { |
| 845 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
| 846 InsertSyncPointAndACK(*params); |
| 847 return false; |
| 848 } |
| 849 |
| 850 DCHECK(!current_surface_ || image_transport_clients_.find(current_surface_) != |
| 851 image_transport_clients_.end()); |
| 852 if (current_surface_) |
| 853 params->texture_to_produce = image_transport_clients_[current_surface_]; |
| 854 |
| 855 std::swap(current_surface_, params->surface_handle); |
| 856 |
| 857 DCHECK(image_transport_clients_.find(current_surface_) != |
| 858 image_transport_clients_.end()); |
| 859 |
| 860 image_transport_clients_[current_surface_]->Consume(surface_rect.size()); |
| 861 released_front_lock_ = NULL; |
| 862 UpdateExternalTexture(); |
| 863 |
| 864 return true; |
| 865 } |
| 866 |
| 867 void RenderWidgetHostViewAura::SwapBuffersCompleted( |
| 868 const BufferPresentedParams& params) { |
| 869 ui::Compositor* compositor = GetCompositor(); |
| 870 if (!compositor) { |
| 871 InsertSyncPointAndACK(params); |
| 872 } else { |
| 873 // Add sending an ACK to the list of things to do OnCompositingDidCommit |
| 874 can_lock_compositor_ = NO_PENDING_COMMIT; |
| 875 on_compositing_did_commit_callbacks_.push_back( |
| 876 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, params)); |
| 877 if (!compositor->HasObserver(this)) |
| 878 compositor->AddObserver(this); |
| 879 } |
| 880 } |
| 881 |
| 848 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 882 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
| 849 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 883 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
| 850 int gpu_host_id) { | 884 int gpu_host_id) { |
| 851 surface_route_id_ = params_in_pixel.route_id; | 885 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), params_in_pixel.size); |
| 852 // If protection state changed, then this swap is stale. We must still ACK but | 886 BufferPresentedParams ack_params( |
| 853 // do not update current_surface_ since it may have been discarded. | 887 params_in_pixel.route_id, gpu_host_id, params_in_pixel.surface_handle); |
| 854 if (params_in_pixel.protection_state_id && | 888 if (!SwapBuffersPrepare(surface_rect, surface_rect, &ack_params)) |
| 855 params_in_pixel.protection_state_id != protection_state_id_) { | |
| 856 DCHECK(!current_surface_); | |
| 857 if (!params_in_pixel.skip_ack) | |
| 858 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, false, NULL); | |
| 859 return; | 889 return; |
| 890 |
| 891 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
| 892 skipped_damage_.setEmpty(); |
| 893 |
| 894 ui::Compositor* compositor = GetCompositor(); |
| 895 if (compositor) { |
| 896 gfx::Size surface_size = ConvertSizeToDIP(this, params_in_pixel.size); |
| 897 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
| 860 } | 898 } |
| 861 | 899 |
| 862 if (ShouldFastACK(params_in_pixel.surface_handle)) { | 900 SwapBuffersCompleted(ack_params); |
| 863 if (!params_in_pixel.skip_ack) | |
| 864 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, false, NULL); | |
| 865 return; | |
| 866 } | |
| 867 | |
| 868 current_surface_ = params_in_pixel.surface_handle; | |
| 869 // If we don't require an ACK that means the content is not a fresh updated | |
| 870 // new frame, rather we are just resetting our handle to some old content | |
| 871 // that we still hadn't discarded. Although we could display immediately, | |
| 872 // by not resetting the compositor lock here, we give us some time to get | |
| 873 // a fresh frame which means fewer content flashes. | |
| 874 if (!params_in_pixel.skip_ack) | |
| 875 released_front_lock_ = NULL; | |
| 876 | |
| 877 UpdateExternalTexture(); | |
| 878 | |
| 879 ui::Compositor* compositor = GetCompositor(); | |
| 880 if (!compositor) { | |
| 881 if (!params_in_pixel.skip_ack) | |
| 882 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, true, NULL); | |
| 883 } else { | |
| 884 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) != | |
| 885 image_transport_clients_.end()); | |
| 886 gfx::Size surface_size_in_pixel = | |
| 887 image_transport_clients_[params_in_pixel.surface_handle]->size(); | |
| 888 gfx::Size surface_size = ConvertSizeToDIP(this, surface_size_in_pixel); | |
| 889 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | |
| 890 | |
| 891 if (!params_in_pixel.skip_ack) { | |
| 892 // Add sending an ACK to the list of things to do OnCompositingDidCommit | |
| 893 can_lock_compositor_ = NO_PENDING_COMMIT; | |
| 894 on_compositing_did_commit_callbacks_.push_back( | |
| 895 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | |
| 896 params_in_pixel.route_id, | |
| 897 gpu_host_id, | |
| 898 true)); | |
| 899 if (!compositor->HasObserver(this)) | |
| 900 compositor->AddObserver(this); | |
| 901 } | |
| 902 } | |
| 903 } | 901 } |
| 904 | 902 |
| 905 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 903 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| 906 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 904 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| 907 int gpu_host_id) { | 905 int gpu_host_id) { |
| 908 surface_route_id_ = params_in_pixel.route_id; | 906 const gfx::Rect surface_rect = |
| 909 // If visible state changed, then this PSB is stale. We must still ACK but | 907 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); |
| 910 // do not update current_surface_. | 908 gfx::Rect damage_rect(params_in_pixel.x, |
| 911 if (params_in_pixel.protection_state_id && | 909 params_in_pixel.y, |
| 912 params_in_pixel.protection_state_id != protection_state_id_) { | 910 params_in_pixel.width, |
| 913 DCHECK(!current_surface_); | 911 params_in_pixel.height); |
| 914 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, false, NULL); | 912 BufferPresentedParams ack_params( |
| 913 params_in_pixel.route_id, gpu_host_id, params_in_pixel.surface_handle); |
| 914 if (!SwapBuffersPrepare(surface_rect, damage_rect, &ack_params)) |
| 915 return; | 915 return; |
| 916 |
| 917 SkRegion damage(RectToSkIRect(damage_rect)); |
| 918 if (!skipped_damage_.isEmpty()) { |
| 919 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
| 920 skipped_damage_.setEmpty(); |
| 916 } | 921 } |
| 917 | 922 |
| 918 if (ShouldFastACK(params_in_pixel.surface_handle)) { | 923 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); |
| 919 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, false, NULL); | 924 ui::Texture* current_texture = image_transport_clients_[current_surface_]; |
| 920 return; | 925 |
| 926 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; |
| 927 DLOG_IF(ERROR, ack_params.texture_to_produce && |
| 928 ack_params.texture_to_produce->size() != current_texture->size() && |
| 929 SkIRectToRect(damage.getBounds()) != surface_rect) << |
| 930 "Expected full damage rect after size change"; |
| 931 if (ack_params.texture_to_produce && !previous_damage_.isEmpty() && |
| 932 ack_params.texture_to_produce->size() == current_texture->size()) { |
| 933 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 934 GLHelper* gl_helper = factory->GetGLHelper(); |
| 935 gl_helper->CopySubBufferDamage( |
| 936 current_texture->PrepareTexture(), |
| 937 ack_params.texture_to_produce->PrepareTexture(), |
| 938 damage, |
| 939 previous_damage_); |
| 921 } | 940 } |
| 922 | 941 previous_damage_ = damage; |
| 923 current_surface_ = params_in_pixel.surface_handle; | |
| 924 released_front_lock_ = NULL; | |
| 925 DCHECK(current_surface_); | |
| 926 UpdateExternalTexture(); | |
| 927 | 942 |
| 928 ui::Compositor* compositor = GetCompositor(); | 943 ui::Compositor* compositor = GetCompositor(); |
| 929 if (!compositor) { | 944 if (compositor) { |
| 930 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, true, NULL); | |
| 931 } else { | |
| 932 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) != | |
| 933 image_transport_clients_.end()); | |
| 934 gfx::Size surface_size_in_pixel = | |
| 935 image_transport_clients_[params_in_pixel.surface_handle]->size(); | |
| 936 | |
| 937 // Co-ordinates come in OpenGL co-ordinate space. | 945 // Co-ordinates come in OpenGL co-ordinate space. |
| 938 // We need to convert to layer space. | 946 // We need to convert to layer space. |
| 939 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( | 947 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
| 940 params_in_pixel.x, | 948 params_in_pixel.x, |
| 941 surface_size_in_pixel.height() - params_in_pixel.y - | 949 surface_size_in_pixel.height() - params_in_pixel.y - |
| 942 params_in_pixel.height, | 950 params_in_pixel.height, |
| 943 params_in_pixel.width, | 951 params_in_pixel.width, |
| 944 params_in_pixel.height)); | 952 params_in_pixel.height)); |
| 945 | 953 |
| 946 // Damage may not have been DIP aligned, so inflate damage to compensate | 954 // Damage may not have been DIP aligned, so inflate damage to compensate |
| 947 // for any round-off error. | 955 // for any round-off error. |
| 948 rect_to_paint.Inset(-1, -1); | 956 rect_to_paint.Inset(-1, -1); |
| 949 rect_to_paint.Intersect(window_->bounds()); | 957 rect_to_paint.Intersect(window_->bounds()); |
| 950 | 958 |
| 951 window_->SchedulePaintInRect(rect_to_paint); | 959 window_->SchedulePaintInRect(rect_to_paint); |
| 960 } |
| 952 | 961 |
| 953 // Add sending an ACK to the list of things to do OnCompositingDidCommit | 962 SwapBuffersCompleted(ack_params); |
| 954 can_lock_compositor_ = NO_PENDING_COMMIT; | |
| 955 on_compositing_did_commit_callbacks_.push_back( | |
| 956 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | |
| 957 params_in_pixel.route_id, | |
| 958 gpu_host_id, | |
| 959 true)); | |
| 960 if (!compositor->HasObserver(this)) | |
| 961 compositor->AddObserver(this); | |
| 962 } | |
| 963 } | 963 } |
| 964 | 964 |
| 965 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 965 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
| 966 } | 966 } |
| 967 | 967 |
| 968 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 968 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
| 969 const gfx::Size& desired_size) { | 969 const gfx::Size& desired_size) { |
| 970 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 970 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
| 971 // matter what is returned here as GetBackingStore is the only caller of this | 971 // matter what is returned here as GetBackingStore is the only caller of this |
| 972 // method. TODO(jbates) implement this if other Aura code needs it. | 972 // method. TODO(jbates) implement this if other Aura code needs it. |
| 973 return false; | 973 return false; |
| 974 } | 974 } |
| 975 | 975 |
| 976 // TODO(backer): Drop the |shm_handle| once I remove some unused service side | 976 // TODO(backer): Drop the |shm_handle| once I remove some unused service side |
| 977 // code. | 977 // code. |
| 978 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 978 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
| 979 int32 width_in_pixel, | 979 int32 width_in_pixel, |
| 980 int32 height_in_pixel, | 980 int32 height_in_pixel, |
| 981 uint64 surface_handle) { | 981 uint64 surface_handle, |
| 982 const std::string& mailbox_name) { |
| 982 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 983 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 983 scoped_refptr<ui::Texture> surface(factory->CreateTransportClient( | 984 scoped_refptr<ui::Texture> surface(factory->CreateTransportClient( |
| 984 gfx::Size(width_in_pixel, height_in_pixel), device_scale_factor_, | 985 gfx::Size(width_in_pixel, height_in_pixel), device_scale_factor_, |
| 985 surface_handle)); | 986 mailbox_name)); |
| 986 if (!surface) { | 987 if (!surface) { |
| 987 LOG(ERROR) << "Failed to create ImageTransport texture"; | 988 LOG(ERROR) << "Failed to create ImageTransport texture"; |
| 988 return; | 989 return; |
| 989 } | 990 } |
| 990 | |
| 991 image_transport_clients_[surface_handle] = surface; | 991 image_transport_clients_[surface_handle] = surface; |
| 992 } | 992 } |
| 993 | 993 |
| 994 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( | 994 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
| 995 uint64 surface_handle) { | 995 // This really tells us to release the frontbuffer. |
| 996 DCHECK(image_transport_clients_.find(surface_handle) != | 996 if (current_surface_ && ShouldReleaseFrontSurface()) { |
| 997 image_transport_clients_.end()); | 997 ui::Compositor* compositor = GetCompositor(); |
| 998 if (current_surface_ == surface_handle) { | 998 if (compositor) { |
| 999 // We need to wait for a commit to clear to guarantee that all we |
| 1000 // will not issue any more GL referencing the previous surface. |
| 1001 can_lock_compositor_ = NO_PENDING_COMMIT; |
| 1002 scoped_refptr<ui::Texture> surface_ref = |
| 1003 image_transport_clients_[current_surface_]; |
| 1004 on_compositing_did_commit_callbacks_.push_back( |
| 1005 base::Bind(&RenderWidgetHostViewAura:: |
| 1006 SetSurfaceNotInUseByCompositor, |
| 1007 AsWeakPtr(), |
| 1008 surface_ref)); |
| 1009 if (!compositor->HasObserver(this)) |
| 1010 compositor->AddObserver(this); |
| 1011 } |
| 1012 image_transport_clients_.erase(current_surface_); |
| 999 current_surface_ = 0; | 1013 current_surface_ = 0; |
| 1000 UpdateExternalTexture(); | 1014 UpdateExternalTexture(); |
| 1001 } | 1015 } |
| 1002 image_transport_clients_.erase(surface_handle); | |
| 1003 } | 1016 } |
| 1004 | 1017 |
| 1005 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(ui::Compositor*) { | 1018 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor( |
| 1006 if (current_surface_ || !host_->is_hidden()) | 1019 scoped_refptr<ui::Texture>) { |
| 1007 return; | |
| 1008 current_surface_in_use_by_compositor_ = false; | |
| 1009 AdjustSurfaceProtection(); | |
| 1010 } | |
| 1011 | |
| 1012 void RenderWidgetHostViewAura::AdjustSurfaceProtection() { | |
| 1013 // If the current surface is non null, it is protected. | |
| 1014 // If we are visible, it is protected. | |
| 1015 // Otherwise, change to not proctected once done thumbnailing and compositing. | |
| 1016 bool surface_is_protected = | |
| 1017 current_surface_ || | |
| 1018 !host_->is_hidden() || | |
| 1019 (current_surface_is_protected_ && | |
| 1020 (pending_thumbnail_tasks_ > 0 || | |
| 1021 current_surface_in_use_by_compositor_)); | |
| 1022 if (current_surface_is_protected_ == surface_is_protected) | |
| 1023 return; | |
| 1024 current_surface_is_protected_ = surface_is_protected; | |
| 1025 ++protection_state_id_; | |
| 1026 | |
| 1027 if (!surface_route_id_ || !shared_surface_handle_.parent_gpu_process_id) | |
| 1028 return; | |
| 1029 | |
| 1030 RenderWidgetHostImpl::SendFrontSurfaceIsProtected( | |
| 1031 surface_is_protected, | |
| 1032 protection_state_id_, | |
| 1033 surface_route_id_, | |
| 1034 shared_surface_handle_.parent_gpu_process_id); | |
| 1035 } | 1020 } |
| 1036 | 1021 |
| 1037 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished( | 1022 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished( |
| 1038 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, | 1023 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, |
| 1039 const base::Callback<void(bool)>& callback, | 1024 const base::Callback<void(bool)>& callback, |
| 1040 bool result) { | 1025 bool result) { |
| 1041 callback.Run(result); | 1026 callback.Run(result); |
| 1042 | 1027 |
| 1043 if (!render_widget_host_view.get()) | 1028 if (!render_widget_host_view.get()) |
| 1044 return; | 1029 return; |
| 1045 --render_widget_host_view->pending_thumbnail_tasks_; | 1030 --render_widget_host_view->pending_thumbnail_tasks_; |
| 1046 render_widget_host_view->AdjustSurfaceProtection(); | |
| 1047 } | 1031 } |
| 1048 | 1032 |
| 1049 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 1033 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
| 1050 RenderWidgetHostViewBase::SetBackground(background); | 1034 RenderWidgetHostViewBase::SetBackground(background); |
| 1051 host_->SetBackground(background); | 1035 host_->SetBackground(background); |
| 1052 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 1036 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
| 1053 } | 1037 } |
| 1054 | 1038 |
| 1055 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { | 1039 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { |
| 1056 GetScreenInfoForWindow(results, window_); | 1040 GetScreenInfoForWindow(results, window_); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 | 1740 |
| 1757 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 1741 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
| 1758 ui::Compositor* compositor) { | 1742 ui::Compositor* compositor) { |
| 1759 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 1743 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
| 1760 can_lock_compositor_ = YES; | 1744 can_lock_compositor_ = YES; |
| 1761 for (ResizeLockList::iterator it = resize_locks_.begin(); | 1745 for (ResizeLockList::iterator it = resize_locks_.begin(); |
| 1762 it != resize_locks_.end(); ++it) | 1746 it != resize_locks_.end(); ++it) |
| 1763 if ((*it)->GrabDeferredLock()) | 1747 if ((*it)->GrabDeferredLock()) |
| 1764 can_lock_compositor_ = YES_DID_LOCK; | 1748 can_lock_compositor_ = YES_DID_LOCK; |
| 1765 } | 1749 } |
| 1766 RunCompositingDidCommitCallbacks(compositor); | 1750 RunCompositingDidCommitCallbacks(); |
| 1767 locks_pending_commit_.clear(); | 1751 locks_pending_commit_.clear(); |
| 1768 } | 1752 } |
| 1769 | 1753 |
| 1770 void RenderWidgetHostViewAura::OnCompositingStarted( | 1754 void RenderWidgetHostViewAura::OnCompositingStarted( |
| 1771 ui::Compositor* compositor) { | 1755 ui::Compositor* compositor) { |
| 1772 } | 1756 } |
| 1773 | 1757 |
| 1774 void RenderWidgetHostViewAura::OnCompositingEnded( | 1758 void RenderWidgetHostViewAura::OnCompositingEnded( |
| 1775 ui::Compositor* compositor) { | 1759 ui::Compositor* compositor) { |
| 1776 } | 1760 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1787 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; | 1771 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; |
| 1788 } | 1772 } |
| 1789 } | 1773 } |
| 1790 | 1774 |
| 1791 //////////////////////////////////////////////////////////////////////////////// | 1775 //////////////////////////////////////////////////////////////////////////////// |
| 1792 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 1776 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
| 1793 | 1777 |
| 1794 void RenderWidgetHostViewAura::OnLostResources() { | 1778 void RenderWidgetHostViewAura::OnLostResources() { |
| 1795 image_transport_clients_.clear(); | 1779 image_transport_clients_.clear(); |
| 1796 current_surface_ = 0; | 1780 current_surface_ = 0; |
| 1797 protection_state_id_ = 0; | |
| 1798 current_surface_is_protected_ = true; | |
| 1799 current_surface_in_use_by_compositor_ = true; | |
| 1800 surface_route_id_ = 0; | |
| 1801 UpdateExternalTexture(); | 1781 UpdateExternalTexture(); |
| 1802 locks_pending_commit_.clear(); | 1782 locks_pending_commit_.clear(); |
| 1803 | 1783 |
| 1804 DCHECK(!shared_surface_handle_.is_null()); | 1784 DCHECK(!shared_surface_handle_.is_null()); |
| 1805 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1785 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1806 factory->DestroySharedSurfaceHandle(shared_surface_handle_); | 1786 factory->DestroySharedSurfaceHandle(shared_surface_handle_); |
| 1807 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); | 1787 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); |
| 1808 host_->CompositingSurfaceUpdated(); | 1788 host_->CompositingSurfaceUpdated(); |
| 1809 host_->ScheduleComposite(); | 1789 host_->ScheduleComposite(); |
| 1810 } | 1790 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 gfx::Rect rect = window_->bounds(); | 1912 gfx::Rect rect = window_->bounds(); |
| 1933 int border_x = rect.width() * kMouseLockBorderPercentage / 100; | 1913 int border_x = rect.width() * kMouseLockBorderPercentage / 100; |
| 1934 int border_y = rect.height() * kMouseLockBorderPercentage / 100; | 1914 int border_y = rect.height() * kMouseLockBorderPercentage / 100; |
| 1935 | 1915 |
| 1936 return global_mouse_position_.x() < rect.x() + border_x || | 1916 return global_mouse_position_.x() < rect.x() + border_x || |
| 1937 global_mouse_position_.x() > rect.right() - border_x || | 1917 global_mouse_position_.x() > rect.right() - border_x || |
| 1938 global_mouse_position_.y() < rect.y() + border_y || | 1918 global_mouse_position_.y() < rect.y() + border_y || |
| 1939 global_mouse_position_.y() > rect.bottom() - border_y; | 1919 global_mouse_position_.y() > rect.bottom() - border_y; |
| 1940 } | 1920 } |
| 1941 | 1921 |
| 1942 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks( | 1922 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { |
| 1943 ui::Compositor* compositor) { | 1923 for (std::vector<base::Closure>::const_iterator |
| 1944 for (std::vector< base::Callback<void(ui::Compositor*)> >::const_iterator | |
| 1945 it = on_compositing_did_commit_callbacks_.begin(); | 1924 it = on_compositing_did_commit_callbacks_.begin(); |
| 1946 it != on_compositing_did_commit_callbacks_.end(); ++it) { | 1925 it != on_compositing_did_commit_callbacks_.end(); ++it) { |
| 1947 it->Run(compositor); | 1926 it->Run(); |
| 1948 } | 1927 } |
| 1949 on_compositing_did_commit_callbacks_.clear(); | 1928 on_compositing_did_commit_callbacks_.clear(); |
| 1950 } | 1929 } |
| 1951 | 1930 |
| 1952 // static | 1931 // static |
| 1953 void RenderWidgetHostViewAura::InsertSyncPointAndACK( | 1932 void RenderWidgetHostViewAura::InsertSyncPointAndACK( |
| 1954 int32 route_id, int gpu_host_id, bool presented, | 1933 const BufferPresentedParams& params) { |
| 1955 ui::Compositor* compositor) { | |
| 1956 uint32 sync_point = 0; | 1934 uint32 sync_point = 0; |
| 1957 // If we have no compositor, so we must still send the ACK. A zero | 1935 // If we produced a texture, we have to synchronize with the consumer of |
| 1958 // sync point will not be waited for in the GPU process. | 1936 // that texture. |
| 1959 if (compositor) { | 1937 if (params.texture_to_produce) { |
| 1960 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1938 params.texture_to_produce->Produce(); |
| 1961 sync_point = factory->InsertSyncPoint(); | 1939 sync_point = ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
| 1962 } | 1940 } |
| 1963 | 1941 |
| 1964 RenderWidgetHostImpl::AcknowledgeBufferPresent( | 1942 RenderWidgetHostImpl::AcknowledgeBufferPresent( |
| 1965 route_id, gpu_host_id, presented, sync_point); | 1943 params.route_id, params.gpu_host_id, params.surface_handle, sync_point); |
| 1966 } | 1944 } |
| 1967 | 1945 |
| 1968 void RenderWidgetHostViewAura::AddingToRootWindow() { | 1946 void RenderWidgetHostViewAura::AddingToRootWindow() { |
| 1969 host_->ParentChanged(GetNativeViewId()); | 1947 host_->ParentChanged(GetNativeViewId()); |
| 1970 UpdateScreenInfo(window_); | 1948 UpdateScreenInfo(window_); |
| 1971 } | 1949 } |
| 1972 | 1950 |
| 1973 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 1951 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 1974 host_->ParentChanged(0); | 1952 host_->ParentChanged(0); |
| 1975 // We are about to disconnect ourselves from the compositor, we need to issue | 1953 // We are about to disconnect ourselves from the compositor, we need to issue |
| 1976 // the callbacks now, because we won't get notified when the frame is done. | 1954 // the callbacks now, because we won't get notified when the frame is done. |
| 1977 // TODO(piman): this might in theory cause a race where the GPU process starts | 1955 // TODO(piman): this might in theory cause a race where the GPU process starts |
| 1978 // drawing to the buffer we haven't yet displayed. This will only show for 1 | 1956 // drawing to the buffer we haven't yet displayed. This will only show for 1 |
| 1979 // frame though, because we will reissue a new frame right away without that | 1957 // frame though, because we will reissue a new frame right away without that |
| 1980 // composited data. | 1958 // composited data. |
| 1981 ui::Compositor* compositor = GetCompositor(); | 1959 ui::Compositor* compositor = GetCompositor(); |
| 1982 RunCompositingDidCommitCallbacks(compositor); | 1960 RunCompositingDidCommitCallbacks(); |
| 1983 locks_pending_commit_.clear(); | 1961 locks_pending_commit_.clear(); |
| 1984 if (compositor && compositor->HasObserver(this)) | 1962 if (compositor && compositor->HasObserver(this)) |
| 1985 compositor->RemoveObserver(this); | 1963 compositor->RemoveObserver(this); |
| 1986 DetachFromInputMethod(); | 1964 DetachFromInputMethod(); |
| 1987 } | 1965 } |
| 1988 | 1966 |
| 1989 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { | 1967 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { |
| 1990 aura::RootWindow* root_window = window_->GetRootWindow(); | 1968 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 1991 return root_window ? root_window->compositor() : NULL; | 1969 return root_window ? root_window->compositor() : NULL; |
| 1992 } | 1970 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2005 RenderWidgetHost* widget) { | 1983 RenderWidgetHost* widget) { |
| 2006 return new RenderWidgetHostViewAura(widget); | 1984 return new RenderWidgetHostViewAura(widget); |
| 2007 } | 1985 } |
| 2008 | 1986 |
| 2009 // static | 1987 // static |
| 2010 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1988 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2011 GetScreenInfoForWindow(results, NULL); | 1989 GetScreenInfoForWindow(results, NULL); |
| 2012 } | 1990 } |
| 2013 | 1991 |
| 2014 } // namespace content | 1992 } // namespace content |
| OLD | NEW |