summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-13 06:22:43 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-13 06:22:43 +0000
commita78c74365c05e1e7dae30a77754a4689cd1a42bf (patch)
tree94c665ea295bffa2029d95d1980ab38839df6116 /ui/aura
parent35957bf6a4a1880a4a9be4c1237702bca23d7385 (diff)
downloadchromium_src-a78c74365c05e1e7dae30a77754a4689cd1a42bf.zip
chromium_src-a78c74365c05e1e7dae30a77754a4689cd1a42bf.tar.gz
chromium_src-a78c74365c05e1e7dae30a77754a4689cd1a42bf.tar.bz2
Add UI scaling support
- add flags page BUG=179997 TEST=covered by test. Review URL: https://chromiumcodereview.appspot.com/12638022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/root_window.cc34
-rw-r--r--ui/aura/root_window.h14
2 files changed, 39 insertions, 9 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 5585934..c2a63a5 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -92,6 +92,7 @@ RootWindowHost* CreateHost(RootWindow* root_window,
RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds)
: initial_bounds(a_initial_bounds),
+ initial_root_window_scale(1.0f),
host(NULL) {
}
@@ -117,8 +118,10 @@ RootWindow::RootWindow(const CreateParams& params)
draw_on_compositing_end_(false),
defer_draw_scheduling_(false),
mouse_move_hold_count_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(held_mouse_event_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(held_mouse_event_factory_(this)),
+ root_window_scale_(1.0f) {
SetName("RootWindow");
+ root_window_scale_ = params.initial_root_window_scale;
host_->SetInsets(params.initial_insets);
compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget()));
@@ -198,13 +201,20 @@ gfx::Size RootWindow::GetHostSize() const {
}
void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) {
- SetHostBoundsAndInsets(bounds_in_pixel, gfx::Insets());
+ SetHostBoundsAndInsetsAndRootWindowScale(
+ bounds_in_pixel, gfx::Insets(), 1.0f);
}
-void RootWindow::SetHostBoundsAndInsets(const gfx::Rect& bounds_in_pixel,
- const gfx::Insets& insets_in_pixel) {
+void RootWindow::SetHostBoundsAndInsetsAndRootWindowScale(
+ const gfx::Rect& bounds_in_pixel,
+ const gfx::Insets& insets_in_pixel,
+ float root_window_scale) {
DCHECK(!bounds_in_pixel.IsEmpty());
DispatchHeldMouseMove();
+ root_window_scale_ = root_window_scale;
+ // Scale the composited result if the |root_window_scale_| is specified,
+ // rather than sacling each layers.
+ layer()->SetForceRenderSurface(root_window_scale_ != 1.0f);
host_->SetInsets(insets_in_pixel);
host_->SetBounds(bounds_in_pixel);
synthesize_mouse_move_ = false;
@@ -460,15 +470,16 @@ void RootWindow::SetTransform(const gfx::Transform& transform) {
void RootWindow::SetTransformInternal(const gfx::Transform& transform) {
gfx::Insets insets = host_->GetInsets();
+ gfx::Transform translate;
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);
}
+ float invert = 1.0f / root_window_scale_;
+ translate.Scale(invert, invert);
+ Window::SetTransform(translate * transform);
}
////////////////////////////////////////////////////////////////////////////////
@@ -748,6 +759,15 @@ void RootWindow::UpdateWindowSize(const gfx::Size& host_size) {
bounds = ui::ConvertRectToDIP(layer(), bounds);
gfx::RectF new_bounds(bounds);
layer()->transform().TransformRect(&new_bounds);
+
+ // It makes little sense to scale beyond the original
+ // resolution.
+ DCHECK_LE(root_window_scale_, GetDeviceScaleFactor());
+ // Apply |root_window_scale_| twice as the downscaling
+ // is already applied once in |SetTransformInternal()|.
+ // TODO(oshima): This is a bit ugly. Consider specifying
+ // the pseudo host resolution instead.
+ new_bounds.Scale(root_window_scale_ * root_window_scale_);
// Ignore the origin because RootWindow's insets are handled by
// the transform.
SetBounds(gfx::Rect(gfx::ToNearestRect(new_bounds).size()));
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index 05378c8..de9f034 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -71,6 +71,8 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
gfx::Insets initial_insets;
+ float initial_root_window_scale;
+
// A host to use in place of the default one that RootWindow will create.
// NULL by default.
RootWindowHost* host;
@@ -107,8 +109,10 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Sets the bounds and insets of the host window.
void SetHostBounds(const gfx::Rect& size_in_pizel);
- void SetHostBoundsAndInsets(const gfx::Rect& bounds_in_pixel,
- const gfx::Insets& insets_in_pixel);
+ void SetHostBoundsAndInsetsAndRootWindowScale(
+ const gfx::Rect& bounds_in_pixel,
+ const gfx::Insets& insets_in_pixel,
+ float root_window_scale);
// Returns where the RootWindow is on screen.
gfx::Point GetHostOrigin() const;
@@ -424,6 +428,12 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
scoped_ptr<ui::ViewProp> prop_;
+ // The scale of the root window. This is used to expand the
+ // area of the root window (useful in HighDPI display).
+ // Note that this should not be confused with the device scale
+ // factor, which specfies the pixel density of the display.
+ float root_window_scale_;
+
DISALLOW_COPY_AND_ASSIGN(RootWindow);
};