summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-10-16 16:08:51 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-11-27 09:55:08 +0100
commit6f5c85daa0e5073d87d1d7699bfa59af159686ca (patch)
treeb26f513768e8ad6c825c9fa686a4d4b94f39a98e /vcl/inc
parentef943999fbac70a28066093028e2192f8aba4c72 (diff)
basic implementation of Skia text drawing on Windows
Change-Id: If66e92aef04cd5bbeb22b8c5da65b7b9c77fed23
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/opengl/win/gdiimpl.hxx2
-rw-r--r--vcl/inc/skia/gdiimpl.hxx1
-rw-r--r--vcl/inc/skia/win/gdiimpl.hxx30
-rw-r--r--vcl/inc/skia/win/winlayout.hxx32
-rw-r--r--vcl/inc/win/wingdiimpl.hxx30
-rw-r--r--vcl/inc/win/winlayout.hxx8
6 files changed, 90 insertions, 13 deletions
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index f7d3865ceec7..02b8b3850cab 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -72,8 +72,8 @@ public:
using OpenGLSalGraphicsImpl::DrawMask;
virtual void DeferredTextDraw(const CompatibleDC::Texture* pTexture, Color nMaskColor, const SalTwoRect& rPosAry) override;
+ virtual bool UseRenderNativeControl() const { return true; }
virtual bool TryRenderCachedNativeControl(ControlCacheKey const & rControlCacheKey, int nX, int nY) override;
-
virtual bool RenderAndCacheNativeControl(CompatibleDC& rWhite, CompatibleDC& rBlack,
int nX, int nY , ControlCacheKey& aControlCacheKey) override;
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 96bc628e1dd6..68646a78d4bc 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -218,6 +218,7 @@ protected:
return Color(255 - SkColorGetA(color), SkColorGetR(color), SkColorGetG(color),
SkColorGetB(color));
}
+ void drawMask(const SalTwoRect& rPosAry, const SkBitmap& rBitmap, Color nMaskColor);
SalGraphics& mParent;
/// Pointer to the SalFrame or SalVirtualDevice
diff --git a/vcl/inc/skia/win/gdiimpl.hxx b/vcl/inc/skia/win/gdiimpl.hxx
index 4c47f02baa95..05cacb69d230 100644
--- a/vcl/inc/skia/win/gdiimpl.hxx
+++ b/vcl/inc/skia/win/gdiimpl.hxx
@@ -23,6 +23,26 @@ namespace sk_app
class WindowContext;
}
+class SkiaCompatibleDC : public CompatibleDC
+{
+public:
+ SkiaCompatibleDC(SalGraphics& rGraphics, int x, int y, int width, int height);
+
+ virtual std::unique_ptr<Texture> getTexture() override;
+
+ virtual bool copyToTexture(Texture& aTexture) override;
+
+ struct Texture;
+};
+
+struct SkiaCompatibleDC::Texture : public CompatibleDC::Texture
+{
+ SkBitmap bitmap; // TODO SkBitmap, SkSurface, SkImage?
+ virtual bool isValid() const { return !bitmap.drawsNothing(); }
+ virtual int GetWidth() const { return bitmap.width(); }
+ virtual int GetHeight() const { return bitmap.height(); }
+};
+
class WinSkiaSalGraphicsImpl : public SkiaSalGraphicsImpl, public WinSalGraphicsImplBase
{
private:
@@ -37,12 +57,20 @@ public:
virtual void freeResources() override;
+ virtual bool UseRenderNativeControl() const override { return true; }
virtual bool TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey, int nX,
int nY) override;
-
virtual bool RenderAndCacheNativeControl(CompatibleDC& rWhite, CompatibleDC& rBlack, int nX,
int nY, ControlCacheKey& aControlCacheKey) override;
+ virtual bool UseTextDraw() const override { return true; }
+ virtual void PreDrawText() override;
+ virtual void PostDrawText() override;
+ virtual void DrawMask(CompatibleDC::Texture* rTexture, Color nMaskColor,
+ const SalTwoRect& rPosAry) override;
+ virtual void DeferredTextDraw(const CompatibleDC::Texture* pTexture, Color nMaskColor,
+ const SalTwoRect& rPosAry) override;
+
protected:
virtual void createSurface() override;
virtual void performFlush() override;
diff --git a/vcl/inc/skia/win/winlayout.hxx b/vcl/inc/skia/win/winlayout.hxx
new file mode 100644
index 000000000000..2455c39d06e8
--- /dev/null
+++ b/vcl/inc/skia/win/winlayout.hxx
@@ -0,0 +1,32 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_SKIA_WIN_WINLAYOUT_HXX
+#define INCLUDED_VCL_INC_SKIA_WIN_WINLAYOUT_HXX
+
+#include <win/winlayout.hxx>
+
+struct SkiaGlobalWinGlyphCache : public GlobalWinGlyphCache
+{
+ virtual bool AllocateTexture(WinGlyphDrawElement& rElement, int nWidth, int nHeight) override;
+};
+
+#endif // INCLUDED_VCL_INC_SKIA_WIN_WINLAYOUT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/wingdiimpl.hxx b/vcl/inc/win/wingdiimpl.hxx
index d283f4c2bb5c..2264eecf353d 100644
--- a/vcl/inc/win/wingdiimpl.hxx
+++ b/vcl/inc/win/wingdiimpl.hxx
@@ -21,22 +21,34 @@ class WinSalGraphicsImplBase
public:
virtual ~WinSalGraphicsImplBase(){};
- virtual bool TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey, int nX,
- int nY)
- = 0;
-
- virtual bool RenderAndCacheNativeControl(CompatibleDC& rWhite, CompatibleDC& rBlack, int nX,
- int nY, ControlCacheKey& aControlCacheKey)
- = 0;
+ // If true is returned, the following functions are used for drawing controls.
+ virtual bool UseRenderNativeControl() const { return false; }
+ virtual bool TryRenderCachedNativeControl(const ControlCacheKey& /*rControlCacheKey*/,
+ int /*nX*/, int /*nY*/)
+ {
+ abort();
+ };
+ virtual bool RenderAndCacheNativeControl(CompatibleDC& /*rWhite*/, CompatibleDC& /*rBlack*/,
+ int /*nX*/, int /*nY*/,
+ ControlCacheKey& /*aControlCacheKey*/)
+ {
+ abort();
+ };
// If true is returned, the following functions are used for text rendering.
virtual bool UseTextDraw() const { return false; }
virtual void PreDrawText() {}
virtual void PostDrawText() {}
virtual void DrawMask(CompatibleDC::Texture* /*rTexture*/, Color /*nMaskColor*/,
- const SalTwoRect& /*rPosAry*/){};
+ const SalTwoRect& /*rPosAry*/)
+ {
+ abort();
+ };
virtual void DeferredTextDraw(const CompatibleDC::Texture* /*pTexture*/, Color /*nMaskColor*/,
- const SalTwoRect& /*rPosAry*/){};
+ const SalTwoRect& /*rPosAry*/)
+ {
+ abort();
+ };
};
#endif // INCLUDED_VCL_INC_WIN_WINGDIIMPL_HXX
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index aef394fa83e3..0e819d7de369 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -75,22 +75,26 @@ protected:
public:
WinGlyphCache()
{
- GlobalWinGlyphCache::get()->maWinGlyphCaches.insert(this);
+ if(GlobalWinGlyphCache* c = GlobalWinGlyphCache::get())
+ c->maWinGlyphCaches.insert(this);
}
virtual ~WinGlyphCache()
{
- GlobalWinGlyphCache::get()->maWinGlyphCaches.erase(this);
+ if(GlobalWinGlyphCache* c = GlobalWinGlyphCache::get())
+ c->maWinGlyphCaches.erase(this);
}
void PutDrawElementInCache(WinGlyphDrawElement&& rElement, int nGlyphIndex)
{
+ assert(GlobalWinGlyphCache::get());
assert(!IsGlyphCached(nGlyphIndex));
maWinTextureCache[nGlyphIndex] = std::move( rElement );
}
WinGlyphDrawElement& GetDrawElement(int nGlyphIndex)
{
+ assert(GlobalWinGlyphCache::get());
assert(IsGlyphCached(nGlyphIndex));
return maWinTextureCache[nGlyphIndex];
}