mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
LibGfx: Sync to_skia_color_type
This commit is contained in:
parent
66530086a4
commit
ed80e929e5
Notes:
github-actions[bot]
2024-11-18 18:19:06 +00:00
Author: https://github.com/shlyakpavel Commit: https://github.com/LadybirdBrowser/ladybird/commit/ed80e929e5d Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2274 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/konradekk Reviewed-by: https://github.com/trflynn89
4 changed files with 34 additions and 32 deletions
|
@ -73,6 +73,7 @@ set(SOURCES
|
|||
set(SWIFT_EXCLUDE_HEADERS
|
||||
MetalContext.h
|
||||
VulkanContext.h
|
||||
SkiaUtils.h
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibGfx/ImmutableBitmap.h>
|
||||
#include <LibGfx/PaintingSurface.h>
|
||||
#include <LibGfx/SkiaUtils.h>
|
||||
|
||||
#include <core/SkBitmap.h>
|
||||
#include <core/SkImage.h>
|
||||
|
@ -60,23 +61,6 @@ Color ImmutableBitmap::get_pixel(int x, int y) const
|
|||
return m_impl->source.get<NonnullRefPtr<Gfx::Bitmap>>()->get_pixel(x, y);
|
||||
}
|
||||
|
||||
static SkColorType to_skia_color_type(Gfx::BitmapFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case Gfx::BitmapFormat::Invalid:
|
||||
return kUnknown_SkColorType;
|
||||
case Gfx::BitmapFormat::BGRA8888:
|
||||
case Gfx::BitmapFormat::BGRx8888:
|
||||
return kBGRA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBA8888:
|
||||
return kRGBA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBx8888:
|
||||
return kRGB_888x_SkColorType;
|
||||
default:
|
||||
return kUnknown_SkColorType;
|
||||
}
|
||||
}
|
||||
|
||||
static SkAlphaType to_skia_alpha_type(Gfx::AlphaType alpha_type)
|
||||
{
|
||||
switch (alpha_type) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/ImmutableBitmap.h>
|
||||
#include <LibGfx/PaintingSurface.h>
|
||||
#include <LibGfx/SkiaUtils.h>
|
||||
|
||||
#include <core/SkColorSpace.h>
|
||||
#include <core/SkSurface.h>
|
||||
|
@ -29,21 +30,6 @@ struct PaintingSurface::Impl {
|
|||
RefPtr<SkiaBackendContext> context;
|
||||
};
|
||||
|
||||
static SkColorType to_skia_color_type(Gfx::BitmapFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case Gfx::BitmapFormat::Invalid:
|
||||
return kUnknown_SkColorType;
|
||||
case Gfx::BitmapFormat::BGRA8888:
|
||||
case Gfx::BitmapFormat::BGRx8888:
|
||||
return kBGRA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBA8888:
|
||||
return kRGBA_8888_SkColorType;
|
||||
default:
|
||||
return kUnknown_SkColorType;
|
||||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<PaintingSurface> PaintingSurface::create_with_size(RefPtr<SkiaBackendContext> context, Gfx::IntSize size, Gfx::BitmapFormat color_type, Gfx::AlphaType alpha_type)
|
||||
{
|
||||
auto sk_color_type = to_skia_color_type(color_type);
|
||||
|
|
31
Libraries/LibGfx/SkiaUtils.h
Normal file
31
Libraries/LibGfx/SkiaUtils.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Pavel Shliak <shlyakpavel@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <core/SkColorType.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
static SkColorType to_skia_color_type(Gfx::BitmapFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case Gfx::BitmapFormat::Invalid:
|
||||
return kUnknown_SkColorType;
|
||||
case Gfx::BitmapFormat::BGRA8888:
|
||||
case Gfx::BitmapFormat::BGRx8888:
|
||||
return kBGRA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBA8888:
|
||||
return kRGBA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBx8888:
|
||||
return kRGB_888x_SkColorType;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue