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

Unified Diff: experimental/svg/model/SkSVGRenderContext.cpp

Issue 2259473002: [SVGDom] Add support for assorted absolute units (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/svg/model/SkSVGRenderContext.cpp
diff --git a/experimental/svg/model/SkSVGRenderContext.cpp b/experimental/svg/model/SkSVGRenderContext.cpp
index 8ad881429a21b906a3041a06753bb5b045c61757..1ce21e4a9bd759cd2a95dd8ef0b82f6e8b7e112a 100644
--- a/experimental/svg/model/SkSVGRenderContext.cpp
+++ b/experimental/svg/model/SkSVGRenderContext.cpp
@@ -26,16 +26,34 @@ SkScalar length_size_for_type(const SkSize& viewport, SkSVGLengthContext::Length
return 0;
}
robertphillips 2016/08/17 18:39:03 // These all assume a 90dpi display device. Do we
f(malita) 2016/08/17 21:04:17 Done.
+// https://www.w3.org/TR/SVG/coords.html#Units
+constexpr SkScalar kPXMultiplier = 1.00f;
robertphillips 2016/08/17 18:39:03 Isn't the pt multiplier supposed to be DPI/72.272
f(malita) 2016/08/17 21:04:17 Done.
+constexpr SkScalar kPTMultiplier = 1.25f;
+constexpr SkScalar kPCMultiplier = 15.00f;
+constexpr SkScalar kINMultiplier = 90.00f;
+constexpr SkScalar kMMMultiplier = 3.543307f;
+constexpr SkScalar kCMMultiplier = kMMMultiplier * 10;
+
} // anonymous ns
SkScalar SkSVGLengthContext::resolve(const SkSVGLength& l, LengthType t) const {
switch (l.unit()) {
case SkSVGLength::Unit::kNumber:
- // Fall through.
- case SkSVGLength::Unit::kPX:
return l.value();
case SkSVGLength::Unit::kPercentage:
return l.value() * length_size_for_type(fViewport, t) / 100;
+ case SkSVGLength::Unit::kPX:
+ return l.value() * kPXMultiplier;
+ case SkSVGLength::Unit::kCM:
+ return l.value() * kCMMultiplier;
+ case SkSVGLength::Unit::kMM:
+ return l.value() * kMMMultiplier;
+ case SkSVGLength::Unit::kIN:
+ return l.value() * kINMultiplier;
+ case SkSVGLength::Unit::kPT:
+ return l.value() * kPTMultiplier;
+ case SkSVGLength::Unit::kPC:
+ return l.value() * kPCMultiplier;
default:
SkDebugf("unsupported unit type: <%d>\n", l.unit());
return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698