[Libreoffice-commits] core.git: Branch 'private/llunak/skia' - 4 commits - external/skia vcl/inc vcl/Library_vclplug_win.mk vcl/skia vcl/source vcl/win
Luboš Luňák (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 10 09:18:06 UTC 2019
external/skia/Library_skia.mk | 23 ++++++++
external/skia/UnpackedTarball_skia.mk | 2
external/skia/make-api-visible.patch | 37 +++++++++++++
vcl/Library_vclplug_win.mk | 2
vcl/inc/skia/gdiimpl.hxx | 2
vcl/inc/skia/salbmp.hxx | 2
vcl/inc/skia/win/gdiimpl.hxx | 53 ++++++++++++++++++
vcl/inc/skia/x11/gdiimpl.hxx | 10 ++-
vcl/inc/win/salinst.h | 1
vcl/skia/gdiimpl.cxx | 10 ++-
vcl/skia/salbmp.cxx | 1
vcl/skia/win/gdiimpl.cxx | 96 ++++++++++++++++++++++++++++++++++
vcl/skia/x11/gdiimpl.cxx | 74 ++++++++++++--------------
vcl/source/window/event.cxx | 7 +-
vcl/source/window/status.cxx | 3 +
vcl/win/app/salinst.cxx | 14 ++++
vcl/win/gdi/salfont.cxx | 1
vcl/win/gdi/salgdi.cxx | 6 +-
vcl/win/gdi/salgdi2.cxx | 9 +++
vcl/win/gdi/salnativewidgets-luna.cxx | 1
vcl/win/gdi/salvd.cxx | 7 --
vcl/win/gdi/winlayout.cxx | 3 +
22 files changed, 308 insertions(+), 56 deletions(-)
New commits:
commit ca5dbaa1b00c93461a8f0ebcf5dc420320e13ff9
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Oct 8 12:19:18 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Oct 10 11:17:18 2019 +0200
initial implementation of Skia drawing on screen in Windows
Change-Id: I1562bd2cfd1862947042bef3343aefd851a65002
diff --git a/external/skia/make-api-visible.patch b/external/skia/make-api-visible.patch
index d2c3b1f794e3..45f4ee44ae71 100644
--- a/external/skia/make-api-visible.patch
+++ b/external/skia/make-api-visible.patch
@@ -15,3 +15,23 @@
} // namespace window_context_factory
+--- skia/tools/sk_app/win/WindowContextFactory_win.h
++++ skia/tools/sk_app/win/WindowContextFactory_win.h
+@@ -18,13 +18,13 @@ struct DisplayParams;
+
+ namespace window_context_factory {
+
+-WindowContext* NewVulkanForWin(HWND, const DisplayParams&);
++SK_API WindowContext* NewVulkanForWin(HWND, const DisplayParams&);
+
+-WindowContext* NewGLForWin(HWND, const DisplayParams&);
++SK_API WindowContext* NewGLForWin(HWND, const DisplayParams&);
+
+-WindowContext* NewANGLEForWin(HWND, const DisplayParams&);
++SK_API WindowContext* NewANGLEForWin(HWND, const DisplayParams&);
+
+-WindowContext* NewRasterForWin(HWND, const DisplayParams&);
++SK_API WindowContext* NewRasterForWin(HWND, const DisplayParams&);
+
+ } // namespace window_context_factory
+
diff --git a/vcl/Library_vclplug_win.mk b/vcl/Library_vclplug_win.mk
index f64cc0392d13..a2979674d00a 100644
--- a/vcl/Library_vclplug_win.mk
+++ b/vcl/Library_vclplug_win.mk
@@ -55,10 +55,12 @@ $(eval $(call gb_Library_use_externals,vclplug_win,\
epoxy \
glm_headers \
harfbuzz \
+ skia \
))
$(eval $(call gb_Library_add_exception_objects,vclplug_win,\
vcl/opengl/win/gdiimpl \
+ vcl/skia/win/gdiimpl \
vcl/win/app/saldata \
vcl/win/app/salinfo \
vcl/win/app/salinst \
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index 543fbb669cf2..97a88db790c4 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -66,6 +66,8 @@ public:
const SkBitmap& GetAlphaSkBitmap() const;
+ const BitmapPalette& GetBitmapPalette() const { return mPalette; }
+
#ifdef DBG_UTIL
void dump(const char* file) const;
#endif
diff --git a/vcl/inc/skia/win/gdiimpl.hxx b/vcl/inc/skia/win/gdiimpl.hxx
new file mode 100644
index 000000000000..03f04ca4889c
--- /dev/null
+++ b/vcl/inc/skia/win/gdiimpl.hxx
@@ -0,0 +1,53 @@
+/* -*- 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_WIN_GDIIMPL_HXX
+#define INCLUDED_VCL_INC_SKIA_WIN_GDIIMPL_HXX
+
+#include <memory>
+#include <vcl/dllapi.h>
+
+#include <skia/gdiimpl.hxx>
+#include <win/salgdi.h>
+
+class ControlCacheKey;
+namespace sk_app
+{
+class WindowContext;
+}
+
+class WinSkiaSalGraphicsImpl : public SkiaSalGraphicsImpl
+{
+private:
+ WinSalGraphics& mWinParent;
+
+public:
+ WinSkiaSalGraphicsImpl(WinSalGraphics& rGraphics, SalGeometryProvider* mpProvider);
+
+ virtual void Init() override;
+ virtual void DeInit() override;
+
+ virtual void freeResources() override;
+
+ bool TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey, int nX, int nY);
+
+ bool RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack, int nX,
+ int nY, ControlCacheKey& aControlCacheKey);
+
+protected:
+ virtual void createSurface() override;
+ virtual void performFlush() override;
+
+private:
+ std::unique_ptr<sk_app::WindowContext> mWindowContext;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index bcd3540ad8a9..7a0c9c51ed76 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -63,6 +63,7 @@ public:
virtual SalSystem* CreateSalSystem() override;
virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
virtual bool IsMainThread() const override;
+ std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override;
virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
virtual bool AnyInput( VclInputFlags nType ) override;
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index c9936d675d66..8454de7bff0f 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -495,6 +495,7 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi
&paint);
paint.setBlendMode(SkBlendMode::kSrcIn);
canvas.drawBitmap(static_cast<const SkiaSalBitmap&>(rSourceBitmap).GetSkBitmap(), 0, 0, &paint);
+ canvas.flush();
drawBitmap(rPosAry, tmpBitmap);
return true;
}
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index b066569e1a45..8c466bc87296 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -362,7 +362,6 @@ const SkBitmap& SkiaSalBitmap::GetAlphaSkBitmap() const
const_cast<SkBitmap&>(mAlphaBitmap)
.setPixelRef(sk_ref_sp(mBitmap.pixelRef()), mBitmap.pixelRefOrigin().x(),
mBitmap.pixelRefOrigin().y());
- return mAlphaBitmap;
}
}
return mAlphaBitmap;
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
new file mode 100644
index 000000000000..fa173226b871
--- /dev/null
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -0,0 +1,96 @@
+/* -*- 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/.
+ */
+
+#include <skia/win/gdiimpl.hxx>
+
+#include <tools/sk_app/win/WindowContextFactory_win.h>
+#include <tools/sk_app/WindowContext.h>
+
+WinSkiaSalGraphicsImpl::WinSkiaSalGraphicsImpl(WinSalGraphics& rGraphics,
+ SalGeometryProvider* mpProvider)
+ : SkiaSalGraphicsImpl(rGraphics, mpProvider)
+ , mWinParent(rGraphics)
+{
+}
+
+void WinSkiaSalGraphicsImpl::Init()
+{
+#if 0 // TODO
+ if (!IsOffscreen() && mpContext.is() && mpContext->isInitialized())
+ {
+ const GLWinWindow& rGLWindow = static_cast<const GLWinWindow&>(mpContext->getOpenGLWindow());
+ if (rGLWindow.hWnd != mrWinParent.mhWnd || rGLWindow.hDC == mrWinParent.mhLocalDC)
+ {
+ // This can legitimately happen, SalFrame keeps 2x
+ // SalGraphics which share the same hWnd and hDC.
+ // The shape 'Area' dialog does reparenting to trigger this.
+ SAL_WARN("vcl.opengl", "Unusual: Windows handle / DC changed without DeInit");
+ DeInit();
+ }
+ }
+#endif
+ SkiaSalGraphicsImpl::Init();
+}
+
+void WinSkiaSalGraphicsImpl::createSurface()
+{
+ if (isOffscreen())
+ return SkiaSalGraphicsImpl::createSurface();
+ if (GetWidth() == 0 || GetHeight() == 0)
+ {
+ // When created, Init() gets called with size (0,0), which is invalid size
+ // for Skia. So fake a surface, Init() will get called later again with the correct size.
+ mSurface = SkSurface::MakeRasterN32Premul(1, 1);
+ return;
+ }
+ sk_app::DisplayParams displayParams;
+ mWindowContext.reset(
+ sk_app::window_context_factory::NewRasterForWin(mWinParent.gethWnd(), displayParams));
+ assert(SkToBool(mWindowContext)); // TODO
+ mSurface = mWindowContext->getBackbufferSurface();
+ assert(mSurface.get());
+}
+
+void WinSkiaSalGraphicsImpl::DeInit()
+{
+ mWindowContext.reset();
+ SkiaSalGraphicsImpl::DeInit();
+}
+
+void WinSkiaSalGraphicsImpl::freeResources() {}
+
+void WinSkiaSalGraphicsImpl::performFlush()
+{
+ if (mWindowContext)
+ mWindowContext->swapBuffers();
+}
+
+bool WinSkiaSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey,
+ int nX, int nY)
+{
+ (void)rControlCacheKey;
+ (void)nX;
+ (void)nY;
+ return false; // TODO
+}
+
+// TODO OpenGLCompatibleDC?
+bool WinSkiaSalGraphicsImpl::RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite,
+ OpenGLCompatibleDC& rBlack, int nX, int nY,
+ ControlCacheKey& aControlCacheKey)
+{
+ (void)rWhite;
+ (void)rBlack;
+ (void)nX;
+ (void)nY;
+ (void)aControlCacheKey;
+ return false; // TODO
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index c8c6b730e1dd..f962b57c209f 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -22,6 +22,7 @@
#include <vcl/dockwin.hxx>
#include <vcl/layout.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
#include <sal/log.hxx>
#include <window.h>
@@ -517,10 +518,12 @@ void Window::ImplCallResize()
#if HAVE_FEATURE_OPENGL
if( OpenGLWrapper::isVCLOpenGLEnabled() )
Invalidate();
-
- // Normally we avoid blanking on re-size unless people might notice:
else
#endif
+ if( SkiaHelper::isVCLSkiaEnabled() ) // TODO
+ Invalidate();
+ // Normally we avoid blanking on re-size unless people might notice:
+ else
if( GetBackground().IsGradient() )
Invalidate();
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 61c17df48dab..deb552f8d4a8 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -30,6 +30,7 @@
#if HAVE_FEATURE_OPENGL
#include <vcl/opengl/OpenGLWrapper.hxx>
#endif
+#include <vcl/skia/SkiaHelper.hxx>
#include <svdata.hxx>
#include <window.h>
@@ -723,6 +724,8 @@ void StatusBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle
if( OpenGLWrapper::isVCLOpenGLEnabled() )
bOffscreen = false;
#endif
+ if( SkiaHelper::isVCLSkiaEnabled() ) // TODO
+ bOffscreen = false;
if (!bOffscreen)
rRenderContext.Erase(rRect);
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 3a5fd78f743b..54df30da1f0e 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -32,11 +32,13 @@
#include <vcl/inputtypes.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
#include <vcl/timer.hxx>
#include <vclpluginapi.h>
#include <opengl/salbmp.hxx>
#include <opengl/win/gdiimpl.hxx>
+#include <skia/salbmp.hxx>
#include <win/wincomp.hxx>
#include <win/salids.hrc>
#include <win/saldata.hxx>
@@ -967,12 +969,22 @@ SalTimer* WinSalInstance::CreateSalTimer()
std::shared_ptr<SalBitmap> WinSalInstance::CreateSalBitmap()
{
- if (OpenGLHelper::isVCLOpenGLEnabled())
+ if (SkiaHelper::isVCLSkiaEnabled())
+ return std::make_shared<SkiaSalBitmap>();
+ else if (OpenGLHelper::isVCLOpenGLEnabled())
return std::make_shared<OpenGLSalBitmap>();
else
return std::make_shared<WinSalBitmap>();
}
+std::shared_ptr<vcl::BackendCapabilities> WinSalInstance::GetBackendCapabilities()
+{
+ auto pBackendCapabilities = SalInstance::GetBackendCapabilities();
+ if( SkiaHelper::isVCLSkiaEnabled())
+ pBackendCapabilities->mbSupportsBitmap32 = true;
+ return pBackendCapabilities;
+}
+
int WinSalInstance::WorkaroundExceptionHandlingInUSER32Lib(int, LPEXCEPTION_POINTERS pExceptionInfo)
{
// Decide if an exception is a c++ (mostly UNO) exception or a process violation.
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 5a866092bf30..2218e5030e04 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -781,6 +781,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
static BYTE nDefaultQuality = NONANTIALIASED_QUALITY;
if (nDefaultQuality == NONANTIALIASED_QUALITY)
{
+ // TODO skia
if (OpenGLWrapper::isVCLOpenGLEnabled())
nDefaultQuality = ANTIALIASED_QUALITY;
else
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 2d4a283bb818..19553f415eee 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -35,8 +35,10 @@
#include <salgdiimpl.hxx>
#include "gdiimpl.hxx"
#include <opengl/win/gdiimpl.hxx>
+#include <skia/win/gdiimpl.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
#define DITHER_PAL_DELTA 51
@@ -619,7 +621,9 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
mpStdClipRgnData(nullptr),
mnPenWidth(GSL_PEN_WIDTH)
{
- if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
+ if (SkiaHelper::isVCLSkiaEnabled() && !mbPrinter)
+ mpImpl.reset(new WinSkiaSalGraphicsImpl(*this, pProvider));
+ else if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this, pProvider));
else
mpImpl.reset(new WinSalGraphicsImpl(*this));
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx
index ceddcb5b2c8a..7e04366351f6 100644
--- a/vcl/win/gdi/salgdi2.cxx
+++ b/vcl/win/gdi/salgdi2.cxx
@@ -30,12 +30,14 @@
#include <win/salgdi.h>
#include <win/salframe.h>
#include <opengl/salbmp.hxx>
+#include <skia/salbmp.hxx>
#include <vcl/salbtype.hxx>
#include <vcl/bitmapaccess.hxx>
#include <outdata.hxx>
#include <salgdiimpl.hxx>
#include <opengl/win/gdiimpl.hxx>
+#include <skia/win/gdiimpl.hxx>
bool WinSalGraphics::supportsOperation( OutDevSupportType eType ) const
@@ -120,6 +122,11 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
{
aBitmapPalette = pGLSalBitmap->GetBitmapPalette();
}
+ SkiaSalBitmap* pSkiaSalBitmap = dynamic_cast<SkiaSalBitmap*>(&rSalBitmap);
+ if (pSkiaSalBitmap != nullptr) // TODO
+ {
+ aBitmapPalette = pSkiaSalBitmap->GetBitmapPalette();
+ }
BitmapBuffer* pRead = rSalBitmap.AcquireBuffer(BitmapAccessMode::Read);
@@ -165,6 +172,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap)
{
if (dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get()) == nullptr &&
+ dynamic_cast<WinSkiaSalGraphicsImpl*>(mpImpl.get()) == nullptr &&
dynamic_cast<const WinSalBitmap*>(&rSalBitmap) == nullptr)
{
std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap());
@@ -183,6 +191,7 @@ void WinSalGraphics::drawBitmap( const SalTwoRect& rPosAry,
const SalBitmap& rSTransparentBitmap )
{
if (dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get()) == nullptr &&
+ dynamic_cast<WinSkiaSalGraphicsImpl*>(mpImpl.get()) == nullptr &&
dynamic_cast<const WinSalBitmap*>(&rSSalBitmap) == nullptr)
{
std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap());
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 84a9bda35ec3..1bfc5312b9a6 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -1159,6 +1159,7 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
tools::Rectangle cacheRect = rControlRegion;
Size keySize = cacheRect.GetSize();
+ // TODO skia
WinOpenGLSalGraphicsImpl* pImpl = dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get());
// tdf#95618 - A few controls render outside the region they're given.
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 25949dc0692e..ec8472a5256b 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -434,6 +434,7 @@ bool WinSalGraphics::DrawCachedGlyphs(const GenericSalLayout& rLayout)
COLORREF color = GetTextColor(hDC);
Color salColor = Color(GetRValue(color), GetGValue(color), GetBValue(color));
+ // TODO skia
WinOpenGLSalGraphicsImpl *pImpl = dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get());
if (!pImpl)
return false;
@@ -475,6 +476,7 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
const WinFontInstance* pWinFont = static_cast<const WinFontInstance*>(&rLayout.GetFont());
const HFONT hLayoutFont = pWinFont->GetHFONT();
+ // TODO skia
bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
// Our DirectWrite renderer is incomplete, skip it for vertical text where glyphs are not
@@ -523,6 +525,7 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
tools::Rectangle aRect;
rLayout.GetBoundRect(aRect);
+ // TODO skia
WinOpenGLSalGraphicsImpl *pImpl = dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get());
if (pImpl)
commit db75c4e194cb97aa4e352fa38a45c012ce597e30
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Oct 8 11:47:17 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Oct 10 11:14:12 2019 +0200
make WinSalVirtualDevice::SetSize() always call Init() for all Impl's
I don't see why this should be OpenGL-only. For WinSalGraphicsImpl
it's a no-op anyway, and for other Impl's it may be useful to find
out that they have been in fact resized. For Skia this is necessary
because Init() the first time may get called with empty size.
Change-Id: I4a8fa0fc633b415735d3633e89f208ab1c1f1229
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 57ad9581b1c4..e1cacb8b098a 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -218,12 +218,7 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
mhBmp.reset(hNewBmp);
if (mpGraphics)
- {
- WinOpenGLSalGraphicsImpl *pImpl;
- pImpl = dynamic_cast< WinOpenGLSalGraphicsImpl * >(mpGraphics->GetImpl());
- if (pImpl)
- pImpl->Init();
- }
+ mpGraphics->GetImpl()->Init();
return true;
}
commit 3d1b9405ad3507d788f7321d3aaddf40febf35d8
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Oct 7 12:40:02 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Oct 10 11:14:08 2019 +0200
make X11/Skia render to screen using Skia code
Change-Id: I3056afe2ba0a15e0798d209ab9bd833c773948be
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 28f088179611..91e3db4be5f8 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -197,6 +197,8 @@ public:
#endif
protected:
+ virtual void createSurface();
+
void setProvider(SalGeometryProvider* provider) { mProvider = provider; }
bool isOffscreen() const { return mProvider == nullptr || mProvider->IsOffScreen(); }
diff --git a/vcl/inc/skia/x11/gdiimpl.hxx b/vcl/inc/skia/x11/gdiimpl.hxx
index fcc0ecb116d8..c3ffb1221cd9 100644
--- a/vcl/inc/skia/x11/gdiimpl.hxx
+++ b/vcl/inc/skia/x11/gdiimpl.hxx
@@ -16,6 +16,11 @@
#include <unx/x11/x11gdiimpl.h>
#include <skia/gdiimpl.hxx>
+namespace sk_app
+{
+class WindowContext;
+}
+
class VCL_PLUGIN_PUBLIC X11SkiaSalGraphicsImpl : public SkiaSalGraphicsImpl, public X11GraphicsImpl
{
private:
@@ -26,6 +31,7 @@ public:
virtual ~X11SkiaSalGraphicsImpl() override;
virtual void Init() override;
+ virtual void DeInit() override;
virtual void freeResources() override;
// implementation of X11GraphicsImpl
@@ -36,11 +42,11 @@ public:
bool TryRenderCachedNativeControl(ControlCacheKey& rControlCacheKey, int nX, int nY) override;
protected:
+ virtual void createSurface() override;
virtual void performFlush() override;
private:
- GC getGC();
- GC mCopyGc;
+ std::unique_ptr<sk_app::WindowContext> mWindowContext;
};
#endif // INCLUDED_VCL_INC_SKIA_X11_GDIIMPL_HXX
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 07937c6b9cb0..c9936d675d66 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -67,8 +67,7 @@ SkiaSalGraphicsImpl::~SkiaSalGraphicsImpl() {}
void SkiaSalGraphicsImpl::Init()
{
- // TODO
- mSurface = SkSurface::MakeRasterN32Premul(GetWidth(), GetHeight());
+ createSurface();
mSurface->getCanvas()->save(); // see SetClipRegion()
mClipRegion = vcl::Region(tools::Rectangle(0, 0, GetWidth(), GetHeight()));
@@ -76,6 +75,12 @@ void SkiaSalGraphicsImpl::Init()
mFlush->SetPriority(TaskPriority::POST_PAINT);
}
+void SkiaSalGraphicsImpl::createSurface()
+{
+ // TODO
+ mSurface = SkSurface::MakeRasterN32Premul(GetWidth(), GetHeight());
+}
+
void SkiaSalGraphicsImpl::DeInit() { mSurface.reset(); }
static SkIRect toSkIRect(const tools::Rectangle& rectangle)
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 3891de5b059e..5c4408eff7c2 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -18,10 +18,16 @@
#include <skia/x11/gdiimpl.hxx>
+// TODO
+#define SK_ASSUME_GL 1
+#define SK_ASSUME_GL_ES 0
+
+#include <tools/sk_app/unix/WindowContextFactory_unix.h>
+#include <tools/sk_app/WindowContext.h>
+
X11SkiaSalGraphicsImpl::X11SkiaSalGraphicsImpl(X11SalGraphics& rParent)
: SkiaSalGraphicsImpl(rParent, rParent.GetGeometryProvider())
, mParent(rParent)
- , mCopyGc(None)
{
}
@@ -34,54 +40,42 @@ void X11SkiaSalGraphicsImpl::Init()
SkiaSalGraphicsImpl::Init();
}
-GC X11SkiaSalGraphicsImpl::getGC()
+void X11SkiaSalGraphicsImpl::createSurface()
{
- if (mCopyGc == None)
- {
- XGCValues values;
- values.graphics_exposures = False;
- values.subwindow_mode = ClipByChildren;
- mCopyGc = XCreateGC(mParent.GetXDisplay(), mParent.GetDrawable(),
- GCGraphicsExposures | GCSubwindowMode, &values);
- }
- return mCopyGc;
+ if (isOffscreen())
+ return SkiaSalGraphicsImpl::createSurface();
+ sk_app::DisplayParams displayParams;
+ // TODO The Skia Xlib code actually requires the non-native color type to work properly.
+ // Use a macro to hide an unreachable code warning.
+#define GET_FORMAT \
+ kN32_SkColorType == kBGRA_8888_SkColorType ? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType
+ displayParams.fColorType = GET_FORMAT;
+#undef GET_FORMAT
+ sk_app::window_context_factory::XlibWindowInfo winInfo;
+ winInfo.fDisplay = mParent.GetXDisplay();
+ winInfo.fWindow = mParent.GetDrawable();
+ assert(winInfo.fDisplay && winInfo.fWindow != None);
+ winInfo.fFBConfig = nullptr; // not used
+ winInfo.fVisualInfo = const_cast<SalVisual*>(&mParent.GetVisual());
+ winInfo.fWidth = GetWidth();
+ winInfo.fHeight = GetHeight();
+ mWindowContext.reset(sk_app::window_context_factory::NewRasterForXlib(winInfo, displayParams));
+ assert(SkToBool(mWindowContext)); // TODO
+ mSurface = mWindowContext->getBackbufferSurface();
}
-void X11SkiaSalGraphicsImpl::freeResources()
+void X11SkiaSalGraphicsImpl::DeInit()
{
- if (mCopyGc != None)
- {
- XFreeGC(mParent.GetXDisplay(), mCopyGc);
- mCopyGc = None;
- }
+ mWindowContext.reset();
+ SkiaSalGraphicsImpl::DeInit();
}
+void X11SkiaSalGraphicsImpl::freeResources() {}
+
void X11SkiaSalGraphicsImpl::performFlush()
{
- Display* dpy = mParent.GetXDisplay();
- Drawable drawable = mParent.GetDrawable();
- GC gc = getGC();
- SkPixmap pm;
- if (!mSurface->peekPixels(&pm))
- abort();
- int bitsPerPixel = pm.info().bytesPerPixel() * 8;
- XImage image;
- memset(&image, 0, sizeof(image));
- image.width = pm.width();
- image.height = pm.height();
- image.format = ZPixmap;
- image.data = (char*)pm.addr();
- image.byte_order = LSBFirst;
- image.bitmap_unit = bitsPerPixel;
- image.bitmap_bit_order = LSBFirst;
- image.bitmap_pad = bitsPerPixel;
- image.depth = 24;
- image.bytes_per_line = pm.rowBytes() - pm.width() * pm.info().bytesPerPixel();
- image.bits_per_pixel = bitsPerPixel;
- if (!XInitImage(&image))
- abort();
// TODO XPutImage() is somewhat inefficient, XShmPutImage() should be preferred.
- XPutImage(dpy, drawable, gc, &image, 0, 0, 0, 0, pm.width(), pm.height());
+ mWindowContext->swapBuffers();
}
void X11SkiaSalGraphicsImpl::FillPixmapFromScreen(X11Pixmap* pPixmap, int nX, int nY)
commit f15162033e8716d469052d0e1ebcde395baf30c0
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Oct 7 12:01:04 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Oct 10 11:14:03 2019 +0200
build also the tools/sk_app part of Skia
That's basically code that allows intergrating the library with X11 etc.
Change-Id: I3f5506ef4ecc334b4e93c4450fb1aa4c53dbfefc
diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk
index 60eb173f9628..bc1af13af801 100644
--- a/external/skia/Library_skia.mk
+++ b/external/skia/Library_skia.mk
@@ -26,6 +26,8 @@ $(eval $(call gb_Library_add_defs,skia,\
-DSK_HAS_JPEG_LIBRARY=1 \
-DSK_HAS_PNG_LIBRARY=1 \
-DSK_GAMMA_APPLY_TO_A8 \
+ -DSK_ASSUME_GL=1 \
+ -DSK_ASSUME_GL_ES=0 \
))
ifneq (,$(gb_ENABLE_DBGUTIL))
@@ -93,6 +95,9 @@ $(eval $(call gb_Library_add_libs,skia,\
-lm \
-ldl \
-lGLX \
+ -lGL \
+ -lX11-xcb \
+ -lX11 \
))
endif
@@ -832,6 +837,12 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/ports/SkOSFile_stdio \
))
+$(eval $(call gb_Library_add_generated_exception_objects,skia,\
+ UnpackedTarball/skia/tools/gpu/vk/VkTestUtils \
+ UnpackedTarball/skia/tools/sk_app/GLWindowContext \
+ UnpackedTarball/skia/tools/sk_app/VulkanWindowContext \
+))
+
ifeq ($(OS),WNT)
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/gpu/gl/win/GrGLMakeNativeInterface_win \
@@ -853,6 +864,12 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/utils/win/SkIStream \
UnpackedTarball/skia/src/utils/win/SkWGL_win \
))
+
+$(eval $(call gb_Library_add_generated_exception_objects,skia,\
+ UnpackedTarball/skia/tools/sk_app/win/GLWindowContext_win \
+ UnpackedTarball/skia/tools/sk_app/win/RasterWindowContext_win \
+ UnpackedTarball/skia/tools/sk_app/win/VulkanWindowContext_win \
+))
else
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/gpu/gl/glx/GrGLMakeNativeInterface_glx \
@@ -869,6 +886,12 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/ports/SkOSLibrary_posix \
UnpackedTarball/skia/src/ports/SkTLS_pthread \
))
+
+$(eval $(call gb_Library_add_generated_exception_objects,skia,\
+ UnpackedTarball/skia/tools/sk_app/unix/GLWindowContext_unix \
+ UnpackedTarball/skia/tools/sk_app/unix/RasterWindowContext_unix \
+ UnpackedTarball/skia/tools/sk_app/unix/VulkanWindowContext_unix \
+))
endif
diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index 7ae3bf4427fc..462d07edf8f2 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -12,7 +12,7 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,skia))
$(eval $(call gb_UnpackedTarball_set_tarball,skia,$(SKIA_TARBALL)))
# TODO
-skia_patches := lerp.patch fix-pch.patch fix-ddi.patch
+skia_patches := lerp.patch fix-pch.patch fix-ddi.patch make-api-visible.patch
$(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/make-api-visible.patch b/external/skia/make-api-visible.patch
new file mode 100644
index 000000000000..d2c3b1f794e3
--- /dev/null
+++ b/external/skia/make-api-visible.patch
@@ -0,0 +1,17 @@
+--- skia/tools/sk_app/unix/WindowContextFactory_unix.h.sav 2019-09-26 15:02:19.637587019 +0200
++++ skia/tools/sk_app/unix/WindowContextFactory_unix.h 2019-10-07 11:52:46.744194127 +0200
+@@ -33,11 +33,11 @@ struct XlibWindowInfo {
+ int fHeight;
+ };
+
+-WindowContext* NewVulkanForXlib(const XlibWindowInfo&, const DisplayParams&);
++SK_API WindowContext* NewVulkanForXlib(const XlibWindowInfo&, const DisplayParams&);
+
+-WindowContext* NewGLForXlib(const XlibWindowInfo&, const DisplayParams&);
++SK_API WindowContext* NewGLForXlib(const XlibWindowInfo&, const DisplayParams&);
+
+-WindowContext* NewRasterForXlib(const XlibWindowInfo&, const DisplayParams&);
++SK_API WindowContext* NewRasterForXlib(const XlibWindowInfo&, const DisplayParams&);
+
+ } // namespace window_context_factory
+
More information about the Libreoffice-commits
mailing list