diff --git a/LICENSE.txt b/LICENSE.txt index d2223a08e..4b4a4ffe6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Igara Studio S.A. +Copyright (c) 2018-2024 Igara Studio S.A. Copyright (c) 2016-2018 David Capello Permission is hereby granted, free of charge, to any person obtaining diff --git a/os/skia/paint.h b/os/skia/paint.h index c47e1204a..94b37c9cb 100644 --- a/os/skia/paint.h +++ b/os/skia/paint.h @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (c) 2022 Igara Studio S.A. +// Copyright (c) 2022-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -10,6 +10,7 @@ #include "gfx/color.h" +#include "include/core/SkBlendMode.h" #include "include/core/SkPaint.h" namespace os { diff --git a/os/skia/skia_color_space.cpp b/os/skia/skia_color_space.cpp index 48bba2cd9..704052887 100644 --- a/os/skia/skia_color_space.cpp +++ b/os/skia/skia_color_space.cpp @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (C) 2018-2021 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -14,15 +14,11 @@ #include "include/core/SkImageInfo.h" #include "include/core/SkString.h" -#include "include/third_party/skcms/skcms.h" +#include "modules/skcms/src/skcms_public.h" #include "src/core/SkConvertPixels.h" #include -// Defined in skia/src/core/SkICC.cpp -const char* get_color_profile_description(const skcms_TransferFunction& fn, - const skcms_Matrix3x3& toXYZD50); - namespace os { // Copied from skia/src/core/SkColorSpacePriv.h @@ -113,9 +109,11 @@ SkiaColorSpace::SkiaColorSpace(const gfx::ColorSpaceRef& gfxcs) skcms_Matrix3x3 toXYZD50; if (m_skcs->isNumericalTransferFn(&fn) && m_skcs->toXYZD50(&toXYZD50)) { +#if 0 // TODO create a description for the color profile const char* desc = get_color_profile_description(fn, toXYZD50); if (desc) m_gfxcs->setName(desc); +#endif } } diff --git a/os/skia/skia_draw_text_with_shaper.cpp b/os/skia/skia_draw_text_with_shaper.cpp index 8147baa9a..79dc68699 100644 --- a/os/skia/skia_draw_text_with_shaper.cpp +++ b/os/skia/skia_draw_text_with_shaper.cpp @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (C) 2019-2022 Igara Studio S.A. +// Copyright (C) 2019-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -31,8 +31,7 @@ void draw_text_with_shaper( const TextAlign textAlign, DrawTextDelegate* delegate) { - // SkFont skFont(SkTypeface::MakeFromFile("/Library/Fonts/Arial Unicode.ttf"), SkIntToScalar(24)); - SkFont skFont(SkTypeface::MakeDefault(), SkIntToScalar(24)); + SkFont skFont; sk_sp textBlob; auto shaper = SkShaper::Make(); if (shaper) { diff --git a/os/skia/skia_font_manager.h b/os/skia/skia_font_manager.h index 3aafcc179..dace9336b 100644 --- a/os/skia/skia_font_manager.h +++ b/os/skia/skia_font_manager.h @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (c) 2019-2020 Igara Studio S.A. +// Copyright (c) 2019-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -20,7 +20,7 @@ namespace os { class SkiaTypeface : public Typeface { public: - SkiaTypeface(SkTypeface* skTypeface) + SkiaTypeface(sk_sp skTypeface) : m_skTypeface(skTypeface) { } @@ -37,7 +37,7 @@ class SkiaTypeface : public Typeface { class SkiaFontStyleSet : public FontStyleSet { public: - SkiaFontStyleSet(SkFontStyleSet* set) + SkiaFontStyleSet(sk_sp set) : m_skSet(set) { } @@ -75,7 +75,7 @@ class SkiaFontStyleSet : public FontStyleSet { class SkiaFontManager : public FontManager { public: SkiaFontManager() - : m_skFontMgr(SkFontMgr::RefDefault()) { + : m_skFontMgr(SkFontMgr::RefEmpty()) { } ~SkiaFontManager() { diff --git a/os/skia/skia_gl.cpp b/os/skia/skia_gl.cpp index ef7643e37..452d13512 100644 --- a/os/skia/skia_gl.cpp +++ b/os/skia/skia_gl.cpp @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (C) 2022 Igara Studio S.A. +// Copyright (C) 2022-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -14,8 +14,11 @@ #if SK_SUPPORT_GPU #include "include/core/SkSurface.h" -#include "include/core/SkSurfaceCharacterization.h" -#include "src/gpu/gl/GrGLDefines.h" +#include "include/gpu/GrBackendSurface.h" +#include "include/gpu/ganesh/SkSurfaceGanesh.h" +#include "include/gpu/ganesh/gl/GrGLBackendSurface.h" +#include "include/gpu/ganesh/gl/GrGLDirectContext.h" +#include "src/gpu/ganesh/gl/GrGLDefines.h" namespace os { @@ -36,7 +39,7 @@ bool SkiaGL::attachGL() return false; } - m_grCtx = GrDirectContext::MakeGL(m_glInterfaces); + m_grCtx = GrDirectContexts::MakeGL(m_glInterfaces); if (!m_grCtx) { LOG(ERROR, "OS: Cannot create GrContext\n"); detachGL(); @@ -75,15 +78,18 @@ bool SkiaGL::createRenderTarget(const gfx::Size& size, GrGLFramebufferInfo info; info.fFBOID = (GrGLuint)buffer; info.fFormat = GR_GL_RGBA8; + //SK_API bool GrBackendRenderTargets::GetGLFramebufferInfo(const GrBackendRenderTarget&, GrGLFramebufferInfo*); GrGLint stencil = 0; m_glInterfaces->fFunctions.fGetIntegerv(GR_GL_STENCIL_BITS, &stencil); - GrBackendRenderTarget target(size.w, size.h, 0, stencil, info); + // GrBackendRenderTarget target(size.w, size.h, 0, stencil, info); + GrBackendRenderTarget target = + GrBackendRenderTargets::MakeGL(size.w, size.h, 0, stencil, info); m_surface.reset(nullptr); m_backbufferSurface = - SkSurface::MakeFromBackendRenderTarget( + SkSurfaces::WrapBackendRenderTarget( m_grCtx.get(), target, kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, @@ -104,13 +110,10 @@ bool SkiaGL::createRenderTarget(const gfx::Size& size, kOpaque_SkAlphaType, colorSpace); - SkSurfaceCharacterization ch; - m_backbufferSurface->characterize(&ch); - m_surface = - SkSurface::MakeRenderTarget( - m_grCtx.get(), SkBudgeted::kNo, - info, ch.sampleCount(), nullptr); + SkSurfaces::RenderTarget( + m_grCtx.get(), skgpu::Budgeted::kNo, + info, 0, nullptr); } return true; diff --git a/os/skia/skia_surface.cpp b/os/skia/skia_surface.cpp index b5a625190..4c2acf782 100644 --- a/os/skia/skia_surface.cpp +++ b/os/skia/skia_surface.cpp @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (c) 2018-2022 Igara Studio S.A. +// Copyright (c) 2018-2024 Igara Studio S.A. // Copyright (c) 2016-2018 David Capello // // This file is released under the terms of the MIT license. @@ -24,8 +24,10 @@ #include "include/private/SkColorData.h" #if SK_SUPPORT_GPU - #include "include/gpu/GrDirectContext.h" #include "include/gpu/GrBackendSurface.h" + #include "include/gpu/GrDirectContext.h" + #include "include/gpu/ganesh/SkImageGanesh.h" + #include "include/gpu/ganesh/gl/GrGLBackendSurface.h" #endif #include @@ -105,14 +107,16 @@ void SkiaSurface::destroy() void SkiaSurface::flush() const { - if (m_canvas) - m_canvas->flush(); + // TODO replace with GrDirectContext::flush() + // if (m_canvas) + // m_canvas->flush(); } void SkiaSurface::flushAndSubmit() const { - if (m_surface) - m_surface->flushAndSubmit(); + // TODO replace with GrDirectContext::flushAndSubmit() + // if (m_surface) + // m_surface->flushAndSubmit(); } int SkiaSurface::width() const @@ -246,7 +250,7 @@ void SkiaSurface::applyScale(int scaleFactor) SkCanvas canvas(result); SkRect srcRect = SkRect::Make(SkIRect::MakeXYWH(0, 0, width(), height())); SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(0, 0, result.width(), result.height())); - canvas.drawImageRect(SkImage::MakeFromRaster(m_bitmap.pixmap(), nullptr, nullptr), + canvas.drawImageRect(SkImages::RasterFromPixmap(m_bitmap.pixmap(), nullptr, nullptr), srcRect, dstRect, SkSamplingOptions(), &paint, SkCanvas::kStrict_SrcRectConstraint); @@ -368,7 +372,6 @@ void SkiaSurface::putPixel(gfx::Color color, int x, int y) auto r = SkIRect::MakeXYWH(x, y, 1, 1); const_cast(m_bitmap.pixmap()).erase( to_skia4f(color), - skColorSpace().get(), &r); #else // Doesn't work as SkBitmap::erase() expects an sRGB color (and @@ -435,7 +438,7 @@ void SkiaSurface::blitTo(Surface* _dst, int srcx, int srcy, int dstx, int dsty, if (!m_bitmap.empty()) { dst->m_canvas->drawImageRect( - SkImage::MakeFromRaster(m_bitmap.pixmap(), nullptr, nullptr), + SkImages::RasterFromPixmap(m_bitmap.pixmap(), nullptr, nullptr), srcRect, dstRect, SkSamplingOptions(), &paint, SkCanvas::kStrict_SrcRectConstraint); @@ -671,8 +674,9 @@ void SkiaSurface::drawSurfaceNine(os::Surface* surface, } #endif + auto image = SkImages::RasterFromPixmap(((SkiaSurface*)surface)->m_bitmap.pixmap(), nullptr, nullptr); m_canvas->drawImageLattice( - SkImage::MakeFromRaster(((SkiaSurface*)surface)->m_bitmap.pixmap(), nullptr, nullptr).get(), + image.get(), lattice, dstRect, SkFilterMode::kNearest, &skPaint); @@ -764,7 +768,7 @@ void SkiaSurface::skDrawSurface( #endif m_canvas->drawImageRect( - SkImage::MakeFromRaster(src->m_bitmap.pixmap(), nullptr, nullptr), + SkImages::RasterFromPixmap(src->m_bitmap.pixmap(), nullptr, nullptr), srcRect, dstRect, sampling, @@ -798,14 +802,14 @@ bool SkiaSurface::uploadBitmapAsTexture() const Window* win = os::instance()->defaultWindow(); GrBackendTexture texture; - SkImage::BackendTextureReleaseProc proc; - SkImage::MakeBackendTextureFromSkImage( + SkImages::BackendTextureReleaseProc proc; + SkImages::GetBackendTextureFromImage( win->sk_grCtx(), image, &texture, &proc); - m_image = SkImage::MakeFromTexture( + m_image = SkImages::BorrowTextureFrom( win->sk_grCtx(), texture, kTopLeft_GrSurfaceOrigin, diff --git a/os/skia/skia_window_osx.mm b/os/skia/skia_window_osx.mm index b8970fa21..45c6f110d 100644 --- a/os/skia/skia_window_osx.mm +++ b/os/skia/skia_window_osx.mm @@ -237,7 +237,7 @@ bitmap.eraseColor(0); SkCanvas canvas(bitmap); - canvas.drawImageRect(SkImage::MakeFromRaster(origBitmap.pixmap(), nullptr, nullptr), + canvas.drawImageRect(SkImages::RasterFromPixmap(origBitmap.pixmap(), nullptr, nullptr), SkRect::MakeXYWH(rect.x/scale, (viewBounds.size.height-(rect.y+rect.h))/scale, rect.w/scale, diff --git a/os/skia/skia_window_x11.cpp b/os/skia/skia_window_x11.cpp index eb6163a15..95c04097e 100644 --- a/os/skia/skia_window_x11.cpp +++ b/os/skia/skia_window_x11.cpp @@ -97,7 +97,7 @@ void SkiaWindowX11::onPaint(const gfx::Rect& rc) SkCanvas canvas(scaled); SkRect srcRect = SkRect::Make(SkIRect::MakeXYWH(rc.x/scale, rc.y/scale, rc.w/scale, rc.h/scale)); SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(0, 0, rc.w, rc.h)); - canvas.drawImageRect(SkImage::MakeFromRaster(bitmap.pixmap(), nullptr, nullptr), + canvas.drawImageRect(SkImages::RasterFromPixmap(bitmap.pixmap(), nullptr, nullptr), srcRect, dstRect, SkSamplingOptions(), &paint, SkCanvas::kStrict_SrcRectConstraint);