Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: Source/core/rendering/style/BasicShapes.h

Issue 305883002: Switch arguments to const Length references for performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.cpp ('k') | Source/core/rendering/style/FillLayer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 TopLeft, 81 TopLeft,
82 BottomRight 82 BottomRight
83 }; 83 };
84 BasicShapeCenterCoordinate() 84 BasicShapeCenterCoordinate()
85 : m_direction(TopLeft) 85 : m_direction(TopLeft)
86 , m_length(Undefined) 86 , m_length(Undefined)
87 { 87 {
88 updateComputedLength(); 88 updateComputedLength();
89 } 89 }
90 90
91 BasicShapeCenterCoordinate(Direction direction, Length length) 91 BasicShapeCenterCoordinate(Direction direction, const Length& length)
92 : m_direction(direction) 92 : m_direction(direction)
93 , m_length(length) 93 , m_length(length)
94 { 94 {
95 updateComputedLength(); 95 updateComputedLength();
96 } 96 }
97 97
98 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) 98 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other)
99 : m_direction(other.direction()) 99 : m_direction(other.direction())
100 , m_length(other.length()) 100 , m_length(other.length())
101 , m_computedLength(other.m_computedLength) 101 , m_computedLength(other.m_computedLength)
(...skipping 20 matching lines...) Expand all
122 }; 122 };
123 123
124 class BasicShapeRadius { 124 class BasicShapeRadius {
125 public: 125 public:
126 enum Type { 126 enum Type {
127 Value, 127 Value,
128 ClosestSide, 128 ClosestSide,
129 FarthestSide 129 FarthestSide
130 }; 130 };
131 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } 131 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
132 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { } 132 explicit BasicShapeRadius(const Length& v) : m_value(v), m_type(Value) { }
133 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { } 133 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { }
134 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_ type(other.type()) { } 134 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_ type(other.type()) { }
135 bool operator==(const BasicShapeRadius& other) const { return m_type == othe r.m_type && m_value == other.m_value; } 135 bool operator==(const BasicShapeRadius& other) const { return m_type == othe r.m_type && m_value == other.m_value; }
136 136
137 const Length& value() const { return m_value; } 137 const Length& value() const { return m_value; }
138 Type type() const { return m_type; } 138 Type type() const { return m_type; }
139 139
140 bool canBlend(const BasicShapeRadius& other) const 140 bool canBlend(const BasicShapeRadius& other) const
141 { 141 {
142 // FIXME determine how to interpolate between keywords. See issue 330248 . 142 // FIXME determine how to interpolate between keywords. See issue 330248 .
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 class BasicShapePolygon FINAL : public BasicShape { 219 class BasicShapePolygon FINAL : public BasicShape {
220 public: 220 public:
221 static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicSha pePolygon); } 221 static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicSha pePolygon); }
222 222
223 const Vector<Length>& values() const { return m_values; } 223 const Vector<Length>& values() const { return m_values; }
224 Length getXAt(unsigned i) const { return m_values.at(2 * i); } 224 Length getXAt(unsigned i) const { return m_values.at(2 * i); }
225 Length getYAt(unsigned i) const { return m_values.at(2 * i + 1); } 225 Length getYAt(unsigned i) const { return m_values.at(2 * i + 1); }
226 226
227 void setWindRule(WindRule windRule) { m_windRule = windRule; } 227 void setWindRule(WindRule windRule) { m_windRule = windRule; }
228 void appendPoint(Length x, Length y) { m_values.append(x); m_values.append(y ); } 228 void appendPoint(const Length& x, const Length& y) { m_values.append(x); m_v alues.append(y); }
229 229
230 virtual void path(Path&, const FloatRect&) OVERRIDE; 230 virtual void path(Path&, const FloatRect&) OVERRIDE;
231 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 231 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
232 virtual bool operator==(const BasicShape&) const OVERRIDE; 232 virtual bool operator==(const BasicShape&) const OVERRIDE;
233 233
234 virtual WindRule windRule() const OVERRIDE { return m_windRule; } 234 virtual WindRule windRule() const OVERRIDE { return m_windRule; }
235 235
236 virtual Type type() const OVERRIDE { return BasicShapePolygonType; } 236 virtual Type type() const OVERRIDE { return BasicShapePolygonType; }
237 private: 237 private:
238 BasicShapePolygon() 238 BasicShapePolygon()
(...skipping 13 matching lines...) Expand all
252 const Length& top() const { return m_top; } 252 const Length& top() const { return m_top; }
253 const Length& right() const { return m_right; } 253 const Length& right() const { return m_right; }
254 const Length& bottom() const { return m_bottom; } 254 const Length& bottom() const { return m_bottom; }
255 const Length& left() const { return m_left; } 255 const Length& left() const { return m_left; }
256 256
257 const LengthSize& topLeftRadius() const { return m_topLeftRadius; } 257 const LengthSize& topLeftRadius() const { return m_topLeftRadius; }
258 const LengthSize& topRightRadius() const { return m_topRightRadius; } 258 const LengthSize& topRightRadius() const { return m_topRightRadius; }
259 const LengthSize& bottomRightRadius() const { return m_bottomRightRadius; } 259 const LengthSize& bottomRightRadius() const { return m_bottomRightRadius; }
260 const LengthSize& bottomLeftRadius() const { return m_bottomLeftRadius; } 260 const LengthSize& bottomLeftRadius() const { return m_bottomLeftRadius; }
261 261
262 void setTop(Length top) { m_top = top; } 262 void setTop(const Length& top) { m_top = top; }
263 void setRight(Length right) { m_right = right; } 263 void setRight(const Length& right) { m_right = right; }
264 void setBottom(Length bottom) { m_bottom = bottom; } 264 void setBottom(const Length& bottom) { m_bottom = bottom; }
265 void setLeft(Length left) { m_left = left; } 265 void setLeft(const Length& left) { m_left = left; }
266 266
267 void setTopLeftRadius(LengthSize radius) { m_topLeftRadius = radius; } 267 void setTopLeftRadius(const LengthSize& radius) { m_topLeftRadius = radius; }
268 void setTopRightRadius(LengthSize radius) { m_topRightRadius = radius; } 268 void setTopRightRadius(const LengthSize& radius) { m_topRightRadius = radius ; }
269 void setBottomRightRadius(LengthSize radius) { m_bottomRightRadius = radius; } 269 void setBottomRightRadius(const LengthSize& radius) { m_bottomRightRadius = radius; }
270 void setBottomLeftRadius(LengthSize radius) { m_bottomLeftRadius = radius; } 270 void setBottomLeftRadius(const LengthSize& radius) { m_bottomLeftRadius = ra dius; }
271 271
272 virtual void path(Path&, const FloatRect&) OVERRIDE; 272 virtual void path(Path&, const FloatRect&) OVERRIDE;
273 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 273 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
274 virtual bool operator==(const BasicShape&) const OVERRIDE; 274 virtual bool operator==(const BasicShape&) const OVERRIDE;
275 275
276 virtual Type type() const OVERRIDE { return BasicShapeInsetType; } 276 virtual Type type() const OVERRIDE { return BasicShapeInsetType; }
277 private: 277 private:
278 BasicShapeInset() { } 278 BasicShapeInset() { }
279 279
280 Length m_right; 280 Length m_right;
281 Length m_top; 281 Length m_top;
282 Length m_bottom; 282 Length m_bottom;
283 Length m_left; 283 Length m_left;
284 284
285 LengthSize m_topLeftRadius; 285 LengthSize m_topLeftRadius;
286 LengthSize m_topRightRadius; 286 LengthSize m_topRightRadius;
287 LengthSize m_bottomRightRadius; 287 LengthSize m_bottomRightRadius;
288 LengthSize m_bottomLeftRadius; 288 LengthSize m_bottomLeftRadius;
289 }; 289 };
290 290
291 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInset); 291 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInset);
292 292
293 } 293 }
294 #endif 294 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.cpp ('k') | Source/core/rendering/style/FillLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698