michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/WidgetUtils.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: gfx::Matrix michael@0: ComputeTransformForRotation(const nsIntRect& aBounds, michael@0: ScreenRotation aRotation) michael@0: { michael@0: gfx::Matrix transform; michael@0: switch (aRotation) { michael@0: case ROTATION_0: michael@0: break; michael@0: case ROTATION_90: michael@0: transform.Translate(aBounds.width, 0); michael@0: transform = gfx::Matrix::Rotation(M_PI / 2) * transform; michael@0: break; michael@0: case ROTATION_180: michael@0: transform.Translate(aBounds.width, aBounds.height); michael@0: transform = gfx::Matrix::Rotation(M_PI) * transform; michael@0: break; michael@0: case ROTATION_270: michael@0: transform.Translate(0, aBounds.height); michael@0: transform = gfx::Matrix::Rotation(M_PI * 3 / 2) * transform; michael@0: break; michael@0: default: michael@0: MOZ_CRASH("Unknown rotation"); michael@0: } michael@0: return transform; michael@0: } michael@0: michael@0: } // namespace mozilla