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

Unified Diff: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc

Issue 8400059: Revert 107715 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
===================================================================
--- chrome/browser/ui/touch/frame/touch_browser_frame_view.cc (revision 107719)
+++ chrome/browser/ui/touch/frame/touch_browser_frame_view.cc (working copy)
@@ -4,10 +4,46 @@
#include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h"
+#include "chrome/browser/ui/touch/animation/screen_rotation_setter.h"
#include "views/controls/button/image_button.h"
#include "views/desktop/desktop_window_view.h"
-#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/transform.h"
+namespace {
+
+ui::Transform SideToTransform(sensors::ScreenOrientation::Side side,
+ const ui::Transform& old_transform,
+ const gfx::Size& size) {
+ gfx::Point origin;
+ gfx::Point bottom_right(size.width(), size.height());
+ old_transform.TransformPoint(origin);
+ old_transform.TransformPoint(bottom_right);
+ int original_width = abs(origin.x() - bottom_right.x());
+ int original_height = abs(origin.y() - bottom_right.y());
+ ui::Transform to_return;
+ switch (side) {
+ case sensors::ScreenOrientation::TOP: break;
+ case sensors::ScreenOrientation::RIGHT:
+ to_return.ConcatRotate(90);
+ to_return.ConcatTranslate(original_width, 0);
+ break;
+ case sensors::ScreenOrientation::LEFT:
+ to_return.ConcatRotate(-90);
+ to_return.ConcatTranslate(0, original_height);
+ break;
+ case sensors::ScreenOrientation::BOTTOM:
+ to_return.ConcatRotate(180);
+ to_return.ConcatTranslate(original_width, original_height);
+ break;
+ default:
+ to_return = old_transform;
+ break;
+ }
+ return to_return;
+}
+
+} // namespace
+
// static
const char TouchBrowserFrameView::kViewClassName[] =
"browser/ui/touch/frame/TouchBrowserFrameView";
@@ -19,9 +55,11 @@
BrowserView* browser_view)
: OpaqueBrowserFrameView(frame, browser_view),
initialized_screen_rotation_(false) {
+ sensors::Provider::GetInstance()->AddListener(this);
}
TouchBrowserFrameView::~TouchBrowserFrameView() {
+ sensors::Provider::GetInstance()->RemoveListener(this);
}
std::string TouchBrowserFrameView::GetClassName() const {
@@ -47,3 +85,31 @@
return false;
}
+
+void TouchBrowserFrameView::OnScreenOrientationChanged(
+ const sensors::ScreenOrientation& change) {
+ // In views desktop mode, then the desktop_window_view will not be NULL and
+ // is the view to be rotated.
+ views::View* to_rotate =
+ views::desktop::DesktopWindowView::desktop_window_view;
+
+ if (!to_rotate) {
+ // Otherwise, rotate the widget's view.
+ views::Widget* widget = GetWidget();
+ to_rotate = widget->GetRootView();
+ }
+
+ if (!initialized_screen_rotation_) {
+ to_rotate->SetPaintToLayer(true);
+ to_rotate->SetLayerPropertySetter(
+ ScreenRotationSetterFactory::Create(to_rotate));
+ initialized_screen_rotation_ = true;
+ }
+
+ const ui::Transform& old_xform = to_rotate->GetTransform();
+ const ui::Transform& new_xform = SideToTransform(change.upward,
+ old_xform,
+ to_rotate->size());
+ if (old_xform != new_xform)
+ to_rotate->SetTransform(new_xform);
+}
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698