Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 class FloatRect; | 42 class FloatRect; |
| 43 class Path; | 43 class Path; |
| 44 | 44 |
| 45 class BasicShape : public RefCounted<BasicShape> { | 45 class BasicShape : public RefCounted<BasicShape> { |
| 46 public: | 46 public: |
| 47 virtual ~BasicShape() { } | 47 virtual ~BasicShape() { } |
| 48 | 48 |
| 49 enum Type { | 49 enum Type { |
| 50 BasicShapeRectangleType = 1, | 50 BasicShapeRectangleType = 1, |
| 51 BasicShapeCircleType = 2, | 51 DeprecatedBasicShapeCircleType = 2, |
| 52 BasicShapeEllipseType = 3, | 52 BasicShapeEllipseType = 3, |
| 53 BasicShapePolygonType = 4, | 53 BasicShapePolygonType = 4, |
| 54 BasicShapeInsetRectangleType = 5 | 54 BasicShapeInsetRectangleType = 5, |
| 55 BasicShapeCircleType = 6 | |
|
Bem Jones-Bey (adobe)
2013/12/18 21:57:57
The explicit numbers got removed in a subsequent p
| |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 bool canBlend(const BasicShape*) const; | 58 bool canBlend(const BasicShape*) const; |
| 58 bool isSameType(const BasicShape& other) const { return type() == other.type (); } | 59 bool isSameType(const BasicShape& other) const { return type() == other.type (); } |
| 59 | 60 |
| 60 virtual void path(Path&, const FloatRect&) = 0; | 61 virtual void path(Path&, const FloatRect&) = 0; |
| 61 virtual WindRule windRule() const { return RULE_NONZERO; } | 62 virtual WindRule windRule() const { return RULE_NONZERO; } |
| 62 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0; | 63 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0; |
| 63 virtual bool operator==(const BasicShape&) const = 0; | 64 virtual bool operator==(const BasicShape&) const = 0; |
| 64 | 65 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 Length m_y; | 116 Length m_y; |
| 116 Length m_x; | 117 Length m_x; |
| 117 Length m_width; | 118 Length m_width; |
| 118 Length m_height; | 119 Length m_height; |
| 119 Length m_cornerRadiusX; | 120 Length m_cornerRadiusX; |
| 120 Length m_cornerRadiusY; | 121 Length m_cornerRadiusY; |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle); | 124 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle); |
| 124 | 125 |
| 126 class BasicShapeCenterCoordinate { | |
| 127 public: | |
| 128 enum Keyword { | |
| 129 None, | |
| 130 Top, | |
| 131 Right, | |
| 132 Bottom, | |
| 133 Left | |
| 134 }; | |
| 135 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { } | |
| 136 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng th(length) { } | |
| 137 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo rd), m_length(length) { } | |
| 138 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw ord(other.keyword()), m_length(other.length()) { } | |
| 139 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke yword == other.m_keyword && m_length == other.m_length; } | |
| 140 | |
| 141 Keyword keyword() const { return m_keyword; } | |
| 142 const Length& length() const { return m_length; } | |
| 143 | |
| 144 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const | |
| 145 { | |
| 146 if (m_keyword != None || other.keyword() != None) | |
| 147 return BasicShapeCenterCoordinate(other); | |
| 148 | |
| 149 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres s, ValueRangeAll)); | |
| 150 } | |
| 151 | |
| 152 private: | |
| 153 Keyword m_keyword; | |
| 154 Length m_length; | |
| 155 }; | |
| 156 | |
| 157 class BasicShapeRadius { | |
| 158 public: | |
| 159 enum Type { | |
| 160 Value, | |
| 161 ClosestSide, | |
| 162 FarthestSide | |
| 163 }; | |
| 164 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } | |
| 165 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { } | |
| 166 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { } | |
| 167 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_ type(other.type()) { } | |
| 168 bool operator==(const BasicShapeRadius& other) const { return m_type == othe r.m_type && m_value == other.m_value; } | |
| 169 | |
| 170 const Length& value() const { return m_value; } | |
| 171 Type type() const { return m_type; } | |
| 172 | |
| 173 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const | |
| 174 { | |
| 175 if (m_type != Value || other.type() != Value) | |
| 176 return BasicShapeRadius(other); | |
| 177 | |
| 178 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang eAll)); | |
| 179 } | |
| 180 | |
| 181 private: | |
| 182 Length m_value; | |
| 183 Type m_type; | |
| 184 | |
| 185 }; | |
| 186 | |
| 125 class BasicShapeCircle : public BasicShape { | 187 class BasicShapeCircle : public BasicShape { |
| 126 public: | 188 public: |
| 127 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap eCircle); } | 189 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap eCircle); } |
| 128 | 190 |
| 191 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; } | |
| 192 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; } | |
| 193 const BasicShapeRadius& radius() const { return m_radius; } | |
| 194 | |
| 195 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; } | |
| 196 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; } | |
| 197 void setRadius(BasicShapeRadius radius) { m_radius = radius; } | |
| 198 | |
| 199 virtual void path(Path&, const FloatRect&) OVERRIDE; | |
| 200 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; | |
| 201 virtual bool operator==(const BasicShape&) const OVERRIDE; | |
| 202 | |
| 203 virtual Type type() const { return BasicShapeCircleType; } | |
| 204 private: | |
| 205 BasicShapeCircle() { } | |
| 206 | |
| 207 BasicShapeCenterCoordinate m_centerX; | |
| 208 BasicShapeCenterCoordinate m_centerY; | |
| 209 BasicShapeRadius m_radius; | |
| 210 }; | |
| 211 | |
| 212 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle); | |
| 213 | |
| 214 class DeprecatedBasicShapeCircle : public BasicShape { | |
| 215 public: | |
| 216 static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); } | |
| 217 | |
| 129 Length centerX() const { return m_centerX; } | 218 Length centerX() const { return m_centerX; } |
| 130 Length centerY() const { return m_centerY; } | 219 Length centerY() const { return m_centerY; } |
| 131 Length radius() const { return m_radius; } | 220 Length radius() const { return m_radius; } |
| 132 | 221 |
| 133 void setCenterX(Length centerX) { m_centerX = centerX; } | 222 void setCenterX(Length centerX) { m_centerX = centerX; } |
| 134 void setCenterY(Length centerY) { m_centerY = centerY; } | 223 void setCenterY(Length centerY) { m_centerY = centerY; } |
| 135 void setRadius(Length radius) { m_radius = radius; } | 224 void setRadius(Length radius) { m_radius = radius; } |
| 136 | 225 |
| 137 virtual void path(Path&, const FloatRect&) OVERRIDE; | 226 virtual void path(Path&, const FloatRect&) OVERRIDE; |
| 138 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; | 227 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; |
| 139 virtual bool operator==(const BasicShape&) const OVERRIDE; | 228 virtual bool operator==(const BasicShape&) const OVERRIDE; |
| 140 | 229 |
| 141 virtual Type type() const { return BasicShapeCircleType; } | 230 virtual Type type() const { return DeprecatedBasicShapeCircleType; } |
| 142 private: | 231 private: |
| 143 BasicShapeCircle() { } | 232 DeprecatedBasicShapeCircle() { } |
| 144 | 233 |
| 145 Length m_centerX; | 234 Length m_centerX; |
| 146 Length m_centerY; | 235 Length m_centerY; |
| 147 Length m_radius; | 236 Length m_radius; |
| 148 }; | 237 }; |
| 149 | 238 |
| 150 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle); | 239 DEFINE_BASICSHAPE_TYPE_CASTS(DeprecatedBasicShapeCircle); |
| 151 | 240 |
| 152 class BasicShapeEllipse : public BasicShape { | 241 class BasicShapeEllipse : public BasicShape { |
| 153 public: | 242 public: |
| 154 static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicSha peEllipse); } | 243 static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicSha peEllipse); } |
| 155 | 244 |
| 156 Length centerX() const { return m_centerX; } | 245 Length centerX() const { return m_centerX; } |
| 157 Length centerY() const { return m_centerY; } | 246 Length centerY() const { return m_centerY; } |
| 158 Length radiusX() const { return m_radiusX; } | 247 Length radiusX() const { return m_radiusX; } |
| 159 Length radiusY() const { return m_radiusY; } | 248 Length radiusY() const { return m_radiusY; } |
| 160 | 249 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 Length m_bottom; | 334 Length m_bottom; |
| 246 Length m_left; | 335 Length m_left; |
| 247 Length m_cornerRadiusX; | 336 Length m_cornerRadiusX; |
| 248 Length m_cornerRadiusY; | 337 Length m_cornerRadiusY; |
| 249 }; | 338 }; |
| 250 | 339 |
| 251 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle); | 340 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle); |
| 252 | 341 |
| 253 } | 342 } |
| 254 #endif | 343 #endif |
| OLD | NEW |