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

Side by Side Diff: remoting/client/view_matrix.cc

Issue 2857113002: [Remoting Client] Fix scaling bug in ViewMatrix (Closed)
Patch Set: Resolve Feedback Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « remoting/client/desktop_viewport_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/view_matrix.h" 5 #include "remoting/client/view_matrix.h"
6 6
7 namespace remoting { 7 namespace remoting {
8 8
9 ViewMatrix::ViewMatrix() : ViewMatrix(0.f, {0.f, 0.f}) {} 9 ViewMatrix::ViewMatrix() : ViewMatrix(0.f, {0.f, 0.f}) {}
10 10
(...skipping 17 matching lines...) Expand all
28 void ViewMatrix::SetScale(float scale) { 28 void ViewMatrix::SetScale(float scale) {
29 scale_ = scale; 29 scale_ = scale;
30 } 30 }
31 31
32 float ViewMatrix::GetScale() const { 32 float ViewMatrix::GetScale() const {
33 return scale_; 33 return scale_;
34 } 34 }
35 35
36 void ViewMatrix::PostScale(const Point& pivot, float scale) { 36 void ViewMatrix::PostScale(const Point& pivot, float scale) {
37 scale_ *= scale; 37 scale_ *= scale;
38 offset_.x *= scale;
38 offset_.x += (1.f - scale) * pivot.x; 39 offset_.x += (1.f - scale) * pivot.x;
40 offset_.y *= scale;
39 offset_.y += (1.f - scale) * pivot.y; 41 offset_.y += (1.f - scale) * pivot.y;
40 } 42 }
41 43
42 void ViewMatrix::PostTranslate(const Vector2D& delta) { 44 void ViewMatrix::PostTranslate(const Vector2D& delta) {
43 offset_.x += delta.x; 45 offset_.x += delta.x;
44 offset_.y += delta.y; 46 offset_.y += delta.y;
45 } 47 }
46 48
47 ViewMatrix ViewMatrix::Invert() const { 49 ViewMatrix ViewMatrix::Invert() const {
48 return ViewMatrix(1.f / scale_, {-offset_.x / scale_, -offset_.y / scale_}); 50 return ViewMatrix(1.f / scale_, {-offset_.x / scale_, -offset_.y / scale_});
49 } 51 }
50 52
51 std::array<float, 9> ViewMatrix::ToMatrixArray() const { 53 std::array<float, 9> ViewMatrix::ToMatrixArray() const {
52 return {{scale_, 0, offset_.x, // Row 1 54 return {{scale_, 0, offset_.x, // Row 1
53 0, scale_, offset_.y, // Row 2 55 0, scale_, offset_.y, // Row 2
54 0, 0, 1}}; 56 0, 0, 1}};
55 } 57 }
56 58
57 bool ViewMatrix::IsEmpty() const { 59 bool ViewMatrix::IsEmpty() const {
58 return scale_ == 0.f && offset_.x == 0.f && offset_.y == 0.f; 60 return scale_ == 0.f && offset_.x == 0.f && offset_.y == 0.f;
59 } 61 }
60 62
61 } // namespace remoting 63 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/desktop_viewport_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698