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

Unified Diff: ash/display/display_controller.cc

Issue 14142011: Round near zero value in rotation matrix to zero (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | ash/display/display_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 3d129450300e79555a3c2e5fe20f023fb8e75f75..454290dbe05b7bbe06f4c3154179ea7bd979ab96 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -5,6 +5,7 @@
#include "ash/display/display_controller.h"
#include <algorithm>
+#include <cmath>
#include <map>
#include "ash/ash_root_window_transformer.h"
@@ -24,6 +25,7 @@
#include "base/stringprintf.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
+#include "third_party/skia/include/utils/SkMatrix44.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
@@ -123,6 +125,18 @@ internal::DisplayManager* GetDisplayManager() {
return Shell::GetInstance()->display_manager();
}
+// Round near zero value to zero.
+void RoundNearZero(gfx::Transform* transform) {
+ const float kEpsilon = 0.001f;
+ SkMatrix44& matrix = transform->matrix();
+ for (int x = 0; x < 4; ++x) {
+ for (int y = 0; y < 4; ++y) {
+ if (std::abs(SkMScalarToFloat(matrix.get(x, y))) < kEpsilon)
+ matrix.set(x, y, SkFloatToMScalar(0.0f));
+ }
+ }
+}
+
void RotateRootWindow(aura::RootWindow* root_window,
const gfx::Display& display,
const internal::DisplayInfo& info) {
@@ -152,7 +166,6 @@ void RotateRootWindow(aura::RootWindow* root_window,
case gfx::Display::ROTATE_90:
rotate.Translate(display.bounds().height() - one_pixel, 0);
rotate.Rotate(90);
- // Rotate 270 instead of 90 as it will cause calcuration error.
reverse_rotate.Rotate(270);
reverse_rotate.Translate(-(display.bounds().height() - one_pixel), 0);
break;
@@ -171,6 +184,9 @@ void RotateRootWindow(aura::RootWindow* root_window,
-(display.bounds().height() - one_pixel));
break;
}
+ RoundNearZero(&rotate);
+ RoundNearZero(&reverse_rotate);
+
scoped_ptr<aura::RootWindowTransformer> transformer(
new AshRootWindowTransformer(root_window,
rotate,
« no previous file with comments | « no previous file | ash/display/display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698