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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/StrokeData.h

Issue 2737063002: Improve dashed line drawing (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright (C) 2013 Google Inc. All rights reserved. 1 // Copyright (C) 2013 Google Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer 10 // copyright notice, this list of conditions and the following disclaimer
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Setup any DashPathEffect on the paint. If a non-zero length is provided, 80 // Setup any DashPathEffect on the paint. If a non-zero length is provided,
81 // and no line dash has been set, the number of dashes/dots on a dashed/dotted 81 // and no line dash has been set, the number of dashes/dots on a dashed/dotted
82 // line will be adjusted to start and end that length with a dash/dot. 82 // line will be adjusted to start and end that length with a dash/dot.
83 void setupPaintDashPathEffect(PaintFlags*, int) const; 83 void setupPaintDashPathEffect(PaintFlags*, int) const;
84 84
85 // Determine whether a stroked line should be drawn using dashes. In practice, 85 // Determine whether a stroked line should be drawn using dashes. In practice,
86 // we draw dashes when a dashed stroke is specified or when a dotted stroke 86 // we draw dashes when a dashed stroke is specified or when a dotted stroke
87 // is specified but the line width is too small to draw circles. 87 // is specified but the line width is too small to draw circles.
88 static bool strokeIsDashed(float width, StrokeStyle); 88 static bool strokeIsDashed(float width, StrokeStyle);
89 89
90 // The length of the dash relative to the line thickness for dashed stroking.
91 // A different dash length may be used when dashes are adjusted to better
92 // fit a given length path.
93 static float dashLengthRatio(float thickness) {
94 return thickness >= 3 ? 2.0 : 3.0;
95 }
96
97 // The length of the gap between dashes relative to the line thickness for
98 // dashed stroking. A different gap may be used when dashes are adjusted to
99 // better fit a given length path. Thin lines need longer dashes to avoid
100 // looking like dots when drawn.
101 static float dashGapRatio(float thickness) {
102 return thickness >= 3 ? 1.0 : 2.0;
103 }
104
90 private: 105 private:
91 StrokeStyle m_style; 106 StrokeStyle m_style;
92 float m_thickness; 107 float m_thickness;
93 PaintFlags::Cap m_lineCap; 108 PaintFlags::Cap m_lineCap;
94 PaintFlags::Join m_lineJoin; 109 PaintFlags::Join m_lineJoin;
95 float m_miterLimit; 110 float m_miterLimit;
96 sk_sp<SkPathEffect> m_dash; 111 sk_sp<SkPathEffect> m_dash;
97 }; 112 };
98 113
99 } // namespace blink 114 } // namespace blink
100 115
101 #endif // StrokeData_h 116 #endif // StrokeData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698