diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-10-15 16:17:26 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:08 +0100 |
commit | b6cbf5dbd067c63f94872e31f2332e95edc201dd (patch) | |
tree | c169fd52f259038dca208c2bcc6904f38163fb1b /vcl/inc/opengl | |
parent | 8fa83a3265e25b164cb11d598f1fbb49a7b8fbf1 (diff) |
refactor Windows OpenGLGlyphCache stuff to be reusable for Skia
Basically just remove 'OpenGL' from names of most of the classes,
turn them into base classes that have OpenGL subclasses that
actually implement the functionality.
Change-Id: Idf1f347cebc2a417bda37d6955201c775ecb0890
Diffstat (limited to 'vcl/inc/opengl')
-rw-r--r-- | vcl/inc/opengl/RenderList.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/opengl/gdiimpl.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/opengl/win/gdiimpl.hxx | 37 | ||||
-rw-r--r-- | vcl/inc/opengl/win/winlayout.hxx | 46 | ||||
-rw-r--r-- | vcl/inc/opengl/x11/gdiimpl.hxx | 2 |
5 files changed, 80 insertions, 8 deletions
diff --git a/vcl/inc/opengl/RenderList.hxx b/vcl/inc/opengl/RenderList.hxx index e4df834755d6..06dd03b4d7d1 100644 --- a/vcl/inc/opengl/RenderList.hxx +++ b/vcl/inc/opengl/RenderList.hxx @@ -150,7 +150,7 @@ public: return maRenderEntries; } - void addDrawTextureWithMaskColor(OpenGLTexture const & rTexture, Color nColor, const SalTwoRect& r2Rect); + VCL_DLLPUBLIC void addDrawTextureWithMaskColor(OpenGLTexture const & rTexture, Color nColor, const SalTwoRect& r2Rect); void addDrawPixel(long nX, long nY, Color nColor); diff --git a/vcl/inc/opengl/gdiimpl.hxx b/vcl/inc/opengl/gdiimpl.hxx index e90e55458d12..b0b1de88b185 100644 --- a/vcl/inc/opengl/gdiimpl.hxx +++ b/vcl/inc/opengl/gdiimpl.hxx @@ -141,7 +141,6 @@ public: void DrawLinearGradient( const Gradient& rGradient, const tools::Rectangle& rRect ); void DrawAxialGradient( const Gradient& rGradient, const tools::Rectangle& rRect ); void DrawRadialGradient( const Gradient& rGradient, const tools::Rectangle& rRect ); - void DeferredTextDraw(OpenGLTexture const & rTexture, const Color nMaskColor, const SalTwoRect& rPosAry); void FlushDeferredDrawing(); void FlushLinesOrTriangles(DrawShaderType eType, RenderParameters const & rParameters); diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx index 3af0ccbcd344..f7d3865ceec7 100644 --- a/vcl/inc/opengl/win/gdiimpl.hxx +++ b/vcl/inc/opengl/win/gdiimpl.hxx @@ -16,11 +16,34 @@ #include <opengl/gdiimpl.hxx> #include <svdata.hxx> #include <win/salgdi.h> +#include <win/wingdiimpl.hxx> #include <o3tl/lru_map.hxx> #include <vcl/opengl/OpenGLContext.hxx> #include <ControlCacheKey.hxx> -class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl +class OpenGLCompatibleDC : public CompatibleDC +{ +public: + OpenGLCompatibleDC(SalGraphics &rGraphics, int x, int y, int width, int height); + + virtual std::unique_ptr<Texture> getTexture() override; + // overload, caller must delete + OpenGLTexture* getOpenGLTexture(); + + virtual bool copyToTexture(Texture& aTexture) override; + + struct Texture; +}; + +struct OpenGLCompatibleDC::Texture : public CompatibleDC::Texture +{ + OpenGLTexture texture; + virtual bool isValid() const { return !!texture; } + virtual int GetWidth() const { return texture.GetWidth(); } + virtual int GetHeight() const { return texture.GetHeight(); } +}; + +class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl, public WinSalGraphicsImplBase { friend class WinLayout; private: @@ -42,11 +65,17 @@ public: virtual void Init() override; virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) 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; + using OpenGLSalGraphicsImpl::DrawMask; + virtual void DeferredTextDraw(const CompatibleDC::Texture* pTexture, Color nMaskColor, const SalTwoRect& rPosAry) override; - bool TryRenderCachedNativeControl(ControlCacheKey const & rControlCacheKey, int nX, int nY); + virtual bool TryRenderCachedNativeControl(ControlCacheKey const & rControlCacheKey, int nX, int nY) override; - bool RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack, - int nX, int nY , ControlCacheKey& aControlCacheKey); + virtual bool RenderAndCacheNativeControl(CompatibleDC& rWhite, CompatibleDC& rBlack, + int nX, int nY , ControlCacheKey& aControlCacheKey) override; }; diff --git a/vcl/inc/opengl/win/winlayout.hxx b/vcl/inc/opengl/win/winlayout.hxx new file mode 100644 index 000000000000..c6ce77bdad4e --- /dev/null +++ b/vcl/inc/opengl/win/winlayout.hxx @@ -0,0 +1,46 @@ +/* -*- 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_OPENGL_WIN_WINLAYOUT_HXX +#define INCLUDED_VCL_INC_OPENGL_WIN_WINLAYOUT_HXX + +#include <win/winlayout.hxx> +#include <opengl/PackedTextureAtlas.hxx> + +struct OpenGLGlobalWinGlyphCache : public GlobalWinGlyphCache +{ + OpenGLGlobalWinGlyphCache() + : maPackedTextureAtlas(2048, 2048) + { + } + + PackedTextureAtlasManager maPackedTextureAtlas; + + virtual bool AllocateTexture(WinGlyphDrawElement& rElement, int nWidth, int nHeight) override; +}; + +class OpenGLWinGlyphCache : public WinGlyphCache +{ +public: + void RemoveTextures(std::vector<GLuint>& rTextureIDs); +}; + +#endif // INCLUDED_VCL_INC_OPENGL_WIN_WINLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx index d0c0c3caf352..d86af9223c54 100644 --- a/vcl/inc/opengl/x11/gdiimpl.hxx +++ b/vcl/inc/opengl/x11/gdiimpl.hxx @@ -32,8 +32,6 @@ protected: virtual rtl::Reference<OpenGLContext> CreateWinContext() override; public: - // implementation of X11GraphicsImpl - virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) override; virtual void Init() override; |