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

Side by Side Diff: third_party/WebKit/Source/platform/testing/TransformPrinters.cpp

Issue 2265453003: Add platform/transforms pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update per reviewer comments Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/testing/TransformPrinters.h" 5 #include "platform/testing/TransformPrinters.h"
6 6
7 #include "platform/transforms/AffineTransform.h" 7 #include "platform/transforms/AffineTransform.h"
8 #include "platform/transforms/TransformationMatrix.h" 8 #include "platform/transforms/TransformationMatrix.h"
9 #include "wtf/text/WTFString.h"
9 #include <ostream> // NOLINT 10 #include <ostream> // NOLINT
10 11
11 namespace blink { 12 namespace blink {
12 13
13 void PrintTo(const AffineTransform& transform, std::ostream* os) 14 void PrintTo(const AffineTransform& transform, std::ostream* os)
14 { 15 {
15 AffineTransform::DecomposedType decomposition; 16 *os << transform.toString();
16 if (!transform.decompose(decomposition)) {
17 *os << "AffineTransform(degenerate)";
18 return;
19 }
20
21 if (transform.isIdentityOrTranslation()) {
22 *os << "AffineTransform(translation=(" << decomposition.translateX << ", " << decomposition.translateY << "))";
23 return;
24 }
25
26 *os << "AffineTransform("
27 << "translation=(" << decomposition.translateX << "," << decomposition.t ranslateY << ")"
28 << ", scale=(" << decomposition.scaleX << "," << decomposition.scaleY << ")"
29 << ", angle=(" << decomposition.angle << ")"
30 << ", remainder=(" << decomposition.remainderA << "," << decomposition.r emainderB << "," << decomposition.remainderC << "," << decomposition.remainderD << ")"
31 << ", translate=(" << decomposition.translateX << "," << decomposition.t ranslateY << ")"
32 << ")";
33 } 17 }
34 18
35 void PrintTo(const TransformationMatrix& matrix, std::ostream* os) 19 void PrintTo(const TransformationMatrix& matrix, std::ostream* os)
36 { 20 {
37 TransformationMatrix::DecomposedType decomposition; 21 *os << matrix.toString();
38 if (!matrix.decompose(decomposition)) {
39 *os << "TransformationMatrix(degenerate)";
40 return;
41 }
42
43 if (matrix.isIdentityOrTranslation()) {
44 *os << "TransformationMatrix(translation=(" << decomposition.translateX << "," << decomposition.translateY << "," << decomposition.translateZ << "))";
45 return;
46 }
47
48 *os << "TransformationMatrix("
49 << "translation=(" << decomposition.translateX << "," << decomposition.t ranslateY << "," << decomposition.translateZ << ")"
50 << ", scale=(" << decomposition.scaleX << "," << decomposition.scaleY << "," << decomposition.scaleZ << ")"
51 << ", skew=(" << decomposition.skewXY << "," << decomposition.skewXZ << "," << decomposition.skewYZ << ")"
52 << ", quaternion=(" << decomposition.quaternionX << "," << decomposition .quaternionY << "," << decomposition.quaternionZ << "," << decomposition.quatern ionW << ")"
53 << ", perspective=(" << decomposition.perspectiveX << "," << decompositi on.perspectiveY << "," << decomposition.perspectiveZ << "," << decomposition.per spectiveW << ")"
54 << ")";
55 } 22 }
56 23
57 } // namespace blink 24 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698