| Index: remoting/client/simple_matrix.cc
|
| diff --git a/remoting/client/simple_matrix.cc b/remoting/client/simple_matrix.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b4615fb7e22c5debca7c95ffa22571ecbf2d0d8f
|
| --- /dev/null
|
| +++ b/remoting/client/simple_matrix.cc
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "remoting/client/simple_matrix.h"
|
| +
|
| +namespace remoting {
|
| +
|
| +SimpleMatrix::SimpleMatrix(float scale, const Vector2D& offset)
|
| + : scale_(scale), offset_(offset) {}
|
| +
|
| +SimpleMatrix::~SimpleMatrix() {}
|
| +
|
| +Point SimpleMatrix::MapPoint(const Point& point) const {
|
| + float x = scale_ * point.x + offset_.x;
|
| + float y = scale_ * point.y + offset_.y;
|
| + return {x, y};
|
| +}
|
| +
|
| +Vector2D SimpleMatrix::MapVector(const Vector2D& vector) const {
|
| + float x = scale_ * vector.x;
|
| + float y = scale_ * vector.y;
|
| + return {x, y};
|
| +}
|
| +
|
| +void SimpleMatrix::SetScale(float scale) {
|
| + scale_ = scale;
|
| +}
|
| +
|
| +float SimpleMatrix::GetScale() const {
|
| + return scale_;
|
| +}
|
| +
|
| +void SimpleMatrix::PostScale(const Point& pivot, float scale) {
|
| + scale_ *= scale;
|
| + offset_.x += (1.f - scale) * pivot.x;
|
| + offset_.y += (1.f - scale) * pivot.y;
|
| +}
|
| +
|
| +void SimpleMatrix::PostTranslate(const Vector2D& delta) {
|
| + offset_.x += delta.x;
|
| + offset_.y += delta.y;
|
| +}
|
| +
|
| +SimpleMatrix SimpleMatrix::Invert() const {
|
| + return SimpleMatrix(1.f / scale_, {-offset_.x / scale_, -offset_.y / scale_});
|
| +}
|
| +
|
| +std::array<float, 9> SimpleMatrix::ToMatrixArray() const {
|
| + return {{scale_, 0, offset_.x, // Row 1
|
| + 0, scale_, offset_.y, // Row 2
|
| + 0, 0, 1}};
|
| +}
|
| +
|
| +} // namespace remoting
|
|
|