Commit 6250e6dd authored by oshima@chromium.org's avatar oshima@chromium.org

Use GetInverse

 Rotation matrixes are normalized (and will soon changed to handle 90 rotations in special form),
so no need to have separate inverse matrix.

BUG=222483
TEST=no functionality change.

Review URL: https://codereview.chromium.org/14361002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195238 0039d316-1c4b-4281-b951-d872f2087c98
parent 303d592d
...@@ -5,6 +5,8 @@ sky@chromium.org ...@@ -5,6 +5,8 @@ sky@chromium.org
per-file ash_strings.grd=* per-file ash_strings.grd=*
per-file ash_chromeos_strings.grdp=* per-file ash_chromeos_strings.grdp=*
per-file ash_root_window_transformer.*=oshima@chromium.org
per-file extended_desktop_unittest.*=oshima@chromium.org
per-file root_window_controller*=oshima@chromium.org per-file root_window_controller*=oshima@chromium.org
per-file screen_ash*=oshima@chromium.org per-file screen_ash*=oshima@chromium.org
per-file extended_desktop_unittest.*=oshima@chromium.org
...@@ -13,7 +13,6 @@ namespace ash { ...@@ -13,7 +13,6 @@ namespace ash {
AshRootWindowTransformer::AshRootWindowTransformer( AshRootWindowTransformer::AshRootWindowTransformer(
aura::RootWindow* root, aura::RootWindow* root,
const gfx::Transform& transform, const gfx::Transform& transform,
const gfx::Transform& inverted,
const gfx::Insets& host_insets, const gfx::Insets& host_insets,
float root_window_scale) float root_window_scale)
: root_window_(root), : root_window_(root),
...@@ -23,20 +22,18 @@ AshRootWindowTransformer::AshRootWindowTransformer( ...@@ -23,20 +22,18 @@ AshRootWindowTransformer::AshRootWindowTransformer(
root_window_->layer()->SetForceRenderSurface(root_window_scale_ != 1.0f); root_window_->layer()->SetForceRenderSurface(root_window_scale_ != 1.0f);
gfx::Transform translate; gfx::Transform translate;
invert_transform_ = inverted;
invert_transform_.Scale(root_window_scale_, root_window_scale_);
if (host_insets.top() != 0 || host_insets.left() != 0) { if (host_insets.top() != 0 || host_insets.left() != 0) {
float device_scale_factor = ui::GetDeviceScaleFactor(root_window_->layer()); float device_scale_factor = ui::GetDeviceScaleFactor(root_window_->layer());
float x_offset = host_insets.left() / device_scale_factor; float x_offset = host_insets.left() / device_scale_factor;
float y_offset = host_insets.top() / device_scale_factor; float y_offset = host_insets.top() / device_scale_factor;
translate.Translate(x_offset, y_offset); translate.Translate(x_offset, y_offset);
invert_transform_.Translate(-x_offset, -y_offset);
} }
float inverted_scale = 1.0f / root_window_scale_; float inverted_scale = 1.0f / root_window_scale_;
translate.Scale(inverted_scale, inverted_scale); translate.Scale(inverted_scale, inverted_scale);
transform_ = translate * transform; transform_ = translate * transform;
CHECK(transform_.GetInverse(&invert_transform_));
} }
gfx::Transform AshRootWindowTransformer::GetTransform() const { gfx::Transform AshRootWindowTransformer::GetTransform() const {
......
...@@ -22,7 +22,6 @@ class ASH_EXPORT AshRootWindowTransformer : public aura::RootWindowTransformer { ...@@ -22,7 +22,6 @@ class ASH_EXPORT AshRootWindowTransformer : public aura::RootWindowTransformer {
public: public:
AshRootWindowTransformer(aura::RootWindow* root, AshRootWindowTransformer(aura::RootWindow* root,
const gfx::Transform& transform, const gfx::Transform& transform,
const gfx::Transform& inverted,
const gfx::Insets& insets, const gfx::Insets& insets,
float root_window_scale); float root_window_scale);
// aura::RootWindowTransformer overrides: // aura::RootWindowTransformer overrides:
......
...@@ -151,12 +151,6 @@ void RotateRootWindow(aura::RootWindow* root_window, ...@@ -151,12 +151,6 @@ void RotateRootWindow(aura::RootWindow* root_window,
root_window->SetProperty(kRotationPropertyKey, info.rotation()); root_window->SetProperty(kRotationPropertyKey, info.rotation());
#endif #endif
gfx::Transform rotate; gfx::Transform rotate;
// TODO(oshima): Manually complute the inverse of the
// rotate+translate matrix to compensate for computation error in
// the inverted matrix. Ideally, SkMatrix should have special
// case handling for rotate+translate case. crbug.com/222483.
gfx::Transform reverse_rotate;
// The origin is (0, 0), so the translate width/height must be reduced by // The origin is (0, 0), so the translate width/height must be reduced by
// 1 pixel. // 1 pixel.
float one_pixel = 1.0f / display.device_scale_factor(); float one_pixel = 1.0f / display.device_scale_factor();
...@@ -166,31 +160,22 @@ void RotateRootWindow(aura::RootWindow* root_window, ...@@ -166,31 +160,22 @@ void RotateRootWindow(aura::RootWindow* root_window,
case gfx::Display::ROTATE_90: case gfx::Display::ROTATE_90:
rotate.Translate(display.bounds().height() - one_pixel, 0); rotate.Translate(display.bounds().height() - one_pixel, 0);
rotate.Rotate(90); rotate.Rotate(90);
reverse_rotate.Rotate(270);
reverse_rotate.Translate(-(display.bounds().height() - one_pixel), 0);
break; break;
case gfx::Display::ROTATE_270: case gfx::Display::ROTATE_270:
rotate.Translate(0, display.bounds().width() - one_pixel); rotate.Translate(0, display.bounds().width() - one_pixel);
rotate.Rotate(270); rotate.Rotate(270);
reverse_rotate.Rotate(90);
reverse_rotate.Translate(0, -(display.bounds().width() - one_pixel));
break; break;
case gfx::Display::ROTATE_180: case gfx::Display::ROTATE_180:
rotate.Translate(display.bounds().width() - one_pixel, rotate.Translate(display.bounds().width() - one_pixel,
display.bounds().height() - one_pixel); display.bounds().height() - one_pixel);
rotate.Rotate(180); rotate.Rotate(180);
reverse_rotate.Rotate(180);
reverse_rotate.Translate(-(display.bounds().width() - one_pixel),
-(display.bounds().height() - one_pixel));
break; break;
} }
RoundNearZero(&rotate); RoundNearZero(&rotate);
RoundNearZero(&reverse_rotate);
scoped_ptr<aura::RootWindowTransformer> transformer( scoped_ptr<aura::RootWindowTransformer> transformer(
new AshRootWindowTransformer(root_window, new AshRootWindowTransformer(root_window,
rotate, rotate,
reverse_rotate,
info.GetOverscanInsetsInPixel(), info.GetOverscanInsetsInPixel(),
info.ui_scale())); info.ui_scale()));
root_window->SetRootWindowTransformer(transformer.Pass()); root_window->SetRootWindowTransformer(transformer.Pass());
......
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