LibGfx: Explicitly set color space of SkImage
s
If not set, when copying pixels into the SkImage, skia assumes that the color space is the same as the input, so no transformation is done. We are currently setting the color space to sRGB, this is fine for now as it allows us to start making some transformations, but down the road we will want to set that to the actual output's display color space.
This commit is contained in:
parent
407aa629a0
commit
8f8ec146a1
Notes:
github-actions[bot]
2024-12-05 16:17:44 +00:00
Author: https://github.com/LucasChollet Commit: https://github.com/LadybirdBrowser/ladybird/commit/8f8ec146a11 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1764 Reviewed-by: https://github.com/trflynn89
3 changed files with 5 additions and 5 deletions
|
@ -31,7 +31,7 @@ NonnullRefPtr<PaintingSurface> PaintingSurface::create_with_size(RefPtr<SkiaBack
|
|||
{
|
||||
auto sk_color_type = to_skia_color_type(color_type);
|
||||
auto sk_alpha_type = alpha_type == Gfx::AlphaType::Premultiplied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
||||
auto image_info = SkImageInfo::Make(size.width(), size.height(), sk_color_type, sk_alpha_type);
|
||||
auto image_info = SkImageInfo::Make(size.width(), size.height(), sk_color_type, sk_alpha_type, SkColorSpace::MakeSRGB());
|
||||
|
||||
if (!context) {
|
||||
auto bitmap = Gfx::Bitmap::create(color_type, alpha_type, size).value();
|
||||
|
@ -50,7 +50,7 @@ NonnullRefPtr<PaintingSurface> PaintingSurface::wrap_bitmap(Bitmap& bitmap)
|
|||
auto color_type = to_skia_color_type(bitmap.format());
|
||||
auto alpha_type = bitmap.alpha_type() == Gfx::AlphaType::Premultiplied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
||||
auto size = bitmap.size();
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type);
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type, SkColorSpace::MakeSRGB());
|
||||
auto surface = SkSurfaces::WrapPixels(image_info, bitmap.begin(), bitmap.pitch());
|
||||
return adopt_ref(*new PaintingSurface(make<Impl>(size, surface, bitmap, nullptr)));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ NonnullRefPtr<PaintingSurface> PaintingSurface::wrap_iosurface(Core::IOSurfaceHa
|
|||
{
|
||||
auto metal_texture = context->metal_context().create_texture_from_iosurface(iosurface_handle);
|
||||
IntSize const size { metal_texture->width(), metal_texture->height() };
|
||||
auto image_info = SkImageInfo::Make(size.width(), size.height(), kBGRA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
auto image_info = SkImageInfo::Make(size.width(), size.height(), kBGRA_8888_SkColorType, kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
|
||||
GrMtlTextureInfo mtl_info;
|
||||
mtl_info.fTexture = sk_ret_cfp(metal_texture->texture());
|
||||
auto backend_render_target = GrBackendRenderTargets::MakeMtl(metal_texture->width(), metal_texture->height(), mtl_info);
|
||||
|
@ -80,7 +80,7 @@ void PaintingSurface::read_into_bitmap(Gfx::Bitmap& bitmap)
|
|||
{
|
||||
auto color_type = to_skia_color_type(bitmap.format());
|
||||
auto alpha_type = bitmap.alpha_type() == Gfx::AlphaType::Premultiplied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type);
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type, SkColorSpace::MakeSRGB());
|
||||
SkPixmap const pixmap(image_info, bitmap.begin(), bitmap.pitch());
|
||||
m_impl->surface->readPixels(pixmap, 0, 0);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void PaintingSurface::write_from_bitmap(Gfx::Bitmap const& bitmap)
|
|||
{
|
||||
auto color_type = to_skia_color_type(bitmap.format());
|
||||
auto alpha_type = bitmap.alpha_type() == Gfx::AlphaType::Premultiplied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type);
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type, SkColorSpace::MakeSRGB());
|
||||
SkPixmap const pixmap(image_info, bitmap.begin(), bitmap.pitch());
|
||||
m_impl->surface->writePixels(pixmap, 0, 0);
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 112 KiB |
Binary file not shown.
Before Width: | Height: | Size: 305 KiB After Width: | Height: | Size: 343 KiB |
Loading…
Add table
Reference in a new issue