Commit 2e2216e4 authored by oshima@chromium.org's avatar oshima@chromium.org

Remove ui-enable-dip option

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10310067

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137659 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a06ebd3
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "ui/aura/client/activation_client.h" #include "ui/aura/client/activation_client.h"
#include "ui/aura/root_window.h" #include "ui/aura/root_window.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/gfx/insets.h" #include "ui/gfx/insets.h"
#include "ui/gfx/monitor.h" #include "ui/gfx/monitor.h"
...@@ -37,7 +36,6 @@ typedef ash::test::AshTestBase DIPTest; ...@@ -37,7 +36,6 @@ typedef ash::test::AshTestBase DIPTest;
// Test if the WM sets correct work area under different density. // Test if the WM sets correct work area under different density.
TEST_F(DIPTest, MAYBE_WorkArea) { TEST_F(DIPTest, MAYBE_WorkArea) {
ui::test::ScopedDIPEnablerForTest enable;
ChangeMonitorConfig(1.0f, gfx::Rect(0, 0, 1000, 900)); ChangeMonitorConfig(1.0f, gfx::Rect(0, 0, 1000, 900));
aura::RootWindow* root = Shell::GetRootWindow(); aura::RootWindow* root = Shell::GetRootWindow();
......
...@@ -112,8 +112,7 @@ void MonitorChangeObserverX11::NotifyMonitorChange() { ...@@ -112,8 +112,7 @@ void MonitorChangeObserverX11::NotifyMonitorChange() {
gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height))); gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height)));
float device_scale_factor = 1.0f; float device_scale_factor = 1.0f;
if (ui::IsDIPEnabled() && if (output_info->mm_width > 0 &&
output_info->mm_width > 0 &&
(kInchInMm * mode->width / output_info->mm_width) > (kInchInMm * mode->width / output_info->mm_width) >
kHighDensityDIPThreshold) { kHighDensityDIPThreshold) {
device_scale_factor = 2.0f; device_scale_factor = 2.0f;
......
...@@ -280,14 +280,10 @@ bool RootWindow::DispatchKeyEvent(KeyEvent* event) { ...@@ -280,14 +280,10 @@ bool RootWindow::DispatchKeyEvent(KeyEvent* event) {
bool RootWindow::DispatchScrollEvent(ScrollEvent* event) { bool RootWindow::DispatchScrollEvent(ScrollEvent* event) {
DispatchHeldMouseMove(); DispatchHeldMouseMove();
if (ui::IsDIPEnabled()) { float scale = ui::GetDeviceScaleFactor(layer());
float scale = ui::GetDeviceScaleFactor(layer()); ui::Transform transform = layer()->transform();
ui::Transform transform = layer()->transform(); transform.ConcatScale(scale, scale);
transform.ConcatScale(scale, scale); event->UpdateForRootTransform(transform);
event->UpdateForRootTransform(transform);
} else {
event->UpdateForRootTransform(layer()->transform());
}
last_mouse_location_ = event->location(); last_mouse_location_ = event->location();
synthesize_mouse_move_ = false; synthesize_mouse_move_ = false;
...@@ -311,14 +307,10 @@ bool RootWindow::DispatchScrollEvent(ScrollEvent* event) { ...@@ -311,14 +307,10 @@ bool RootWindow::DispatchScrollEvent(ScrollEvent* event) {
bool RootWindow::DispatchTouchEvent(TouchEvent* event) { bool RootWindow::DispatchTouchEvent(TouchEvent* event) {
DispatchHeldMouseMove(); DispatchHeldMouseMove();
if (ui::IsDIPEnabled()) { float scale = ui::GetDeviceScaleFactor(layer());
float scale = ui::GetDeviceScaleFactor(layer()); ui::Transform transform = layer()->transform();
ui::Transform transform = layer()->transform(); transform.ConcatScale(scale, scale);
transform.ConcatScale(scale, scale); event->UpdateForRootTransform(transform);
event->UpdateForRootTransform(transform);
} else {
event->UpdateForRootTransform(layer()->transform());
}
bool handled = false; bool handled = false;
ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
Window* target = capture_window_; Window* target = capture_window_;
...@@ -934,14 +926,10 @@ bool RootWindow::IsFocusedWindow(const Window* window) const { ...@@ -934,14 +926,10 @@ bool RootWindow::IsFocusedWindow(const Window* window) const {
} }
bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) { bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) {
if (ui::IsDIPEnabled()) { float scale = ui::GetDeviceScaleFactor(layer());
float scale = ui::GetDeviceScaleFactor(layer()); ui::Transform transform = layer()->transform();
ui::Transform transform = layer()->transform(); transform.ConcatScale(scale, scale);
transform.ConcatScale(scale, scale); event->UpdateForRootTransform(transform);
event->UpdateForRootTransform(transform);
} else {
event->UpdateForRootTransform(layer()->transform());
}
Window* target = Window* target =
mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_;
if (!target) if (!target)
......
...@@ -242,7 +242,7 @@ void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { ...@@ -242,7 +242,7 @@ void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
host_.setViewportSize(size_in_pixel); host_.setViewportSize(size_in_pixel);
root_web_layer_.setBounds(size_in_pixel); root_web_layer_.setBounds(size_in_pixel);
if (device_scale_factor_ != scale && IsDIPEnabled()) { if (device_scale_factor_ != scale) {
device_scale_factor_ = scale; device_scale_factor_ = scale;
if (root_layer_) if (root_layer_)
root_layer_->OnDeviceScaleFactorChanged(scale); root_layer_->OnDeviceScaleFactorChanged(scale);
......
...@@ -10,9 +10,6 @@ const char kDisableTestCompositor[] = "disable-test-compositor"; ...@@ -10,9 +10,6 @@ const char kDisableTestCompositor[] = "disable-test-compositor";
const char kDisableUIVsync[] = "disable-ui-vsync"; const char kDisableUIVsync[] = "disable-ui-vsync";
// Enable Density Independent Pixel coordinates.
const char kUIEnableDIP[] = "ui-enable-dip";
const char kUIEnablePartialSwap[] = "ui-enable-partial-swap"; const char kUIEnablePartialSwap[] = "ui-enable-partial-swap";
// Show FPS counter. // Show FPS counter.
......
...@@ -12,7 +12,6 @@ namespace switches { ...@@ -12,7 +12,6 @@ namespace switches {
COMPOSITOR_EXPORT extern const char kDisableTestCompositor[]; COMPOSITOR_EXPORT extern const char kDisableTestCompositor[];
COMPOSITOR_EXPORT extern const char kDisableUIVsync[]; COMPOSITOR_EXPORT extern const char kDisableUIVsync[];
COMPOSITOR_EXPORT extern const char kUIEnableDIP[];
COMPOSITOR_EXPORT extern const char kUIEnablePartialSwap[]; COMPOSITOR_EXPORT extern const char kUIEnablePartialSwap[];
COMPOSITOR_EXPORT extern const char kUIShowFPSCounter[]; COMPOSITOR_EXPORT extern const char kUIShowFPSCounter[];
COMPOSITOR_EXPORT extern const char kUIShowLayerBorders[]; COMPOSITOR_EXPORT extern const char kUIShowLayerBorders[];
......
...@@ -15,91 +15,42 @@ ...@@ -15,91 +15,42 @@
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
namespace ui { namespace ui {
namespace {
bool dip_enabled_for_test = false;
} // namespace
namespace test {
ScopedDIPEnablerForTest::ScopedDIPEnablerForTest() {
CHECK(!dip_enabled_for_test);
dip_enabled_for_test = true;
}
ScopedDIPEnablerForTest::~ScopedDIPEnablerForTest() {
dip_enabled_for_test = false;
}
} // namespace test
bool IsDIPEnabled() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
static const bool dip_enabled =
command_line.HasSwitch(switches::kDefaultDeviceScaleFactor) ||
(command_line.HasSwitch(switches::kUIEnableDIP) &&
command_line.GetSwitchValueASCII(switches::kUIEnableDIP) != "false");
return dip_enabled || dip_enabled_for_test;
}
float GetDeviceScaleFactor(const Layer* layer) { float GetDeviceScaleFactor(const Layer* layer) {
if (!IsDIPEnabled())
return 1.0f;
return layer->device_scale_factor(); return layer->device_scale_factor();
} }
gfx::Point ConvertPointToDIP(const Layer* layer, gfx::Point ConvertPointToDIP(const Layer* layer,
const gfx::Point& point_in_pixel) { const gfx::Point& point_in_pixel) {
if (IsDIPEnabled()) return point_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer));
return point_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer));
else
return point_in_pixel;
} }
gfx::Size ConvertSizeToDIP(const Layer* layer, gfx::Size ConvertSizeToDIP(const Layer* layer,
const gfx::Size& size_in_pixel) { const gfx::Size& size_in_pixel) {
if (IsDIPEnabled()) return size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer));
return size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer));
else
return size_in_pixel;
} }
gfx::Rect ConvertRectToDIP(const Layer* layer, gfx::Rect ConvertRectToDIP(const Layer* layer,
const gfx::Rect& rect_in_pixel) { const gfx::Rect& rect_in_pixel) {
if (IsDIPEnabled()) { float scale = 1.0f / GetDeviceScaleFactor(layer);
float scale = 1.0f / GetDeviceScaleFactor(layer); return gfx::Rect(rect_in_pixel.origin().Scale(scale),
return gfx::Rect(rect_in_pixel.origin().Scale(scale), rect_in_pixel.size().Scale(scale));
rect_in_pixel.size().Scale(scale));
} else {
return rect_in_pixel;
}
} }
gfx::Point ConvertPointToPixel(const Layer* layer, gfx::Point ConvertPointToPixel(const Layer* layer,
const gfx::Point& point_in_dip) { const gfx::Point& point_in_dip) {
if (IsDIPEnabled()) { return point_in_dip.Scale(GetDeviceScaleFactor(layer));
return point_in_dip.Scale(GetDeviceScaleFactor(layer));
} else {
return point_in_dip;
}
} }
gfx::Size ConvertSizeToPixel(const Layer* layer, gfx::Size ConvertSizeToPixel(const Layer* layer,
const gfx::Size& size_in_dip) { const gfx::Size& size_in_dip) {
if (IsDIPEnabled()) { return size_in_dip.Scale(GetDeviceScaleFactor(layer));
return size_in_dip.Scale(GetDeviceScaleFactor(layer));
} else {
return size_in_dip;
}
} }
gfx::Rect ConvertRectToPixel(const Layer* layer, gfx::Rect ConvertRectToPixel(const Layer* layer,
const gfx::Rect& rect_in_dip) { const gfx::Rect& rect_in_dip) {
if (IsDIPEnabled()) { float scale = GetDeviceScaleFactor(layer);
float scale = GetDeviceScaleFactor(layer); return gfx::Rect(rect_in_dip.origin().Scale(scale),
return gfx::Rect(rect_in_dip.origin().Scale(scale), rect_in_dip.size().Scale(scale));
rect_in_dip.size().Scale(scale));
} else {
return rect_in_dip;
}
} }
} // namespace ui } // namespace ui
...@@ -16,26 +16,8 @@ class Rect; ...@@ -16,26 +16,8 @@ class Rect;
} // namespace gfx } // namespace gfx
namespace ui { namespace ui {
namespace test {
// A scoped object allows you to temporarily enable DIP
// in the unit tests.
class COMPOSITOR_EXPORT ScopedDIPEnablerForTest {
public:
ScopedDIPEnablerForTest();
~ScopedDIPEnablerForTest();
private:
DISALLOW_COPY_AND_ASSIGN(ScopedDIPEnablerForTest);
};
} // namespace test
class Layer; class Layer;
// True if DIP is enabled.
COMPOSITOR_EXPORT bool IsDIPEnabled();
COMPOSITOR_EXPORT float GetDeviceScaleFactor(const Layer* layer); COMPOSITOR_EXPORT float GetDeviceScaleFactor(const Layer* layer);
// Utility functions that convert point/size/rect between // Utility functions that convert point/size/rect between
......
...@@ -97,7 +97,7 @@ void Layer::SetCompositor(Compositor* compositor) { ...@@ -97,7 +97,7 @@ void Layer::SetCompositor(Compositor* compositor) {
DCHECK(!compositor || compositor->root_layer() == this); DCHECK(!compositor || compositor->root_layer() == this);
DCHECK(!parent_); DCHECK(!parent_);
compositor_ = compositor; compositor_ = compositor;
if (IsDIPEnabled() && compositor) if (compositor)
OnDeviceScaleFactorChanged(compositor->device_scale_factor()); OnDeviceScaleFactorChanged(compositor->device_scale_factor());
} }
...@@ -108,8 +108,7 @@ void Layer::Add(Layer* child) { ...@@ -108,8 +108,7 @@ void Layer::Add(Layer* child) {
child->parent_ = this; child->parent_ = this;
children_.push_back(child); children_.push_back(child);
web_layer_.addChild(child->web_layer_); web_layer_.addChild(child->web_layer_);
if (IsDIPEnabled()) child->OnDeviceScaleFactorChanged(device_scale_factor_);
child->OnDeviceScaleFactorChanged(device_scale_factor_);
} }
void Layer::Remove(Layer* child) { void Layer::Remove(Layer* child) {
...@@ -338,7 +337,7 @@ void Layer::SendDamagedRects() { ...@@ -338,7 +337,7 @@ void Layer::SendDamagedRects() {
// TODO(pkotwicz): Remove this once we are no longer linearly upscaling // TODO(pkotwicz): Remove this once we are no longer linearly upscaling
// web contents when DIP is enabled (crbug.com/127455). // web contents when DIP is enabled (crbug.com/127455).
if (IsDIPEnabled() && web_layer_is_accelerated_) { if (web_layer_is_accelerated_) {
damaged.Inset(-1, -1); damaged.Inset(-1, -1);
damaged = damaged.Intersect(bounds_); damaged = damaged.Intersect(bounds_);
} }
...@@ -370,7 +369,6 @@ void Layer::SuppressPaint() { ...@@ -370,7 +369,6 @@ void Layer::SuppressPaint() {
} }
void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) {
CHECK(IsDIPEnabled());
if (device_scale_factor_ == device_scale_factor) if (device_scale_factor_ == device_scale_factor)
return; return;
device_scale_factor_ = device_scale_factor; device_scale_factor_ = device_scale_factor;
...@@ -387,7 +385,7 @@ void Layer::paintContents(WebKit::WebCanvas* web_canvas, ...@@ -387,7 +385,7 @@ void Layer::paintContents(WebKit::WebCanvas* web_canvas,
const WebKit::WebRect& clip) { const WebKit::WebRect& clip) {
TRACE_EVENT0("ui", "Layer::paintContents"); TRACE_EVENT0("ui", "Layer::paintContents");
gfx::Canvas canvas(web_canvas); gfx::Canvas canvas(web_canvas);
bool scale_canvas = IsDIPEnabled() && scale_canvas_; bool scale_canvas = scale_canvas_;
if (scale_canvas) { if (scale_canvas) {
canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_), canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_),
SkFloatToScalar(device_scale_factor_)); SkFloatToScalar(device_scale_factor_));
...@@ -560,25 +558,19 @@ void Layer::CreateWebLayer() { ...@@ -560,25 +558,19 @@ void Layer::CreateWebLayer() {
} }
void Layer::RecomputeTransform() { void Layer::RecomputeTransform() {
if (IsDIPEnabled()) { ui::Transform scale_translate;
ui::Transform scale_translate; scale_translate.matrix().set3x3(device_scale_factor_, 0, 0,
scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, 0, device_scale_factor_, 0,
0, device_scale_factor_, 0, 0, 0, 1);
0, 0, 1); // Start with the inverse matrix of above.
// Start with the inverse matrix of above. Transform transform;
Transform transform; transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0,
transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, 0, 1.0f / device_scale_factor_, 0,
0, 1.0f / device_scale_factor_, 0, 0, 0, 1);
0, 0, 1); transform.ConcatTransform(transform_);
transform.ConcatTransform(transform_); transform.ConcatTranslate(bounds_.x(), bounds_.y());
transform.ConcatTranslate(bounds_.x(), bounds_.y()); transform.ConcatTransform(scale_translate);
transform.ConcatTransform(scale_translate); web_layer_.setTransform(transform.matrix());
web_layer_.setTransform(transform.matrix());
} else {
Transform t = transform_;
t.ConcatTranslate(bounds_.x(), bounds_.y());
web_layer_.setTransform(t.matrix());
}
} }
void Layer::RecomputeDrawsContentAndUVRect() { void Layer::RecomputeDrawsContentAndUVRect() {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "ui/compositor/compositor_observer.h" #include "ui/compositor/compositor_observer.h"
#include "ui/compositor/compositor_setup.h" #include "ui/compositor/compositor_setup.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/test/test_compositor_host.h" #include "ui/compositor/test/test_compositor_host.h"
...@@ -1066,8 +1065,6 @@ TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) { ...@@ -1066,8 +1065,6 @@ TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
} }
TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
test::ScopedDIPEnablerForTest enable;
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220))); gfx::Rect(10, 20, 200, 220)));
TestLayerDelegate root_delegate; TestLayerDelegate root_delegate;
...@@ -1155,7 +1152,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { ...@@ -1155,7 +1152,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
} }
TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
test::ScopedDIPEnablerForTest enable;
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220))); gfx::Rect(10, 20, 200, 220)));
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
...@@ -1201,7 +1197,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { ...@@ -1201,7 +1197,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
// Tests layer::set_scale_canvas(false). // Tests layer::set_scale_canvas(false).
TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) { TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) {
test::ScopedDIPEnablerForTest enable;
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220))); gfx::Rect(10, 20, 200, 220)));
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment