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 @@
#include "ui/aura/client/activation_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/monitor.h"
......@@ -37,7 +36,6 @@ typedef ash::test::AshTestBase DIPTest;
// Test if the WM sets correct work area under different density.
TEST_F(DIPTest, MAYBE_WorkArea) {
ui::test::ScopedDIPEnablerForTest enable;
ChangeMonitorConfig(1.0f, gfx::Rect(0, 0, 1000, 900));
aura::RootWindow* root = Shell::GetRootWindow();
......
......@@ -112,8 +112,7 @@ void MonitorChangeObserverX11::NotifyMonitorChange() {
gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height)));
float device_scale_factor = 1.0f;
if (ui::IsDIPEnabled() &&
output_info->mm_width > 0 &&
if (output_info->mm_width > 0 &&
(kInchInMm * mode->width / output_info->mm_width) >
kHighDensityDIPThreshold) {
device_scale_factor = 2.0f;
......
......@@ -280,14 +280,10 @@ bool RootWindow::DispatchKeyEvent(KeyEvent* event) {
bool RootWindow::DispatchScrollEvent(ScrollEvent* event) {
DispatchHeldMouseMove();
if (ui::IsDIPEnabled()) {
float scale = ui::GetDeviceScaleFactor(layer());
ui::Transform transform = layer()->transform();
transform.ConcatScale(scale, scale);
event->UpdateForRootTransform(transform);
} else {
event->UpdateForRootTransform(layer()->transform());
}
last_mouse_location_ = event->location();
synthesize_mouse_move_ = false;
......@@ -311,14 +307,10 @@ bool RootWindow::DispatchScrollEvent(ScrollEvent* event) {
bool RootWindow::DispatchTouchEvent(TouchEvent* event) {
DispatchHeldMouseMove();
if (ui::IsDIPEnabled()) {
float scale = ui::GetDeviceScaleFactor(layer());
ui::Transform transform = layer()->transform();
transform.ConcatScale(scale, scale);
event->UpdateForRootTransform(transform);
} else {
event->UpdateForRootTransform(layer()->transform());
}
bool handled = false;
ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
Window* target = capture_window_;
......@@ -934,14 +926,10 @@ bool RootWindow::IsFocusedWindow(const Window* window) const {
}
bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) {
if (ui::IsDIPEnabled()) {
float scale = ui::GetDeviceScaleFactor(layer());
ui::Transform transform = layer()->transform();
transform.ConcatScale(scale, scale);
event->UpdateForRootTransform(transform);
} else {
event->UpdateForRootTransform(layer()->transform());
}
Window* target =
mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_;
if (!target)
......
......@@ -242,7 +242,7 @@ void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
host_.setViewportSize(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;
if (root_layer_)
root_layer_->OnDeviceScaleFactorChanged(scale);
......
......@@ -10,9 +10,6 @@ const char kDisableTestCompositor[] = "disable-test-compositor";
const char kDisableUIVsync[] = "disable-ui-vsync";
// Enable Density Independent Pixel coordinates.
const char kUIEnableDIP[] = "ui-enable-dip";
const char kUIEnablePartialSwap[] = "ui-enable-partial-swap";
// Show FPS counter.
......
......@@ -12,7 +12,6 @@ namespace switches {
COMPOSITOR_EXPORT extern const char kDisableTestCompositor[];
COMPOSITOR_EXPORT extern const char kDisableUIVsync[];
COMPOSITOR_EXPORT extern const char kUIEnableDIP[];
COMPOSITOR_EXPORT extern const char kUIEnablePartialSwap[];
COMPOSITOR_EXPORT extern const char kUIShowFPSCounter[];
COMPOSITOR_EXPORT extern const char kUIShowLayerBorders[];
......
......@@ -15,91 +15,42 @@
#include "ui/gfx/rect.h"
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) {
if (!IsDIPEnabled())
return 1.0f;
return layer->device_scale_factor();
}
gfx::Point ConvertPointToDIP(const Layer* layer,
const gfx::Point& point_in_pixel) {
if (IsDIPEnabled())
return point_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer));
else
return point_in_pixel;
}
gfx::Size ConvertSizeToDIP(const Layer* layer,
const gfx::Size& size_in_pixel) {
if (IsDIPEnabled())
return size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer));
else
return size_in_pixel;
}
gfx::Rect ConvertRectToDIP(const Layer* layer,
const gfx::Rect& rect_in_pixel) {
if (IsDIPEnabled()) {
float scale = 1.0f / GetDeviceScaleFactor(layer);
return gfx::Rect(rect_in_pixel.origin().Scale(scale),
rect_in_pixel.size().Scale(scale));
} else {
return rect_in_pixel;
}
}
gfx::Point ConvertPointToPixel(const Layer* layer,
const gfx::Point& point_in_dip) {
if (IsDIPEnabled()) {
return point_in_dip.Scale(GetDeviceScaleFactor(layer));
} else {
return point_in_dip;
}
}
gfx::Size ConvertSizeToPixel(const Layer* layer,
const gfx::Size& size_in_dip) {
if (IsDIPEnabled()) {
return size_in_dip.Scale(GetDeviceScaleFactor(layer));
} else {
return size_in_dip;
}
}
gfx::Rect ConvertRectToPixel(const Layer* layer,
const gfx::Rect& rect_in_dip) {
if (IsDIPEnabled()) {
float scale = GetDeviceScaleFactor(layer);
return gfx::Rect(rect_in_dip.origin().Scale(scale),
rect_in_dip.size().Scale(scale));
} else {
return rect_in_dip;
}
}
} // namespace ui
......@@ -16,26 +16,8 @@ class Rect;
} // namespace gfx
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;
// True if DIP is enabled.
COMPOSITOR_EXPORT bool IsDIPEnabled();
COMPOSITOR_EXPORT float GetDeviceScaleFactor(const Layer* layer);
// Utility functions that convert point/size/rect between
......
......@@ -97,7 +97,7 @@ void Layer::SetCompositor(Compositor* compositor) {
DCHECK(!compositor || compositor->root_layer() == this);
DCHECK(!parent_);
compositor_ = compositor;
if (IsDIPEnabled() && compositor)
if (compositor)
OnDeviceScaleFactorChanged(compositor->device_scale_factor());
}
......@@ -108,7 +108,6 @@ void Layer::Add(Layer* child) {
child->parent_ = this;
children_.push_back(child);
web_layer_.addChild(child->web_layer_);
if (IsDIPEnabled())
child->OnDeviceScaleFactorChanged(device_scale_factor_);
}
......@@ -338,7 +337,7 @@ void Layer::SendDamagedRects() {
// TODO(pkotwicz): Remove this once we are no longer linearly upscaling
// 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 = damaged.Intersect(bounds_);
}
......@@ -370,7 +369,6 @@ void Layer::SuppressPaint() {
}
void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) {
CHECK(IsDIPEnabled());
if (device_scale_factor_ == device_scale_factor)
return;
device_scale_factor_ = device_scale_factor;
......@@ -387,7 +385,7 @@ void Layer::paintContents(WebKit::WebCanvas* web_canvas,
const WebKit::WebRect& clip) {
TRACE_EVENT0("ui", "Layer::paintContents");
gfx::Canvas canvas(web_canvas);
bool scale_canvas = IsDIPEnabled() && scale_canvas_;
bool scale_canvas = scale_canvas_;
if (scale_canvas) {
canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_),
SkFloatToScalar(device_scale_factor_));
......@@ -560,7 +558,6 @@ void Layer::CreateWebLayer() {
}
void Layer::RecomputeTransform() {
if (IsDIPEnabled()) {
ui::Transform scale_translate;
scale_translate.matrix().set3x3(device_scale_factor_, 0, 0,
0, device_scale_factor_, 0,
......@@ -574,11 +571,6 @@ void Layer::RecomputeTransform() {
transform.ConcatTranslate(bounds_.x(), bounds_.y());
transform.ConcatTransform(scale_translate);
web_layer_.setTransform(transform.matrix());
} else {
Transform t = transform_;
t.ConcatTranslate(bounds_.x(), bounds_.y());
web_layer_.setTransform(t.matrix());
}
}
void Layer::RecomputeDrawsContentAndUVRect() {
......
......@@ -14,7 +14,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/compositor_setup.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/test/test_compositor_host.h"
......@@ -1066,8 +1065,6 @@ TEST_F(LayerWithDelegateTest, SchedulePaintFromOnPaintLayer) {
}
TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
test::ScopedDIPEnablerForTest enable;
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220)));
TestLayerDelegate root_delegate;
......@@ -1155,7 +1152,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) {
}
TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
test::ScopedDIPEnablerForTest enable;
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220)));
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE,
......@@ -1201,7 +1197,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) {
// Tests layer::set_scale_canvas(false).
TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) {
test::ScopedDIPEnablerForTest enable;
scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE,
gfx::Rect(10, 20, 200, 220)));
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