-
Notifications
You must be signed in to change notification settings - Fork 6k
Added float32 support to decodeImageFromPixels #40068
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,17 +85,22 @@ void ImageDescriptor::initRaw(Dart_Handle descriptor_handle, | |
int row_bytes, | ||
PixelFormat pixel_format) { | ||
SkColorType color_type = kUnknown_SkColorType; | ||
SkAlphaType alpha_type = kPremul_SkAlphaType; | ||
switch (pixel_format) { | ||
case PixelFormat::kRGBA8888: | ||
color_type = kRGBA_8888_SkColorType; | ||
break; | ||
case PixelFormat::kBGRA8888: | ||
color_type = kBGRA_8888_SkColorType; | ||
break; | ||
case PixelFormat::kRGBAFloat32: | ||
// `PixelFormat.rgbaFloat32` is documented to not use premultiplied alpha. | ||
color_type = kRGBA_F32_SkColorType; | ||
alpha_type = kUnpremul_SkAlphaType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these unpremul but the other ones are premul? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the Dart API perspective it's not the only one that uses unpremultiplied, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a comment about that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got a bit confused between |
||
break; | ||
} | ||
FML_DCHECK(color_type != kUnknown_SkColorType); | ||
auto image_info = | ||
SkImageInfo::Make(width, height, color_type, kPremul_SkAlphaType); | ||
auto image_info = SkImageInfo::Make(width, height, color_type, alpha_type); | ||
auto descriptor = fml::MakeRefCounted<ImageDescriptor>( | ||
data->data(), std::move(image_info), | ||
row_bytes == -1 ? std::nullopt : std::optional<size_t>(row_bytes)); | ||
|
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.
Why not
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.
There isn't a way to send in kRGBA_F16_SkColorType directly. If we decide to implement that it will probably be better to do that in its own pr with its own tests.