Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: ui/aura/root_window.cc

Issue 12746002: Re-implement overscan & Implement Display Rotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: skip rotate test on win8 Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura/root_window.cc
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 649bc9a7ea94e2204b986aef5914dee3a2892333..5585934bb66a4833843ca11e9c2a5bc3316a2260 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -119,6 +119,7 @@ RootWindow::RootWindow(const CreateParams& params)
mouse_move_hold_count_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(held_mouse_event_factory_(this)) {
SetName("RootWindow");
+ host_->SetInsets(params.initial_insets);
compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget()));
DCHECK(compositor_.get());
@@ -154,8 +155,8 @@ void RootWindow::Init() {
host_->GetBounds().size());
Window::Init(ui::LAYER_NOT_DRAWN);
compositor()->SetRootLayer(layer());
- SetBounds(
- ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size())));
+ SetTransformInternal(gfx::Transform());
+ UpdateWindowSize(host_->GetBounds().size());
Env::GetInstance()->NotifyRootWindowInitialized(this);
Show();
}
@@ -197,8 +198,14 @@ gfx::Size RootWindow::GetHostSize() const {
}
void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) {
+ SetHostBoundsAndInsets(bounds_in_pixel, gfx::Insets());
+}
+
+void RootWindow::SetHostBoundsAndInsets(const gfx::Rect& bounds_in_pixel,
+ const gfx::Insets& insets_in_pixel) {
DCHECK(!bounds_in_pixel.IsEmpty());
DispatchHeldMouseMove();
+ host_->SetInsets(insets_in_pixel);
host_->SetBounds(bounds_in_pixel);
synthesize_mouse_move_ = false;
}
@@ -443,7 +450,7 @@ const RootWindow* RootWindow::GetRootWindow() const {
}
void RootWindow::SetTransform(const gfx::Transform& transform) {
- Window::SetTransform(transform);
+ SetTransformInternal(transform);
// If the layer is not animating, then we need to update the host size
// immediately.
@@ -451,6 +458,19 @@ void RootWindow::SetTransform(const gfx::Transform& transform) {
OnHostResized(host_->GetBounds().size());
}
+void RootWindow::SetTransformInternal(const gfx::Transform& transform) {
+ gfx::Insets insets = host_->GetInsets();
+ if (insets.top() != 0 || insets.left() != 0) {
+ float device_scale_factor = GetDeviceScaleFactor();
+ gfx::Transform translate;
+ translate.Translate(insets.left() / device_scale_factor,
+ insets.top() / device_scale_factor);
+ Window::SetTransform(translate * transform);
+ } else {
+ Window::SetTransform(transform);
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// RootWindow, ui::EventTarget implementation:
@@ -722,6 +742,17 @@ void RootWindow::CleanupGestureRecognizerState(Window* window) {
}
}
+void RootWindow::UpdateWindowSize(const gfx::Size& host_size) {
+ gfx::Rect bounds(host_size);
+ bounds.Inset(host_->GetInsets());
+ bounds = ui::ConvertRectToDIP(layer(), bounds);
+ gfx::RectF new_bounds(bounds);
+ layer()->transform().TransformRect(&new_bounds);
+ // Ignore the origin because RootWindow's insets are handled by
+ // the transform.
+ SetBounds(gfx::Rect(gfx::ToNearestRect(new_bounds).size()));
+}
+
void RootWindow::OnWindowAddedToRootWindow(Window* attached) {
if (attached->IsVisible() &&
attached->ContainsPointInRoot(GetLastMouseLocationInRoot()))
@@ -924,10 +955,8 @@ void RootWindow::OnHostResized(const gfx::Size& size) {
// The layer, and all the observers should be notified of the
// transformed size of the root window.
gfx::Size old(bounds().size());
- gfx::RectF bounds(ui::ConvertSizeToDIP(layer(), size));
- layer()->transform().TransformRect(&bounds);
- // The transform is expected to produce an integer rect as its output.
- SetBounds(gfx::ToNearestRect(bounds));
+ UpdateWindowSize(size);
+ // TODO(oshima): Rename this to OnHostWindowResized.
FOR_EACH_OBSERVER(RootWindowObserver, observers_,
OnRootWindowResized(this, old));
}
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_host.h » ('j') | ui/aura/root_window_host.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698