summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/Library_vclplug_gen.mk1
-rw-r--r--vcl/Library_vclplug_win.mk3
-rw-r--r--vcl/inc/skia/gdiimpl.hxx3
-rw-r--r--vcl/inc/skia/packedsurfaceatlas.hxx83
-rw-r--r--vcl/inc/skia/win/gdiimpl.hxx21
-rw-r--r--vcl/inc/skia/win/winlayout.hxx52
-rw-r--r--vcl/inc/skia/x11/cairotextrender.hxx27
-rw-r--r--vcl/inc/win/salgdi.h3
-rw-r--r--vcl/inc/win/winlayout.hxx5
-rw-r--r--vcl/skia/gdiimpl.cxx34
-rw-r--r--vcl/skia/packedsurfaceatlas.cxx175
-rw-r--r--vcl/skia/win/gdiimpl.cxx46
-rw-r--r--vcl/skia/win/winlayout.cxx65
-rw-r--r--vcl/skia/x11/cairotextrender.cxx92
-rw-r--r--vcl/skia/x11/gdiimpl.cxx1
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx5
-rw-r--r--vcl/win/gdi/salfont.cxx2
-rw-r--r--vcl/win/gdi/winlayout.cxx12
19 files changed, 6 insertions, 625 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index cb59e378fb89..9780ca3575a1 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -593,7 +593,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/opengl/OpenGLHelper \
vcl/skia/SkiaHelper \
$(if $(filter SKIA,$(BUILD_TYPE)), \
- vcl/skia/packedsurfaceatlas \
vcl/skia/salbmp \
vcl/skia/zone \
vcl/skia/gdiimpl \
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 34ca4df4ba50..36652b70159c 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -112,7 +112,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
vcl/opengl/x11/gdiimpl \
vcl/opengl/x11/salvd \
$(if $(filter SKIA,$(BUILD_TYPE)), \
- vcl/skia/x11/cairotextrender \
vcl/skia/x11/gdiimpl \
vcl/skia/x11/salvd \
vcl/skia/x11/textrender \
diff --git a/vcl/Library_vclplug_win.mk b/vcl/Library_vclplug_win.mk
index f422d072a0e6..2e169ded83e7 100644
--- a/vcl/Library_vclplug_win.mk
+++ b/vcl/Library_vclplug_win.mk
@@ -84,8 +84,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_win,\
vcl/win/window/salmenu \
vcl/win/window/salobj \
$(if $(filter SKIA,$(BUILD_TYPE)), \
- vcl/skia/win/gdiimpl \
- vcl/skia/win/winlayout) \
+ vcl/skia/win/gdiimpl ) \
))
$(eval $(call gb_Library_use_system_win32_libs,vclplug_win,\
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 904053200d0a..68652cacc790 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -202,8 +202,6 @@ public:
// Default blend mode for SkPaint is SkBlendMode::kSrcOver
void drawImage(const SalTwoRect& rPosAry, const sk_sp<SkImage>& aImage,
SkBlendMode eBlendMode = SkBlendMode::kSrcOver);
- void drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& aBitmap,
- SkBlendMode eBlendMode = SkBlendMode::kSrcOver);
enum class GlyphOrientation
{
@@ -300,7 +298,6 @@ protected:
std::unique_ptr<SkCanvas> mXorCanvas;
SkRegion mXorRegion; // the area that needs updating for the xor operation
std::unique_ptr<SkiaFlushIdle> mFlush;
- int mPendingPixelsToFlush;
};
#endif
diff --git a/vcl/inc/skia/packedsurfaceatlas.hxx b/vcl/inc/skia/packedsurfaceatlas.hxx
deleted file mode 100644
index a66a24e53876..000000000000
--- a/vcl/inc/skia/packedsurfaceatlas.hxx
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- 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_PACKEDSURFACEATLAS_HXX
-#define INCLUDED_VCL_INC_SKIA_PACKEDSURFACEATLAS_HXX
-
-#include <memory>
-
-#include <SkSurface.h>
-
-#include <vcl/dllapi.h>
-#include <tools/gen.hxx>
-
-/**
- * SkSurface that is actually packed in a larger SkSurface atlas.
- *
- * In Skia's case we draw into SkSurface (as that's what's GPU-backed),
- * but then for using the result we need to get an associated SkImage.
- * The use of SkSurface::makeImageSnapshot() complicates things in two ways:
- * - it does data copy if we want a sub-rectangle, so we need to pass a reference
- * and the geometry wanted
- * - it does a snapshot of the state, meaning any further drawing into the SkSurface
- * would detach by creating a copy, so we need to pass around the SkSurface
- * reference and then create only a temporary SkImage for the whole SkSurface
- * (which should be almost a no-op)
- */
-class VCL_DLLPUBLIC SkiaPackedSurface
-{
-public:
- sk_sp<SkSurface> mSurface;
- tools::Rectangle mRect; // the area in the surface that is this "surface"
- SkiaPackedSurface(const sk_sp<SkSurface>& surface, const tools::Rectangle& rect)
- : mSurface(surface)
- , mRect(rect)
- {
- }
- SkiaPackedSurface() = default;
-};
-
-/**
- * Pack Skia "surfaces" into one surface atlas.
- *
- * This is based on algorithm described in [1] and is an
- * adaptation of "texture atlas generator" from [2].
- *
- * [1]: http://www.blackpawn.com/texts/lightmaps/
- * [2]: https://github.com/lukaszdk/texture-atlas-generator
- *
- */
-class VCL_DLLPUBLIC SkiaPackedSurfaceAtlasManager final
-{
- struct PackedSurface;
- std::vector<std::unique_ptr<PackedSurface>> maPackedSurfaces;
-
- int const mnSurfaceWidth;
- int const mnSurfaceHeight;
-
- void CreateNewSurface();
-
- SkiaPackedSurfaceAtlasManager(const SkiaPackedSurfaceAtlasManager&) = delete;
- SkiaPackedSurfaceAtlasManager& operator=(const SkiaPackedSurfaceAtlasManager&) = delete;
-
-public:
- /**
- * nSurfaceWidth and nSurfaceHeight are the dimensions of the common surface(s)
- */
- SkiaPackedSurfaceAtlasManager(int nSurfaceWidth, int nSurfaceHeight);
- ~SkiaPackedSurfaceAtlasManager();
-
- SkiaPackedSurface Reserve(int nWidth, int nHeight);
- std::vector<sk_sp<SkSurface>> ReduceSurfaceNumber(int nMaxNumberOfSurfaces);
-};
-
-#endif // INCLUDED_VCL_INC_SKIA_PACKEDSURFACEATLAS_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/skia/win/gdiimpl.hxx b/vcl/inc/skia/win/gdiimpl.hxx
index c16981abcb23..cdb6977e5bd2 100644
--- a/vcl/inc/skia/win/gdiimpl.hxx
+++ b/vcl/inc/skia/win/gdiimpl.hxx
@@ -14,7 +14,6 @@
#include <vcl/dllapi.h>
#include <skia/gdiimpl.hxx>
-#include <skia/packedsurfaceatlas.hxx>
#include <win/salgdi.h>
#include <win/wingdiimpl.hxx>
#include <o3tl/lru_map.hxx>
@@ -34,14 +33,11 @@ public:
virtual std::unique_ptr<Texture> getAsMaskTexture() const override;
- virtual bool wantsTextColorWhite() const override { return true; }
-
sk_sp<SkImage> getAsImage() const;
sk_sp<SkImage> getAsMaskImage() const;
sk_sp<SkImage> getAsImageDiff(const SkiaCompatibleDC& white) const;
struct Texture;
- struct PackedTexture;
};
struct SkiaCompatibleDC::Texture : public CompatibleDC::Texture
@@ -52,14 +48,6 @@ struct SkiaCompatibleDC::Texture : public CompatibleDC::Texture
virtual int GetHeight() const { return image->height(); }
};
-struct SkiaCompatibleDC::PackedTexture : public CompatibleDC::Texture
-{
- SkiaPackedSurface packedSurface;
- virtual bool isValid() const { return packedSurface.mSurface.get(); }
- virtual int GetWidth() const { return packedSurface.mRect.GetWidth(); }
- virtual int GetHeight() const { return packedSurface.mRect.GetHeight(); }
-};
-
class WinSkiaSalGraphicsImpl : public SkiaSalGraphicsImpl, public WinSalGraphicsImplBase
{
private:
@@ -78,15 +66,6 @@ public:
int nY, ControlCacheKey& aControlCacheKey) override;
virtual bool DrawTextLayout(const GenericSalLayout& layout) override;
- // TODO This method of text drawing can probably be removed once DrawTextLayout()
- // is fully usable.
- virtual bool UseTextDraw() const override { return true; }
- virtual void PreDrawText() override;
- virtual void PostDrawText() override;
- virtual void DrawTextMask(CompatibleDC::Texture* rTexture, Color nMaskColor,
- const SalTwoRect& rPosAry) override;
- virtual void DeferredTextDraw(const CompatibleDC::Texture* pTexture, Color nMaskColor,
- const SalTwoRect& rPosAry) override;
virtual void ClearDevFontCache() override;
static void prepareSkia();
diff --git a/vcl/inc/skia/win/winlayout.hxx b/vcl/inc/skia/win/winlayout.hxx
deleted file mode 100644
index 649fe993b05a..000000000000
--- a/vcl/inc/skia/win/winlayout.hxx
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- 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>
-
-#include <vector>
-
-#include <skia/packedsurfaceatlas.hxx>
-
-struct SkiaGlobalWinGlyphCache : public GlobalWinGlyphCache
-{
- SkiaGlobalWinGlyphCache()
- : mPackedSurfaceAtlas(2048, 2048)
- {
- }
- SkiaPackedSurfaceAtlasManager mPackedSurfaceAtlas;
- virtual bool AllocateTexture(WinGlyphDrawElement& rElement, CompatibleDC* dc) override;
- virtual void Prune() override;
-};
-
-class SkiaWinGlyphCache : public WinGlyphCache
-{
-public:
- void RemoveSurfaces(const std::vector<sk_sp<SkSurface>>& surfaces);
-
-private:
- // This class just "adds" RemoveSurfaces() to the base class, it's never instantiated.
- SkiaWinGlyphCache() = delete;
-};
-
-#endif // INCLUDED_VCL_INC_SKIA_WIN_WINLAYOUT_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/skia/x11/cairotextrender.hxx b/vcl/inc/skia/x11/cairotextrender.hxx
deleted file mode 100644
index 947657a499cd..000000000000
--- a/vcl/inc/skia/x11/cairotextrender.hxx
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- 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_SKIA_X11_CAIROTEXTRENDER_HXX
-#define INCLUDED_VCL_SKIA_X11_CAIROTEXTRENDER_HXX
-
-#include <unx/x11/x11cairotextrender.hxx>
-
-class SkiaX11CairoTextRender final : public X11CairoTextRender
-{
-public:
- explicit SkiaX11CairoTextRender(X11SalGraphics& rParent);
-
- virtual cairo_t* getCairoContext() override;
- virtual void getSurfaceOffset(double& nDX, double& nDY) override;
- virtual void releaseCairoContext(cairo_t* cr) override;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 06365cd1657b..c45611a6e36e 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -141,9 +141,6 @@ public:
/// Obtain the texture in format for WinSalGraphicsImplBase::DrawTextMask().
virtual std::unique_ptr<Texture> getAsMaskTexture() const { abort(); };
-
- /// Return true if text glyphs should be drawn as white instead of black.
- virtual bool wantsTextColorWhite() const { return false; }
};
struct CompatibleDC::Texture
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 11ab6d553ca6..35a855a3722e 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -67,6 +67,7 @@ struct GlobalWinGlyphCache
virtual ~GlobalWinGlyphCache() {}
virtual bool AllocateTexture(WinGlyphDrawElement& rElement, CompatibleDC* dc) = 0;
+ virtual void NotifyElementUsed(WinGlyphDrawElement& /*rElement*/) {}
virtual void Prune() {}
};
@@ -99,7 +100,9 @@ public:
{
assert(GlobalWinGlyphCache::get());
assert(IsGlyphCached(nGlyphIndex));
- return maWinTextureCache[nGlyphIndex];
+ WinGlyphDrawElement& element = maWinTextureCache[nGlyphIndex];
+ GlobalWinGlyphCache::get()->NotifyElementUsed(element);
+ return element;
}
bool IsGlyphCached(int nGlyphIndex) const
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index efecb95b7920..bd55aaf8a044 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -198,7 +198,6 @@ SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvid
, mFillColor(SALCOLOR_NONE)
, mXorMode(false)
, mFlush(new SkiaFlushIdle(this))
- , mPendingPixelsToFlush(0)
{
}
@@ -338,20 +337,6 @@ void SkiaSalGraphicsImpl::postDraw()
else if (!mFlush->IsActive())
mFlush->Start();
}
- // Skia (at least when using Vulkan) queues drawing commands and executes them only later.
- // But some operations may queue way too much data to draw, leading to Vulkan getting out of memory,
- // which at least on Linux leads to driver problems affecting even the whole X11 session.
- // One such problematic operation may be drawBitmap(SkBitmap), which is used by SkiaX11CairoTextRender
- // to draw text, which is internally done by creating the SkBitmap from cairo surface data. Apparently
- // the cairo surface's size matches the size of the destination (window), which may be large,
- // and each text drawing allocates a new surface (and thus SkBitmap). So we may end up queueing up
- // millions of pixels of bitmap data. So force a flush if such a possibly problematic operation
- // has queued up too much data.
- if (mPendingPixelsToFlush > 10 * 1024 * 1024)
- {
- mSurface->flush();
- mPendingPixelsToFlush = 0;
- }
SkiaZone::leave(); // matched in preDraw()
}
@@ -1301,25 +1286,6 @@ void SkiaSalGraphicsImpl::drawImage(const SalTwoRect& rPosAry, const sk_sp<SkIma
postDraw();
}
-void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& aBitmap,
- SkBlendMode eBlendMode)
-{
- SkRect aSourceRect
- = SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight);
- SkRect aDestinationRect = SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY,
- rPosAry.mnDestWidth, rPosAry.mnDestHeight);
-
- SkPaint aPaint;
- aPaint.setBlendMode(eBlendMode);
-
- preDraw();
- SAL_INFO("vcl.skia.trace", "drawbitmap(" << this << "): " << rPosAry << ":" << int(eBlendMode));
- getDrawCanvas()->drawBitmapRect(aBitmap, aSourceRect, aDestinationRect, &aPaint);
- addXorRegion(aDestinationRect);
- mPendingPixelsToFlush += aBitmap.width() * aBitmap.height();
- postDraw();
-}
-
bool SkiaSalGraphicsImpl::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
const basegfx::B2DPoint& rX,
const basegfx::B2DPoint& rY,
diff --git a/vcl/skia/packedsurfaceatlas.cxx b/vcl/skia/packedsurfaceatlas.cxx
deleted file mode 100644
index 7f358c30eb94..000000000000
--- a/vcl/skia/packedsurfaceatlas.cxx
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -*- 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/packedsurfaceatlas.hxx>
-
-#include <memory>
-#include <assert.h>
-
-#include <sal/config.h>
-#include <sal/log.hxx>
-
-#include <skia/utils.hxx>
-
-namespace
-{
-struct Node
-{
- tools::Rectangle const mRectangle;
- std::unique_ptr<Node> mLeftNode;
- std::unique_ptr<Node> mRightNode;
- bool mOccupied;
-
- explicit Node(int nWidth, int nHeight);
- explicit Node(tools::Rectangle const& aRectangle);
-
- bool isLeaf() const;
- Node* insert(int nWidth, int nHeight, int nPadding);
-};
-}
-
-Node::Node(int nWidth, int nHeight)
- : mRectangle(tools::Rectangle(Point(), Size(nWidth, nHeight)))
- , mLeftNode()
- , mRightNode()
- , mOccupied(false)
-{
-}
-
-Node::Node(tools::Rectangle const& aRectangle)
- : mRectangle(aRectangle)
- , mLeftNode()
- , mRightNode()
- , mOccupied(false)
-{
-}
-
-bool Node::isLeaf() const { return mLeftNode == nullptr && mRightNode == nullptr; }
-
-Node* Node::insert(int nWidth, int nHeight, int nPadding)
-{
- if (!isLeaf())
- {
- Node* pNewNode = mLeftNode->insert(nWidth, nHeight, nPadding);
-
- if (pNewNode != nullptr)
- return pNewNode;
-
- return mRightNode->insert(nWidth, nHeight, nPadding);
- }
- else
- {
- if (mOccupied)
- {
- return nullptr;
- }
-
- if (nWidth > mRectangle.GetWidth() || nHeight > mRectangle.GetHeight())
- { // does not fit
- return nullptr;
- }
-
- if (nWidth == mRectangle.GetWidth() && nHeight == mRectangle.GetHeight())
- { // perfect fit
- mOccupied = true;
- return this;
- }
-
- int dw = mRectangle.GetWidth() - nWidth;
- int dh = mRectangle.GetHeight() - nHeight;
-
- tools::Rectangle aLeftRect;
- tools::Rectangle aRightRect;
- if (dw > dh)
- {
- aLeftRect = tools::Rectangle(Point(mRectangle.Left(), mRectangle.Top()),
- Size(nWidth, mRectangle.GetHeight()));
- aRightRect = tools::Rectangle(
- Point(nPadding + mRectangle.Left() + nWidth, mRectangle.Top()),
- Size(mRectangle.GetWidth() - nWidth - nPadding, mRectangle.GetHeight()));
- }
- else
- {
- aLeftRect = tools::Rectangle(Point(mRectangle.Left(), mRectangle.Top()),
- Size(mRectangle.GetWidth(), nHeight));
- aRightRect = tools::Rectangle(
- Point(mRectangle.Left(), nPadding + mRectangle.Top() + nHeight),
- Size(mRectangle.GetWidth(), mRectangle.GetHeight() - nHeight - nPadding));
- }
-
- mLeftNode.reset(new Node(aLeftRect));
- mRightNode.reset(new Node(aRightRect));
-
- return mLeftNode->insert(nWidth, nHeight, nPadding);
- }
-}
-
-struct SkiaPackedSurfaceAtlasManager::PackedSurface
-{
- sk_sp<SkSurface> mpSurface;
- std::unique_ptr<Node> mpRootNode;
-
- PackedSurface(int nWidth, int nHeight)
- : mpSurface(SkiaHelper::createSkSurface(nWidth, nHeight))
- , mpRootNode(new Node(nWidth, nHeight))
- {
- assert(mpSurface);
- }
-};
-
-SkiaPackedSurfaceAtlasManager::SkiaPackedSurfaceAtlasManager(int nSurfaceWidth, int nSurfaceHeight)
- : mnSurfaceWidth(nSurfaceWidth)
- , mnSurfaceHeight(nSurfaceHeight)
-{
-}
-
-SkiaPackedSurfaceAtlasManager::~SkiaPackedSurfaceAtlasManager() {}
-
-void SkiaPackedSurfaceAtlasManager::CreateNewSurface()
-{
- std::unique_ptr<PackedSurface> pPackedSurface(
- new PackedSurface(mnSurfaceWidth, mnSurfaceHeight));
- maPackedSurfaces.push_back(std::move(pPackedSurface));
- SAL_INFO("vcl.skia.trace",
- "SkiaPackedSurfaceAtlas adding surface, count: " << maPackedSurfaces.size());
-}
-
-SkiaPackedSurface SkiaPackedSurfaceAtlasManager::Reserve(int nWidth, int nHeight)
-{
- for (std::unique_ptr<PackedSurface>& pPackedSurface : maPackedSurfaces)
- {
- Node* pNode = pPackedSurface->mpRootNode->insert(nWidth, nHeight, 1);
- if (pNode != nullptr)
- return SkiaPackedSurface(pPackedSurface->mpSurface, pNode->mRectangle);
- }
- CreateNewSurface();
- std::unique_ptr<PackedSurface>& pPackedSurface = maPackedSurfaces.back();
- Node* pNode = pPackedSurface->mpRootNode->insert(nWidth, nHeight, 1);
- if (pNode != nullptr)
- return SkiaPackedSurface(pPackedSurface->mpSurface, pNode->mRectangle);
- return SkiaPackedSurface();
-}
-
-std::vector<sk_sp<SkSurface>>
-SkiaPackedSurfaceAtlasManager::ReduceSurfaceNumber(int nMaxNumberOfSurfaces)
-{
- std::vector<sk_sp<SkSurface>> aSurfaces;
- while (int(maPackedSurfaces.size()) > nMaxNumberOfSurfaces)
- {
- // Remove oldest created surface
- aSurfaces.push_back(maPackedSurfaces[0]->mpSurface);
- maPackedSurfaces.erase(maPackedSurfaces.begin());
- SAL_INFO("vcl.skia.trace",
- "PackedSurfaceAtlas removing surface, count: " << maPackedSurfaces.size());
- }
- return aSurfaces;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index f65eb7cc69eb..6129c8e266da 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -17,7 +17,6 @@
#include <comphelper/windowserrorstring.hxx>
#include <SkCanvas.h>
-#include <SkColorFilter.h>
#include <SkPaint.h>
#include <SkPixelRef.h>
#include <SkTypeface_win.h>
@@ -66,7 +65,6 @@ void WinSkiaSalGraphicsImpl::freeResources() {}
void WinSkiaSalGraphicsImpl::performFlush()
{
SkiaZone zone;
- mPendingPixelsToFlush = 0;
if (mWindowContext)
mWindowContext->swapBuffers();
}
@@ -237,50 +235,6 @@ void WinSkiaSalGraphicsImpl::ClearDevFontCache()
fontEdgingDone = false;
}
-void WinSkiaSalGraphicsImpl::PreDrawText() { preDraw(); }
-
-void WinSkiaSalGraphicsImpl::PostDrawText() { postDraw(); }
-
-static SkColor toSkColor(Color color)
-{
- return SkColorSetARGB(255 - color.GetTransparency(), color.GetRed(), color.GetGreen(),
- color.GetBlue());
-}
-
-void WinSkiaSalGraphicsImpl::DeferredTextDraw(const CompatibleDC::Texture* pTexture,
- Color aMaskColor, const SalTwoRect& rPosAry)
-{
- assert(dynamic_cast<const SkiaCompatibleDC::PackedTexture*>(pTexture));
- const SkiaCompatibleDC::PackedTexture* texture
- = static_cast<const SkiaCompatibleDC::PackedTexture*>(pTexture);
- preDraw();
- SkPaint paint;
- // The glyph is painted as white, modulate it to be of the appropriate color.
- // SkiaCompatibleDC::wantsTextColorWhite() ensures the glyph is white.
- // TODO maybe other black/white in WinFontInstance::CacheGlyphToAtlas() should be swapped.
- paint.setColorFilter(SkColorFilters::Blend(toSkColor(aMaskColor), SkBlendMode::kModulate));
- // We use SkiaPackedSurface, so use also the appropriate rectangle in the source SkSurface.
- const tools::Rectangle& rect = texture->packedSurface.mRect;
- // The source in SalTwoRect is actually just the size.
- assert(rPosAry.mnSrcX == 0 && rPosAry.mnSrcY == 0);
- assert(rPosAry.mnSrcWidth == rect.GetWidth());
- assert(rPosAry.mnSrcHeight == rect.GetHeight());
- mSurface->getCanvas()->drawImageRect(
- texture->packedSurface.mSurface->makeImageSnapshot(),
- SkRect::MakeXYWH(rect.getX(), rect.getY(), rect.GetWidth(), rect.GetHeight()),
- SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth,
- rPosAry.mnDestHeight),
- &paint);
- postDraw();
-}
-
-void WinSkiaSalGraphicsImpl::DrawTextMask(CompatibleDC::Texture* pTexture, Color nMaskColor,
- const SalTwoRect& rPosAry)
-{
- assert(dynamic_cast<SkiaCompatibleDC::Texture*>(pTexture));
- drawMask(rPosAry, static_cast<const SkiaCompatibleDC::Texture*>(pTexture)->image, nMaskColor);
-}
-
SkiaCompatibleDC::SkiaCompatibleDC(SalGraphics& rGraphics, int x, int y, int width, int height)
: CompatibleDC(rGraphics, x, y, width, height, false)
{
diff --git a/vcl/skia/win/winlayout.cxx b/vcl/skia/win/winlayout.cxx
deleted file mode 100644
index da8a9f6cf2be..000000000000
--- a/vcl/skia/win/winlayout.cxx
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- 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/winlayout.hxx>
-
-#include <skia/win/gdiimpl.hxx>
-
-#include <SkCanvas.h>
-#include <SkPaint.h>
-
-bool SkiaGlobalWinGlyphCache::AllocateTexture(WinGlyphDrawElement& rElement, CompatibleDC* dc)
-{
- assert(rElement.maTexture.get() == nullptr);
- assert(dynamic_cast<SkiaCompatibleDC*>(dc));
- SkiaCompatibleDC* sdc = static_cast<SkiaCompatibleDC*>(dc);
- SkiaCompatibleDC::PackedTexture* texture = new SkiaCompatibleDC::PackedTexture;
- rElement.maTexture.reset(texture);
- texture->packedSurface
- = mPackedSurfaceAtlas.Reserve(sdc->getBitmapWidth(), sdc->getBitmapHeight());
- if (!texture->packedSurface.mSurface)
- return false;
- // Draw the dc's content to the reserved place in the atlas.
- SkCanvas* canvas = texture->packedSurface.mSurface->getCanvas();
- const tools::Rectangle& rect = texture->packedSurface.mRect;
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc); // copy as is
- canvas->drawImageRect(
- sdc->getAsImage(),
- SkRect::MakeXYWH(rect.getX(), rect.getY(), rect.GetWidth(), rect.GetHeight()), &paint);
- return true;
-}
-
-void SkiaGlobalWinGlyphCache::Prune()
-{
- std::vector<sk_sp<SkSurface>> aSurfaces = mPackedSurfaceAtlas.ReduceSurfaceNumber(8);
- if (!aSurfaces.empty())
- {
- for (auto& pWinGlyphCache : maWinGlyphCaches)
- static_cast<SkiaWinGlyphCache*>(pWinGlyphCache)->RemoveSurfaces(aSurfaces);
- }
-}
-
-void SkiaWinGlyphCache::RemoveSurfaces(const std::vector<sk_sp<SkSurface>>& surfaces)
-{
- auto it = maWinTextureCache.begin();
- while (it != maWinTextureCache.end())
- {
- assert(dynamic_cast<SkiaCompatibleDC::PackedTexture*>(it->second.maTexture.get()));
- sk_sp<SkSurface> surface
- = static_cast<SkiaCompatibleDC::PackedTexture*>(it->second.maTexture.get())
- ->packedSurface.mSurface;
- if (std::find(surfaces.begin(), surfaces.end(), surface) != surfaces.end())
- it = maWinTextureCache.erase(it);
- else
- ++it;
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/skia/x11/cairotextrender.cxx b/vcl/skia/x11/cairotextrender.cxx
deleted file mode 100644
index eb05134e3a74..000000000000
--- a/vcl/skia/x11/cairotextrender.cxx
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- 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/x11/cairotextrender.hxx>
-
-#include <salbmp.hxx>
-#include <skia/gdiimpl.hxx>
-#include <osl/endian.h>
-
-#include <cairo.h>
-
-SkiaX11CairoTextRender::SkiaX11CairoTextRender(X11SalGraphics& rParent)
- : X11CairoTextRender(rParent)
-{
-}
-
-cairo_t* SkiaX11CairoTextRender::getCairoContext()
-{
- cairo_surface_t* surface = nullptr;
- SkiaSalGraphicsImpl* pImpl = dynamic_cast<SkiaSalGraphicsImpl*>(mrParent.GetImpl());
- if (pImpl)
- {
- tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect();
- if (aClipRect.IsEmpty())
- {
- aClipRect.setWidth(GetWidth());
- aClipRect.setHeight(GetHeight());
- }
- surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, aClipRect.GetWidth(),
- aClipRect.GetHeight());
- }
- if (!surface)
- return nullptr;
- cairo_t* cr = cairo_create(surface);
- cairo_surface_destroy(surface);
- return cr;
-}
-
-void SkiaX11CairoTextRender::getSurfaceOffset(double& nDX, double& nDY)
-{
- SkiaSalGraphicsImpl* pImpl = dynamic_cast<SkiaSalGraphicsImpl*>(mrParent.GetImpl());
- if (pImpl)
- {
- tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect();
- nDX = -aClipRect.Left();
- nDY = -aClipRect.Top();
- }
-}
-
-void SkiaX11CairoTextRender::releaseCairoContext(cairo_t* cr)
-{
- SkiaSalGraphicsImpl* pImpl = dynamic_cast<SkiaSalGraphicsImpl*>(mrParent.GetImpl());
- if (!pImpl)
- {
- cairo_destroy(cr);
- return;
- }
-
- cairo_surface_t* pSurface = cairo_get_target(cr);
- int nWidth = cairo_image_surface_get_width(pSurface);
- int nHeight = cairo_image_surface_get_height(pSurface);
- cairo_surface_flush(pSurface);
- unsigned char* pSrc = cairo_image_surface_get_data(pSurface);
-
- tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect();
-
- SalTwoRect aRect(0, 0, nWidth, nHeight, aClipRect.Left(), aClipRect.Top(), nWidth, nHeight);
-
- SkImageInfo info;
-#ifdef OSL_LITENDIAN
- info = SkImageInfo::Make(nWidth, nHeight, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
-#else
- info = SkImageInfo::Make(nWidth, nHeight, kARGB_8888_SkColorType, kPremul_SkAlphaType);
-#endif
- SkBitmap bitmap;
- if (!bitmap.installPixels(info, pSrc, nWidth * 4))
- abort();
- bitmap.setImmutable();
-
- pImpl->drawBitmap(aRect, bitmap);
-
- bitmap.reset();
- cairo_destroy(cr);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 0ed4b6a0ccbd..4754bfc64f95 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -128,7 +128,6 @@ void X11SkiaSalGraphicsImpl::freeResources() {}
void X11SkiaSalGraphicsImpl::performFlush()
{
SkiaZone zone;
- mPendingPixelsToFlush = 0;
// TODO XPutImage() is somewhat inefficient, XShmPutImage() should be preferred.
mWindowContext->swapBuffers();
}
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index f712e366ce18..eeb67195dfb7 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -58,7 +58,6 @@
#include <vcl/skia/SkiaHelper.hxx>
#if HAVE_FEATURE_SKIA
#include <skia/x11/gdiimpl.hxx>
-#include <skia/x11/cairotextrender.hxx>
#include <skia/x11/textrender.hxx>
#endif
@@ -87,11 +86,7 @@ X11SalGraphics::X11SalGraphics():
if (m_bSkia)
{
mxImpl.reset(new X11SkiaSalGraphicsImpl(*this));
-#if 1
mxTextRenderImpl.reset(new SkiaTextRender);
-#else // old method, probably can be removed once native Skia render works well
- mxTextRenderImpl.reset(new SkiaX11CairoTextRender(*this));
-#endif
}
else
#endif
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index cd7ca435e807..ce1a8bd610a0 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -63,8 +63,6 @@
#include <impfontmetricdata.hxx>
#include <impglyphitem.hxx>
-#include <vcl/skia/SkiaHelper.hxx>
-
using namespace vcl;
static const int MAXFONTHEIGHT = 2048;
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 636cac595bf1..884b1be6e670 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -36,10 +36,6 @@
#include <win/saldata.hxx>
#include <win/wingdiimpl.hxx>
#include <outdev.h>
-#include <vcl/skia/SkiaHelper.hxx>
-#if HAVE_FEATURE_SKIA
-#include <skia/win/winlayout.hxx>
-#endif
#include <win/DWriteTextRenderer.hxx>
#include <win/scoped_gdi.hxx>
@@ -63,11 +59,6 @@ GlobalWinGlyphCache * GlobalWinGlyphCache::get()
SalData *data = GetSalData();
if (!data->m_pGlobalWinGlyphCache)
{
-#if HAVE_FEATURE_SKIA
- if (SkiaHelper::isVCLSkiaEnabled())
- data->m_pGlobalWinGlyphCache.reset(new SkiaGlobalWinGlyphCache);
- else
-#endif
if (OpenGLHelper::isVCLOpenGLEnabled())
data->m_pGlobalWinGlyphCache.reset(new OpenGLGlobalWinGlyphCache);
}
@@ -170,8 +161,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex,
auto pRT = pTxt->GetRenderTarget();
ID2D1SolidColorBrush* pBrush = nullptr;
- D2D1::ColorF textColor = aDC->wantsTextColorWhite() ? D2D1::ColorF::White : D2D1::ColorF::Black;
- if (!SUCCEEDED(pRT->CreateSolidColorBrush(textColor, &pBrush)))
+ if (!SUCCEEDED(pRT->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black), &pBrush)))
return false;
D2D1_POINT_2F baseline = {