diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-08-12 13:24:07 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-08-23 14:59:08 +0200 |
commit | 13acc8a5df8db5fa24d72c1d44b35e41e4ca2a7c (patch) | |
tree | cbffe0b2afee7b1796cfce03a96640954e977aff /vcl/skia/osx | |
parent | 00083cfa840269ef5e569c7c4a6a09a34e6ce2db (diff) |
first WIP version of mac skia SalGraphics backend
It doesn't yet blit to screen, but the basics should be there.
Change-Id: I0f77b66756f578d84d0cee16cda00e7a2fea714f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120805
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia/osx')
-rw-r--r-- | vcl/skia/osx/gdiimpl.cxx | 93 | ||||
-rw-r--r-- | vcl/skia/osx/rastercontext.cxx | 51 |
2 files changed, 144 insertions, 0 deletions
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx new file mode 100644 index 000000000000..e15406ea831c --- /dev/null +++ b/vcl/skia/osx/gdiimpl.cxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Some of this code is based on Skia source code, covered by the following + * license notice (see readlicense_oo for the full license): + * + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + */ + +#include <skia/osx/gdiimpl.hxx> + +#include <skia/utils.hxx> +#include <skia/zone.hxx> + +#include <skia/osx/rastercontext.hxx> + +using namespace SkiaHelper; + +AquaSkiaSalGraphicsImpl::AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent, + AquaSharedAttributes& rShared) + : SkiaSalGraphicsImpl(rParent, rShared.mpFrame) + , AquaGraphicsBackendBase(rShared) +{ +} + +AquaSkiaSalGraphicsImpl::~AquaSkiaSalGraphicsImpl() { DeInit(); } + +void AquaSkiaSalGraphicsImpl::Init() +{ + // The m_pFrame and m_pVDev pointers are updated late in X11 + // setProvider(mX11Parent.GetGeometryProvider()); + // SkiaSalGraphicsImpl::Init(); +} + +void AquaSkiaSalGraphicsImpl::DeInit() +{ + SkiaZone zone; + SkiaSalGraphicsImpl::DeInit(); + mWindowContext.reset(); +} + +void AquaSkiaSalGraphicsImpl::freeResources() {} + +void AquaSkiaSalGraphicsImpl::createWindowContext(bool forceRaster) +{ + SkiaZone zone; + sk_app::DisplayParams displayParams; + displayParams.fColorType = kN32_SkColorType; + RenderMethod renderMethod = forceRaster ? RenderRaster : renderMethodToUse(); + switch (renderMethod) + { + case RenderRaster: + displayParams.fColorType = kBGRA_8888_SkColorType; // TODO + mWindowContext.reset( + new AquaSkiaWindowContextRaster(GetWidth(), GetHeight(), displayParams)); + break; + case RenderVulkan: + abort(); + break; + } +} + +//void AquaSkiaSalGraphicsImpl::Flush() { performFlush(); } + +void AquaSkiaSalGraphicsImpl::performFlush() +{ + SkiaZone zone; + flushDrawing(); + if (mWindowContext) + { + if (mDirtyRect.intersect(SkIRect::MakeWH(GetWidth(), GetHeight()))) + mWindowContext->swapBuffers(&mDirtyRect); // TODO + mDirtyRect.setEmpty(); + } +} + +std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool /*temporary*/) +{ + return nullptr; +} + +void AquaSkiaSalGraphicsImpl::prepareSkia() { SkiaHelper::prepareSkia(createVulkanWindowContext); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/skia/osx/rastercontext.cxx b/vcl/skia/osx/rastercontext.cxx new file mode 100644 index 000000000000..a2a514483710 --- /dev/null +++ b/vcl/skia/osx/rastercontext.cxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Some of this code is based on Skia source code, covered by the following + * license notice (see readlicense_oo for the full license): + * + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + */ + +#include <skia/osx/rastercontext.hxx> + +#include <SkSurface.h> + +AquaSkiaWindowContextRaster::AquaSkiaWindowContextRaster(int w, int h, + const sk_app::DisplayParams& params) + : WindowContext(params) +{ + fWidth = w; + fHeight = h; + resize(w, h); +} + +void AquaSkiaWindowContextRaster::resize(int w, int h) +{ + fWidth = w; + fHeight = h; + createSurface(); +} + +void AquaSkiaWindowContextRaster::setDisplayParams(const sk_app::DisplayParams& params) +{ + fDisplayParams = params; +} + +void AquaSkiaWindowContextRaster::createSurface() +{ + SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType, + kPremul_SkAlphaType, fDisplayParams.fColorSpace); + mSurface = SkSurface::MakeRaster(info, &fDisplayParams.fSurfaceProps); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |