| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/proto/gfx_conversions.h" | 8 #include "cc/proto/gfx_conversions.h" |
| 9 #include "cc/proto/skclipop.pb.h" | 9 #include "cc/proto/skclipop.pb.h" |
| 10 #include "cc/proto/skrrect.pb.h" | 10 #include "cc/proto/skrrect.pb.h" |
| 11 #include "third_party/skia/include/core/SkRRect.h" | 11 #include "third_party/skia/include/core/SkRRect.h" |
| 12 #include "ui/gfx/skia_util.h" | 12 #include "ui/gfx/skia_util.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void SkPointToProto(const SkPoint& point, proto::PointF* proto) { | 18 void SkPointToProto(const SkPoint& point, proto::PointF* proto) { |
| 19 PointFToProto(gfx::PointF(point.x(), point.y()), proto); | 19 PointFToProto(gfx::PointF(point.x(), point.y()), proto); |
| 20 } | 20 } |
| 21 | 21 |
| 22 SkPoint ProtoToSkPoint(const proto::PointF& proto) { | 22 SkPoint ProtoToSkPoint(const proto::PointF& proto) { |
| 23 gfx::PointF point = ProtoToPointF(proto); | 23 gfx::PointF point = ProtoToPointF(proto); |
| 24 return SkPoint::Make(point.x(), point.y()); | 24 return SkPoint::Make(point.x(), point.y()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 SkClipOp SkClipOpFromProto(proto::SkClipOp::Op op) { | |
| 30 switch (op) { | |
| 31 case proto::SkClipOp::DIFFERENCE_: | |
| 32 return SkClipOp::kDifference; | |
| 33 case proto::SkClipOp::INTERSECT: | |
| 34 return SkClipOp::kIntersect; | |
| 35 default: | |
| 36 break; | |
| 37 } | |
| 38 return SkClipOp::kDifference; | |
| 39 } | |
| 40 | |
| 41 proto::SkClipOp::Op SkClipOpToProto(SkClipOp op) { | |
| 42 switch (op) { | |
| 43 case SkClipOp::kDifference: | |
| 44 return proto::SkClipOp::DIFFERENCE_; | |
| 45 case SkClipOp::kIntersect: | |
| 46 return proto::SkClipOp::INTERSECT; | |
| 47 default: | |
| 48 break; | |
| 49 } | |
| 50 return proto::SkClipOp::DIFFERENCE_; | |
| 51 } | |
| 52 | |
| 53 SkBlendMode SkXfermodeModeFromProto(proto::SkXfermode::Mode mode) { | 29 SkBlendMode SkXfermodeModeFromProto(proto::SkXfermode::Mode mode) { |
| 54 switch (mode) { | 30 switch (mode) { |
| 55 case proto::SkXfermode::CLEAR_: | 31 case proto::SkXfermode::CLEAR_: |
| 56 return SkBlendMode::kClear; | 32 return SkBlendMode::kClear; |
| 57 case proto::SkXfermode::SRC: | 33 case proto::SkXfermode::SRC: |
| 58 return SkBlendMode::kSrc; | 34 return SkBlendMode::kSrc; |
| 59 case proto::SkXfermode::DST: | 35 case proto::SkXfermode::DST: |
| 60 return SkBlendMode::kDst; | 36 return SkBlendMode::kDst; |
| 61 case proto::SkXfermode::SRC_OVER: | 37 case proto::SkXfermode::SRC_OVER: |
| 62 return SkBlendMode::kSrcOver; | 38 return SkBlendMode::kSrcOver; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 parsed_radii[SkRRect::kLowerRight_Corner] = | 177 parsed_radii[SkRRect::kLowerRight_Corner] = |
| 202 ProtoToSkPoint(proto.radii_lower_right()); | 178 ProtoToSkPoint(proto.radii_lower_right()); |
| 203 parsed_radii[SkRRect::kLowerLeft_Corner] = | 179 parsed_radii[SkRRect::kLowerLeft_Corner] = |
| 204 ProtoToSkPoint(proto.radii_lower_left()); | 180 ProtoToSkPoint(proto.radii_lower_left()); |
| 205 SkRRect rect; | 181 SkRRect rect; |
| 206 rect.setRectRadii(parsed_rect, parsed_radii); | 182 rect.setRectRadii(parsed_rect, parsed_radii); |
| 207 return rect; | 183 return rect; |
| 208 } | 184 } |
| 209 | 185 |
| 210 } // namespace cc | 186 } // namespace cc |
| OLD | NEW |