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/inc | |
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/inc')
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 26 | ||||
-rw-r--r-- | vcl/inc/skia/osx/gdiimpl.hxx | 42 | ||||
-rw-r--r-- | vcl/inc/skia/osx/rastercontext.hxx | 42 |
3 files changed, 107 insertions, 3 deletions
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index afddffb6a9f9..ab7a25ee9b7c 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -267,11 +267,31 @@ struct AquaSharedAttributes } }; -class AquaGraphicsBackend final : public SalGraphicsImpl +class AquaGraphicsBackendBase { private: + SalGraphicsImpl* mpImpl = nullptr; +protected: AquaSharedAttributes& mrShared; +public: + AquaGraphicsBackendBase(AquaSharedAttributes& rShared) + : mrShared( rShared ) + {} + virtual ~AquaGraphicsBackendBase() = 0; + AquaSharedAttributes& GetShared() { return mrShared; } + SalGraphicsImpl* GetImpl() + { + if(mpImpl == nullptr) + mpImpl = dynamic_cast<SalGraphicsImpl*>(this); + return mpImpl; + } +}; + +inline AquaGraphicsBackendBase::~AquaGraphicsBackendBase() {} +class AquaGraphicsBackend final : public SalGraphicsImpl, public AquaGraphicsBackendBase +{ +private: void drawPixelImpl( tools::Long nX, tools::Long nY, const RGBAColor& rColor); // helper to draw single pixels #ifdef MACOSX @@ -400,7 +420,7 @@ public: class AquaSalGraphics : public SalGraphicsAutoDelegateToImpl { AquaSharedAttributes maShared; - std::unique_ptr<AquaGraphicsBackend> mpBackend; + std::unique_ptr<AquaGraphicsBackendBase> mpBackend; /// device resolution of this graphics sal_Int32 mnRealDPIX; @@ -443,7 +463,7 @@ public: // InvalidateContext does an UnsetState and sets mrContext to 0 void InvalidateContext(); - AquaGraphicsBackend* getAquaGraphicsBackend() const + AquaGraphicsBackendBase* getAquaGraphicsBackend() const { return mpBackend.get(); } diff --git a/vcl/inc/skia/osx/gdiimpl.hxx b/vcl/inc/skia/osx/gdiimpl.hxx new file mode 100644 index 000000000000..8523d272e897 --- /dev/null +++ b/vcl/inc/skia/osx/gdiimpl.hxx @@ -0,0 +1,42 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_INC_SKIA_OSX_GDIIMPL_HXX +#define INCLUDED_VCL_INC_SKIA_OSX_GDIIMPL_HXX + +#include <vcl/dllapi.h> + +#include <quartz/salgdi.h> + +#include <skia/gdiimpl.hxx> +#include <skia/utils.hxx> + +class VCL_PLUGIN_PUBLIC AquaSkiaSalGraphicsImpl final : public SkiaSalGraphicsImpl, + public AquaGraphicsBackendBase +{ +public: + AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent, AquaSharedAttributes& rShared); + virtual ~AquaSkiaSalGraphicsImpl() override; + + virtual void Init() override; + virtual void DeInit() override; + virtual void freeResources() override; + // virtual void Flush() override; + + static void prepareSkia(); + +private: + virtual void createWindowContext(bool forceRaster = false) override; + virtual void performFlush() override; + friend std::unique_ptr<sk_app::WindowContext> createVulkanWindowContext(bool); +}; + +#endif // INCLUDED_VCL_INC_SKIA_OSX_GDIIMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/skia/osx/rastercontext.hxx b/vcl/inc/skia/osx/rastercontext.hxx new file mode 100644 index 000000000000..84891d4b8642 --- /dev/null +++ b/vcl/inc/skia/osx/rastercontext.hxx @@ -0,0 +1,42 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_INC_SKIA_OSX_RASTERCONTEXT_HXX +#define INCLUDED_VCL_INC_SKIA_OSX_RASTERCONTEXT_HXX + +#include <tools/sk_app/WindowContext.h> + +class AquaSkiaSalGraphicsImpl; + +// RasterWindowContext_mac uses OpenGL internally, which +// we don't want, so make our own raster window context +// based on SkBitmap, and our code will handle things like flush. + +class AquaSkiaWindowContextRaster : public sk_app::WindowContext +{ +public: + AquaSkiaWindowContextRaster(int w, int h, const sk_app::DisplayParams& params); + virtual sk_sp<SkSurface> getBackbufferSurface() override { return mSurface; } + // Not to be called, our mac code should be used. + virtual void swapBuffers(const SkIRect* = nullptr) override { abort(); } + virtual bool isValid() override { return mSurface.get(); }; + virtual void resize(int w, int h) override; + virtual void setDisplayParams(const sk_app::DisplayParams& params) override; + +protected: + virtual bool isGpuContext() override { return false; } + +private: + void createSurface(); + sk_sp<SkSurface> mSurface; +}; + +#endif // INCLUDED_VCL_INC_SKIA_OSX_RASTERCONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |