-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add-raw-pixel-buffer-to-image: skia impl #2
Conversation
Pixel buffer support has been added for the Skia backend. By default, the memory for the image is copied over to be managed by the SkBitmap instance within the image. This is to give the caller safety when using a raw pointer after creating a paintable pixmap.
@djowel here is the Skia implementation, following up on our conversation on discord/cycfi/elements#227 I do not have access to a Mac/macOS at the moment. Would you, or someone else be able to handle that chunk of work? |
Wow, you are fast! :-) Any chance you can do something with the Quartz-2D backend? :-) I probably shouldn't be pushing my luck. Haha :-) I'll review ASAP. |
Ah there. Of course, I can do that. |
Added some comments above ^. I'll look closer again later... Many thanks for your contribution! |
For sure! Thanks for the code review! |
examples/image_pixmap_chessboard.cpp
Outdated
|
||
uint32_t constexpr white = 0xffffffff; | ||
// on little endian systems RGBA is formatted as ABGR for values | ||
std::function<uint32_t()> black = []() { return is_little_endian() ? 0xff000000 : 0x000000ff; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, infra/support.hpp should probably have a to_little_endian(x)
and to_big_endian(x)
set of overloads for different scalar types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an issue in cycfi/infra
: cycfi/infra#12
- Moved to use function to determine api specific alpha/byte format type. - Updated infra submodule to latest master, in order to have `is_little_endian` function for example. - Updated copyright
Some things I have in mind, but I can add/implement later:
For now, I'm good with merging this PR. Thanks for working on this! |
BTW, I am moving this to the raw_pixel branch. It will stay there until the quartz-2d implementation is added, so as not to break the develop branch. |
Those are good points! Not to beat a dead branch, but as far as an abstraction, do you mean something like the |
Not really. Something like: https://github.com/cycfi/infra/blob/master/include/infra/buffer.hpp for pixmaps. So you can write things like: pm[3][4] = pixel; or iterate like: for (auto& row : pm)
for (auto& pix : row)
pix = some_color; |
Pixel buffer support has been added for the Skia backend.
By default, the memory for the image is copied over to be managed
by the SkBitmap instance within the image. This is to give the caller
safety when using a raw pointer after creating an image.