1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/testing/assertions_skia.h"
6
7namespace flutter {
8namespace testing {
9
10std::ostream& operator<<(std::ostream& os, const SkClipOp& o) {
11 switch (o) {
12 case SkClipOp::kDifference:
13 os << "ClipOpDifference";
14 break;
15 case SkClipOp::kIntersect:
16 os << "ClipOpIntersect";
17 break;
18#ifdef SK_SUPPORT_DEPRECATED_CLIPOPS
19 case SkClipOp::kUnion_deprecated:
20 os << "ClipOpUnion_deprecated";
21 break;
22 case SkClipOp::kXOR_deprecated:
23 os << "ClipOpXOR_deprecated";
24 break;
25 case SkClipOp::kReverseDifference_deprecated:
26 os << "ClipOpReverseDifference_deprecated";
27 break;
28 case SkClipOp::kReplace_deprecated:
29 os << "ClipOpReplace_deprectaed";
30 break;
31#else
32 case SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway2:
33 os << "ClipOpReserved2";
34 break;
35 case SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway3:
36 os << "ClipOpReserved3";
37 break;
38 case SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway4:
39 os << "ClipOpReserved4";
40 break;
41 case SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway5:
42 os << "ClipOpReserved5";
43 break;
44#endif
45 }
46 return os;
47}
48
49std::ostream& operator<<(std::ostream& os, const SkMatrix& m) {
50 os << std::endl;
51 os << "Scale X: " << m[SkMatrix::kMScaleX] << ", ";
52 os << "Skew X: " << m[SkMatrix::kMSkewX] << ", ";
53 os << "Trans X: " << m[SkMatrix::kMTransX] << std::endl;
54 os << "Skew Y: " << m[SkMatrix::kMSkewY] << ", ";
55 os << "Scale Y: " << m[SkMatrix::kMScaleY] << ", ";
56 os << "Trans Y: " << m[SkMatrix::kMTransY] << std::endl;
57 os << "Persp X: " << m[SkMatrix::kMPersp0] << ", ";
58 os << "Persp Y: " << m[SkMatrix::kMPersp1] << ", ";
59 os << "Persp Z: " << m[SkMatrix::kMPersp2];
60 os << std::endl;
61 return os;
62}
63
64std::ostream& operator<<(std::ostream& os, const SkM44& m) {
65 os << m.rc(0, 0) << ", " << m.rc(0, 1) << ", " << m.rc(0, 2) << ", "
66 << m.rc(0, 3) << std::endl;
67 os << m.rc(1, 0) << ", " << m.rc(1, 1) << ", " << m.rc(1, 2) << ", "
68 << m.rc(1, 3) << std::endl;
69 os << m.rc(2, 0) << ", " << m.rc(2, 1) << ", " << m.rc(2, 2) << ", "
70 << m.rc(2, 3) << std::endl;
71 os << m.rc(3, 0) << ", " << m.rc(3, 1) << ", " << m.rc(3, 2) << ", "
72 << m.rc(3, 3);
73 return os;
74}
75
76std::ostream& operator<<(std::ostream& os, const SkVector3& v) {
77 return os << v.x() << ", " << v.y() << ", " << v.z();
78}
79
80std::ostream& operator<<(std::ostream& os, const SkRect& r) {
81 return os << "LTRB: " << r.fLeft << ", " << r.fTop << ", " << r.fRight << ", "
82 << r.fBottom;
83}
84
85std::ostream& operator<<(std::ostream& os, const SkRRect& r) {
86 return os << "LTRB: " << r.rect().fLeft << ", " << r.rect().fTop << ", "
87 << r.rect().fRight << ", " << r.rect().fBottom;
88}
89
90std::ostream& operator<<(std::ostream& os, const SkPath& r) {
91 return os << "Valid: " << r.isValid()
92 << ", FillType: " << static_cast<int>(r.getFillType())
93 << ", Bounds: " << r.getBounds();
94}
95
96std::ostream& operator<<(std::ostream& os, const SkPoint& r) {
97 return os << "XY: " << r.fX << ", " << r.fY;
98}
99
100std::ostream& operator<<(std::ostream& os, const SkISize& size) {
101 return os << size.width() << ", " << size.height();
102}
103
104std::ostream& operator<<(std::ostream& os, const SkColor4f& r) {
105 return os << r.fR << ", " << r.fG << ", " << r.fB << ", " << r.fA;
106}
107
108std::ostream& operator<<(std::ostream& os, const SkPaint& r) {
109 return os << "Color: " << r.getColor4f() << ", Style: " << r.getStyle()
110 << ", AA: " << r.isAntiAlias() << ", Shader: " << r.getShader();
111}
112
113} // namespace testing
114} // namespace flutter
115