| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 3186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 void RenderWidgetHostViewAura::OnCompositingLockStateChanged( | 3197 void RenderWidgetHostViewAura::OnCompositingLockStateChanged( |
| 3198 ui::Compositor* compositor) { | 3198 ui::Compositor* compositor) { |
| 3199 // A compositor lock that is part of a resize lock timed out. We | 3199 // A compositor lock that is part of a resize lock timed out. We |
| 3200 // should display a renderer frame. | 3200 // should display a renderer frame. |
| 3201 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) { | 3201 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) { |
| 3202 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; | 3202 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; |
| 3203 } | 3203 } |
| 3204 } | 3204 } |
| 3205 | 3205 |
| 3206 void RenderWidgetHostViewAura::OnUpdateVSyncParameters( | 3206 void RenderWidgetHostViewAura::OnUpdateVSyncParameters( |
| 3207 ui::Compositor* compositor, | |
| 3208 base::TimeTicks timebase, | 3207 base::TimeTicks timebase, |
| 3209 base::TimeDelta interval) { | 3208 base::TimeDelta interval) { |
| 3210 if (IsShowing()) { | 3209 if (IsShowing()) { |
| 3211 if (IsDeadlineSchedulingEnabled()) { | 3210 if (IsDeadlineSchedulingEnabled()) { |
| 3212 // The deadline scheduler has logic to stagger the draws of the | 3211 // The deadline scheduler has logic to stagger the draws of the |
| 3213 // Renderer and Browser built-in, so send it an accurate timebase. | 3212 // Renderer and Browser built-in, so send it an accurate timebase. |
| 3214 host_->UpdateVSyncParameters(timebase, interval); | 3213 host_->UpdateVSyncParameters(timebase, interval); |
| 3215 } else if (!last_draw_ended_.is_null()) { | 3214 } else if (!last_draw_ended_.is_null()) { |
| 3216 // For the non-deadline scheduler, we send the Renderer an offset | 3215 // For the non-deadline scheduler, we send the Renderer an offset |
| 3217 // vsync timebase to avoid its draws racing the Browser's draws. | 3216 // vsync timebase to avoid its draws racing the Browser's draws. |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3492 cursor_client->AddObserver(this); | 3491 cursor_client->AddObserver(this); |
| 3493 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 3492 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 3494 } | 3493 } |
| 3495 if (current_surface_.get()) | 3494 if (current_surface_.get()) |
| 3496 UpdateExternalTexture(); | 3495 UpdateExternalTexture(); |
| 3497 if (HasFocus()) { | 3496 if (HasFocus()) { |
| 3498 ui::InputMethod* input_method = GetInputMethod(); | 3497 ui::InputMethod* input_method = GetInputMethod(); |
| 3499 if (input_method) | 3498 if (input_method) |
| 3500 input_method->SetFocusedTextInputClient(this); | 3499 input_method->SetFocusedTextInputClient(this); |
| 3501 } | 3500 } |
| 3501 |
| 3502 ui::Compositor* compositor = GetCompositor(); |
| 3503 if (compositor) |
| 3504 compositor->vsync_manager()->AddObserver(this); |
| 3502 } | 3505 } |
| 3503 | 3506 |
| 3504 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 3507 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 3505 aura::client::CursorClient* cursor_client = | 3508 aura::client::CursorClient* cursor_client = |
| 3506 aura::client::GetCursorClient(window_->GetRootWindow()); | 3509 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 3507 if (cursor_client) | 3510 if (cursor_client) |
| 3508 cursor_client->RemoveObserver(this); | 3511 cursor_client->RemoveObserver(this); |
| 3509 | 3512 |
| 3510 DetachFromInputMethod(); | 3513 DetachFromInputMethod(); |
| 3511 | 3514 |
| 3512 window_->GetDispatcher()->RemoveRootWindowObserver(this); | 3515 window_->GetDispatcher()->RemoveRootWindowObserver(this); |
| 3513 host_->ParentChanged(0); | 3516 host_->ParentChanged(0); |
| 3514 ui::Compositor* compositor = GetCompositor(); | 3517 ui::Compositor* compositor = GetCompositor(); |
| 3515 if (current_surface_.get()) { | 3518 if (current_surface_.get()) { |
| 3516 // We can't get notification for commits after this point, which would | 3519 // We can't get notification for commits after this point, which would |
| 3517 // guarantee that the compositor isn't using an old texture any more, so | 3520 // guarantee that the compositor isn't using an old texture any more, so |
| 3518 // instead we force the layer to stop using any external resources which | 3521 // instead we force the layer to stop using any external resources which |
| 3519 // synchronizes with the compositor thread, and makes it safe to run the | 3522 // synchronizes with the compositor thread, and makes it safe to run the |
| 3520 // callback. | 3523 // callback. |
| 3521 window_->layer()->SetShowPaintedContent(); | 3524 window_->layer()->SetShowPaintedContent(); |
| 3522 } | 3525 } |
| 3523 RunOnCommitCallbacks(); | 3526 RunOnCommitCallbacks(); |
| 3524 resize_lock_.reset(); | 3527 resize_lock_.reset(); |
| 3525 host_->WasResized(); | 3528 host_->WasResized(); |
| 3526 if (compositor && compositor->HasObserver(this)) | 3529 if (compositor) { |
| 3527 compositor->RemoveObserver(this); | 3530 if (compositor->HasObserver(this)) |
| 3531 compositor->RemoveObserver(this); |
| 3532 compositor->vsync_manager()->RemoveObserver(this); |
| 3533 } |
| 3528 } | 3534 } |
| 3529 | 3535 |
| 3530 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { | 3536 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { |
| 3531 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 3537 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
| 3532 return dispatcher ? dispatcher->host()->compositor() : NULL; | 3538 return dispatcher ? dispatcher->host()->compositor() : NULL; |
| 3533 } | 3539 } |
| 3534 | 3540 |
| 3535 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 3541 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
| 3536 ui::InputMethod* input_method = GetInputMethod(); | 3542 ui::InputMethod* input_method = GetInputMethod(); |
| 3537 if (input_method && input_method->GetTextInputClient() == this) | 3543 if (input_method && input_method->GetTextInputClient() == this) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3556 RenderWidgetHost* widget) { | 3562 RenderWidgetHost* widget) { |
| 3557 return new RenderWidgetHostViewAura(widget); | 3563 return new RenderWidgetHostViewAura(widget); |
| 3558 } | 3564 } |
| 3559 | 3565 |
| 3560 // static | 3566 // static |
| 3561 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3567 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3562 GetScreenInfoForWindow(results, NULL); | 3568 GetScreenInfoForWindow(results, NULL); |
| 3563 } | 3569 } |
| 3564 | 3570 |
| 3565 } // namespace content | 3571 } // namespace content |
| OLD | NEW |