| 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" | |
| 15 #include "third_party/skia/include/core/SkRRect.h" | 14 #include "third_party/skia/include/core/SkRRect.h" |
| 16 | 15 |
| 17 namespace cc { | 16 namespace cc { |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkClipOp) { | |
| 21 // explicitly list the clipops, as this list will be reduced overtime | |
| 22 // as skia constricts the valid ops for clipping | |
| 23 // https://bugs.chromium.org/p/skia/issues/detail?id=3191 | |
| 24 const SkClipOp ops[] = { | |
| 25 SkClipOp::kDifference, SkClipOp::kIntersect, | |
| 26 }; | |
| 27 for (SkClipOp op : ops) { | |
| 28 EXPECT_EQ(op, SkClipOpFromProto(SkClipOpToProto(op))); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkXfermodeMode) { | 19 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkXfermodeMode) { |
| 33 for (size_t i = 0; i < static_cast<size_t>(SkBlendMode::kLastMode); i++) { | 20 for (size_t i = 0; i < static_cast<size_t>(SkBlendMode::kLastMode); i++) { |
| 34 SkBlendMode mode = static_cast<SkBlendMode>(i); | 21 SkBlendMode mode = static_cast<SkBlendMode>(i); |
| 35 EXPECT_EQ(mode, SkXfermodeModeFromProto(SkXfermodeModeToProto(mode))); | 22 EXPECT_EQ(mode, SkXfermodeModeFromProto(SkXfermodeModeToProto(mode))); |
| 36 } | 23 } |
| 37 } | 24 } |
| 38 | 25 |
| 39 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkRRect) { | 26 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkRRect) { |
| 40 SkRect rect = SkRect::MakeXYWH(0, 10, 15, 20); | 27 SkRect rect = SkRect::MakeXYWH(0, 10, 15, 20); |
| 41 SkVector radii[4]; | 28 SkVector radii[4]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 71 proto.radii_lower_left().x()); | 58 proto.radii_lower_left().x()); |
| 72 EXPECT_EQ(rrect.radii(SkRRect::kLowerLeft_Corner).y(), | 59 EXPECT_EQ(rrect.radii(SkRRect::kLowerLeft_Corner).y(), |
| 73 proto.radii_lower_left().y()); | 60 proto.radii_lower_left().y()); |
| 74 | 61 |
| 75 // Test ProtoToRRect | 62 // Test ProtoToRRect |
| 76 EXPECT_EQ(rrect, ProtoToSkRRect(proto)); | 63 EXPECT_EQ(rrect, ProtoToSkRRect(proto)); |
| 77 } | 64 } |
| 78 | 65 |
| 79 } // namespace | 66 } // namespace |
| 80 } // namespace cc | 67 } // namespace cc |
| OLD | NEW |