New issue
Advanced search Search tips

Issue 648818 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug

Blocked on:
issue 650088



Sign in to add a comment

Improve SkAlign* to work with char*

Project Member Reported by cblume@chromium.org, Sep 21 2016

Issue description

SkAlign* requires >> and << operators, which do not work on pointer types.
As a result, we have to cast pointers to uintptr_t in order to align it.

We should add support for working with char* to SkAlign*.
 

Comment 1 by cblume@chromium.org, Sep 21 2016

BTW I wonder if a better option might be to change calls to SkAlign* to std::align

http://en.cppreference.com/w/cpp/memory/align

Comment 2 by mtkl...@google.com, Sep 21 2016

Yes!  Please try std::align.  No need to wrap with a macro if it's clear enough without.  We'd like Skia to use std:: when std:: does what we want.

Comment 3 by bsalo...@google.com, Sep 21 2016

I agree in principle, but I'm not totally convinced std::align is what we want given its interface. In places where we use SkAlign?() I don't think we want to perform the alignment conditionally based on whether there is space for the size of the thing we're trying to store at the address. We usually know there is space before making the call.
Yeah, I actually looked at std::align yesterday when quickly assessing the situation with SkAlign. The interface seems awkward and clumsy for our use case. I think our own templated helpers may be better?

Comment 5 by cblume@chromium.org, Sep 21 2016

I agree, unfortunately.

Last night I took a look at all of the SkAlign?() call sites to assess the fit.

In all of our call sites we already know the buffer is large enough. So at best, it is a useless extra check. At medium, we would perhaps pipe the sizes in which might not be very natural. At worst, there is no buffer size like https://cs.chromium.org/chromium/src/third_party/skia/fuzz/fuzz.cpp?q=SkAlign&sq=package:chromium&l=284&dr=C and we just provide sizes of 1 and INT_MAX to force it.

It would make things uglier.

Comment 6 by cblume@chromium.org, Sep 25 2016

Blockedon: 650088

Comment 7 by cblume@chromium.org, Jun 25 2018

Status: Fixed (was: Assigned)
This was fixed in https://skia-review.googlesource.com/c/skia/+/134331

Sign in to add a comment