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

Unified Diff: third_party/WebKit/Source/platform/graphics/StrokeData.h

Issue 2737063002: Improve dashed line drawing (Closed)
Patch Set: More expectations. Flaky? 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/StrokeData.h
diff --git a/third_party/WebKit/Source/platform/graphics/StrokeData.h b/third_party/WebKit/Source/platform/graphics/StrokeData.h
index f39dffc800ad3aa7bc142282faa75283ec971a6d..0c73f01acc3b655a2b3d83362ed5fef8fa0faa3d 100644
--- a/third_party/WebKit/Source/platform/graphics/StrokeData.h
+++ b/third_party/WebKit/Source/platform/graphics/StrokeData.h
@@ -87,6 +87,29 @@ class PLATFORM_EXPORT StrokeData final {
// is specified but the line width is too small to draw circles.
static bool strokeIsDashed(float width, StrokeStyle);
+ // The length of the dash relative to the line thickness for dashed stroking.
+ // A different dash length may be used when dashes are adjusted to better
+ // fit a given length path. Thin lines need longer dashes to avoid
+ // looking like dots when drawn.
+ static float dashLengthRatio(float thickness) {
+ return thickness >= 3 ? 2.0 : 3.0;
+ }
+
+ // The length of the gap between dashes relative to the line thickness for
+ // dashed stroking. A different gap may be used when dashes are adjusted to
+ // better fit a given length path. Thin lines need longer gaps to avoid
+ // looking like a continuous line when drawn.
+ static float dashGapRatio(float thickness) {
+ return thickness >= 3 ? 1.0 : 2.0;
+ }
+
+ // Return a dash gap size that places dashes at each end of a stroke that is
+ // strokeLength long, given preferred dash and gap sizes. The gap returned is
+ // the one that minimizes deviation from the preferred gap length.
+ static float selectBestDashGap(float strokeLength,
+ float dashLength,
+ float gapLength);
+
private:
StrokeStyle m_style;
float m_thickness;
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxBorderPainter.cpp ('k') | third_party/WebKit/Source/platform/graphics/StrokeData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698