Project: skia Issues People Development process History Sign in
New issue
Advanced search Search tips
Issue 3045 Add int <-> SkMScalar conversion routines
Starred by 4 users Reported by pkasting@chromium.org, Oct 20 2014 Back to list
Status: Accepted
Owner:
Cc:
Area: API
Priority: Low
Type: Feature



Sign in to add a comment
There are a variety of routines to convert SkMScalars to/from SkScalar, float, and double, but none to convert to/from int.  At least a few places in Chromium could use such conversion routines; for now they chain together multiple conversion operators, or in many cases just don't explicitly convert at all since such code will often compile without warnings on our current compilers.
 
Project Member Comment 1 by hcm@google.com, Oct 21 2014
Cc: hcm@google.com
Owner: reed@chromium.org
Project Member Comment 2 by reed@google.com, Oct 21 2014
We have 6 variants today for SkScalar [floor, round, ceil] -> [scalar, int]
(7 if you count trunc)

Do you know which of these would be used by Chrome?
In the code review where these issues came up, the desired path was int -> SkMScalar.  This popped up because I'm trying to re-enable MSVC warnings about potential value truncation, and an implicit conversion of int -> float causes a warning for that case, so I needed to fix code that was doing this conversion implicitly to be explicit.  Right now the shortest technically-correct way to do that is

  SkScalarToMScalar(SkIntToScalar(foo))
Project Member Comment 4 by tfarina@chromium.org, Oct 22 2014
Commit https://skia.googlesource.com/skia/+/39393e3ac309d4bedbc18bae98d3ebcb762501dd seems to be related to this.

It could have had a BUG=skia:3045 so it gets through here.
Project Member Comment 5 by hcm@google.com, Oct 22 2014
Labels: Area-API
Project Member Comment 6 by tfarina@chromium.org, Oct 23 2014
Status: Accepted
Project Member Comment 7 by hcm@google.com, Dec 7 2015
Labels: Hotlist-Fixit
Sign in to add a comment