OLD | NEW |
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 "cc/proto/skia_conversions.h" | 5 #include "cc/proto/skia_conversions.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/proto/skregion.pb.h" | 9 #include "cc/proto/skregion.pb.h" |
10 #include "cc/proto/skrrect.pb.h" | 10 #include "cc/proto/skrrect.pb.h" |
11 #include "cc/proto/skxfermode.pb.h" | 11 #include "cc/proto/skxfermode.pb.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/skia/include/core/SkBlendMode.h" | 13 #include "third_party/skia/include/core/SkBlendMode.h" |
14 #include "third_party/skia/include/core/SkClipOp.h" | 14 #include "third_party/skia/include/core/SkClipOp.h" |
15 #include "third_party/skia/include/core/SkRRect.h" | 15 #include "third_party/skia/include/core/SkRRect.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 namespace { | 18 namespace { |
19 | 19 |
20 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkClipOp) { | 20 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkClipOp) { |
21 // explicitly list the clipops, as this list will be reduced overtime | 21 // explicitly list the clipops, as this list will be reduced overtime |
22 // as skia constricts the valid ops for clipping | 22 // as skia constricts the valid ops for clipping |
23 // https://bugs.chromium.org/p/skia/issues/detail?id=3191 | 23 // https://bugs.chromium.org/p/skia/issues/detail?id=3191 |
24 const SkClipOp ops[] = { | 24 const SkClipOp ops[] = { |
25 SkClipOp::kDifference, SkClipOp::kIntersect, SkClipOp::kUnion, | 25 SkClipOp::kDifference, SkClipOp::kIntersect, |
26 SkClipOp::kXOR, SkClipOp::kReverseDifference, SkClipOp::kReplace, | |
27 }; | 26 }; |
28 for (SkClipOp op : ops) { | 27 for (SkClipOp op : ops) { |
29 EXPECT_EQ(op, SkClipOpFromProto(SkClipOpToProto(op))); | 28 EXPECT_EQ(op, SkClipOpFromProto(SkClipOpToProto(op))); |
30 } | 29 } |
31 } | 30 } |
32 | 31 |
33 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkXfermodeMode) { | 32 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkXfermodeMode) { |
34 for (size_t i = 0; i < static_cast<size_t>(SkBlendMode::kLastMode); i++) { | 33 for (size_t i = 0; i < static_cast<size_t>(SkBlendMode::kLastMode); i++) { |
35 SkBlendMode mode = static_cast<SkBlendMode>(i); | 34 SkBlendMode mode = static_cast<SkBlendMode>(i); |
36 EXPECT_EQ(mode, SkXfermodeModeFromProto(SkXfermodeModeToProto(mode))); | 35 EXPECT_EQ(mode, SkXfermodeModeFromProto(SkXfermodeModeToProto(mode))); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 proto.radii_lower_left().x()); | 71 proto.radii_lower_left().x()); |
73 EXPECT_EQ(rrect.radii(SkRRect::kLowerLeft_Corner).y(), | 72 EXPECT_EQ(rrect.radii(SkRRect::kLowerLeft_Corner).y(), |
74 proto.radii_lower_left().y()); | 73 proto.radii_lower_left().y()); |
75 | 74 |
76 // Test ProtoToRRect | 75 // Test ProtoToRRect |
77 EXPECT_EQ(rrect, ProtoToSkRRect(proto)); | 76 EXPECT_EQ(rrect, ProtoToSkRRect(proto)); |
78 } | 77 } |
79 | 78 |
80 } // namespace | 79 } // namespace |
81 } // namespace cc | 80 } // namespace cc |
OLD | NEW |