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