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" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "cc/layers/layer.h" |
15 #include "cc/output/copy_output_request.h" | 16 #include "cc/output/copy_output_request.h" |
16 #include "cc/output/copy_output_result.h" | 17 #include "cc/output/copy_output_result.h" |
17 #include "cc/resources/texture_mailbox.h" | 18 #include "cc/resources/texture_mailbox.h" |
18 #include "cc/trees/layer_tree_settings.h" | 19 #include "cc/trees/layer_tree_settings.h" |
19 #include "content/browser/accessibility/browser_accessibility_manager.h" | 20 #include "content/browser/accessibility/browser_accessibility_manager.h" |
20 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 21 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
21 #include "content/browser/frame_host/frame_tree.h" | 22 #include "content/browser/frame_host/frame_tree.h" |
22 #include "content/browser/frame_host/frame_tree_node.h" | 23 #include "content/browser/frame_host/frame_tree_node.h" |
23 #include "content/browser/frame_host/render_frame_host_impl.h" | 24 #include "content/browser/frame_host/render_frame_host_impl.h" |
24 #include "content/browser/gpu/compositor_util.h" | 25 #include "content/browser/gpu/compositor_util.h" |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 aura::Window* root = window_->GetRootWindow(); | 607 aura::Window* root = window_->GetRootWindow(); |
607 if (root) { | 608 if (root) { |
608 aura::client::ScreenPositionClient* screen_position_client = | 609 aura::client::ScreenPositionClient* screen_position_client = |
609 aura::client::GetScreenPositionClient(root); | 610 aura::client::GetScreenPositionClient(root); |
610 if (screen_position_client) { | 611 if (screen_position_client) { |
611 screen_position_client->ConvertPointFromScreen( | 612 screen_position_client->ConvertPointFromScreen( |
612 window_->parent(), &relative_origin); | 613 window_->parent(), &relative_origin); |
613 } | 614 } |
614 } | 615 } |
615 | 616 |
| 617 SnapToPhysicalPixelBoundary(); |
616 InternalSetBounds(gfx::Rect(relative_origin, rect.size())); | 618 InternalSetBounds(gfx::Rect(relative_origin, rect.size())); |
617 } | 619 } |
618 | 620 |
619 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { | 621 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { |
620 return window_; | 622 return window_; |
621 } | 623 } |
622 | 624 |
623 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { | 625 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { |
624 #if defined(OS_WIN) | 626 #if defined(OS_WIN) |
625 aura::WindowTreeHost* host = window_->GetHost(); | 627 aura::WindowTreeHost* host = window_->GetHost(); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 } | 957 } |
956 | 958 |
957 void RenderWidgetHostViewAura::EndFrameSubscription() { | 959 void RenderWidgetHostViewAura::EndFrameSubscription() { |
958 delegated_frame_host_->EndFrameSubscription(); | 960 delegated_frame_host_->EndFrameSubscription(); |
959 } | 961 } |
960 | 962 |
961 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id, | 963 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id, |
962 int route_id) { | 964 int route_id) { |
963 } | 965 } |
964 | 966 |
| 967 void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { |
| 968 // The top left corner of our view in window coordinates might not land on a |
| 969 // device pixel boundary if we have a non-integer device scale. In that case, |
| 970 // to avoid the web contents area looking blurry we translate the web contents |
| 971 // in the +x, +y direction to land on the nearest pixel boundary. This may |
| 972 // cause the bottom and right edges to be clipped slightly, but that's ok. |
| 973 gfx::Point view_offset_dips = window_->GetBoundsInRootWindow().origin(); |
| 974 gfx::PointF view_offset = view_offset_dips; |
| 975 view_offset.Scale(current_device_scale_factor_); |
| 976 gfx::PointF view_offset_snapped(std::ceil(view_offset.x()), |
| 977 std::ceil(view_offset.y())); |
| 978 |
| 979 gfx::Vector2dF fudge = view_offset_snapped - view_offset; |
| 980 fudge.Scale(1.0 / current_device_scale_factor_); |
| 981 gfx::Transform fudge_transform; |
| 982 fudge_transform.Translate(fudge.x(), fudge.y()); |
| 983 GetLayer()->cc_layer()->SetTransform(fudge_transform); |
| 984 } |
| 985 |
965 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 986 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
966 if (HasDisplayPropertyChanged(window_)) | 987 if (HasDisplayPropertyChanged(window_)) |
967 host_->InvalidateScreenInfo(); | 988 host_->InvalidateScreenInfo(); |
968 | 989 |
969 // Don't recursively call SetBounds if this bounds update is the result of | 990 // Don't recursively call SetBounds if this bounds update is the result of |
970 // a Window::SetBoundsInternal call. | 991 // a Window::SetBoundsInternal call. |
971 if (!in_bounds_changed_) | 992 if (!in_bounds_changed_) |
972 window_->SetBounds(rect); | 993 window_->SetBounds(rect); |
973 host_->WasResized(); | 994 host_->WasResized(); |
974 delegated_frame_host_->WasResized(); | 995 delegated_frame_host_->WasResized(); |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 | 2400 |
2380 //////////////////////////////////////////////////////////////////////////////// | 2401 //////////////////////////////////////////////////////////////////////////////// |
2381 // RenderWidgetHostViewBase, public: | 2402 // RenderWidgetHostViewBase, public: |
2382 | 2403 |
2383 // static | 2404 // static |
2384 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2405 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2385 GetScreenInfoForWindow(results, NULL); | 2406 GetScreenInfoForWindow(results, NULL); |
2386 } | 2407 } |
2387 | 2408 |
2388 } // namespace content | 2409 } // namespace content |
OLD | NEW |