diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-12-04 12:14:47 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-12-07 20:46:49 +0100 |
commit | db89f53c31af997b9bf422b0e784afba8d62a42e (patch) | |
tree | da11fedb71f01b6d21a32f95c0a9ccecb43fc265 /vcl/inc/opengl | |
parent | 6265cfca9d775198e81166b914f5dcaea58802db (diff) |
remove OpenGL VCL backend code
It is by now practically unmaintained, even bugreports in bugzilla
have been already closed for it. AFAICT this used to be really
used only on Windows, where it's no longer the default.
There's still some OpenGL code left, because there are still two
other places that use OpenGL. One is OpenGL slideshows, which
reuse some of the base OpenGL code (and I've checked they
still work even after this removal). Second one is OpenGL canvas,
which it seems has never been finished or enabled (or so it
most probably should be dumped too).
Change-Id: I7ea5aef77ec252eb8e712d167db591209be84a13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107290
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc/opengl')
-rw-r--r-- | vcl/inc/opengl/BufferObject.hxx | 80 | ||||
-rw-r--r-- | vcl/inc/opengl/FixedTextureAtlas.hxx | 47 | ||||
-rw-r--r-- | vcl/inc/opengl/LineRenderUtils.hxx | 55 | ||||
-rw-r--r-- | vcl/inc/opengl/PackedTextureAtlas.hxx | 57 | ||||
-rw-r--r-- | vcl/inc/opengl/RenderList.hxx | 173 | ||||
-rw-r--r-- | vcl/inc/opengl/RenderState.hxx | 188 | ||||
-rw-r--r-- | vcl/inc/opengl/TextureState.hxx | 73 | ||||
-rw-r--r-- | vcl/inc/opengl/VertexUtils.hxx | 118 | ||||
-rw-r--r-- | vcl/inc/opengl/framebuffer.hxx | 48 | ||||
-rw-r--r-- | vcl/inc/opengl/gdiimpl.hxx | 396 | ||||
-rw-r--r-- | vcl/inc/opengl/program.hxx | 122 | ||||
-rw-r--r-- | vcl/inc/opengl/salbmp.hxx | 113 | ||||
-rw-r--r-- | vcl/inc/opengl/texture.hxx | 139 | ||||
-rw-r--r-- | vcl/inc/opengl/win/gdiimpl.hxx | 97 | ||||
-rw-r--r-- | vcl/inc/opengl/win/winlayout.hxx | 51 | ||||
-rw-r--r-- | vcl/inc/opengl/x11/cairotextrender.hxx | 27 | ||||
-rw-r--r-- | vcl/inc/opengl/x11/gdiimpl.hxx | 42 | ||||
-rw-r--r-- | vcl/inc/opengl/x11/salvd.hxx | 57 | ||||
-rw-r--r-- | vcl/inc/opengl/zone.hxx | 16 |
19 files changed, 0 insertions, 1899 deletions
diff --git a/vcl/inc/opengl/BufferObject.hxx b/vcl/inc/opengl/BufferObject.hxx deleted file mode 100644 index e31148b74c6e..000000000000 --- a/vcl/inc/opengl/BufferObject.hxx +++ /dev/null @@ -1,80 +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_OPENGL_BUFFEROBJECT_H -#define INCLUDED_VCL_INC_OPENGL_BUFFEROBJECT_H - -namespace vcl -{ -template <typename TYPE, GLenum BUFFER_TYPE> class BufferObject -{ -private: - GLuint mId; - -public: - BufferObject() - : mId(0) - { - glGenBuffers(1, &mId); - CHECK_GL_ERROR(); - } - - virtual ~BufferObject() - { - if (mId) - { - glDeleteBuffers(1, &mId); - CHECK_GL_ERROR(); - mId = 0; - } - } - - void bind() - { - if (mId) - { - glBindBuffer(BUFFER_TYPE, mId); - CHECK_GL_ERROR(); - } - } - - void unbind() - { - if (mId) - { - glBindBuffer(BUFFER_TYPE, 0); - CHECK_GL_ERROR(); - } - } - - void upload(const std::vector<TYPE>& rData) - { - if (mId) - { - bind(); - glBufferData(BUFFER_TYPE, sizeof(TYPE) * rData.size(), rData.data(), GL_STATIC_DRAW); - CHECK_GL_ERROR(); - } - } -}; - -template <typename TYPE> class VertexBufferObject final : public BufferObject<TYPE, GL_ARRAY_BUFFER> -{ -}; - -class IndexBufferObject final : public BufferObject<GLuint, GL_ELEMENT_ARRAY_BUFFER> -{ -}; - -} // end vcl - -#endif // INCLUDED_VCL_INC_OPENGL_BUFFEROBJECT_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/FixedTextureAtlas.hxx b/vcl/inc/opengl/FixedTextureAtlas.hxx deleted file mode 100644 index e576fcb54f0b..000000000000 --- a/vcl/inc/opengl/FixedTextureAtlas.hxx +++ /dev/null @@ -1,47 +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_OPENGL_FIXEDTEXTUREATLAS_HXX -#define INCLUDED_VCL_INC_OPENGL_FIXEDTEXTUREATLAS_HXX - -#include <memory> -#include <opengl/texture.hxx> - -struct FixedTexture; - -class FixedTextureAtlasManager final -{ - std::vector<std::unique_ptr<FixedTexture>> maFixedTextures; - - int mWidthFactor; - int mHeightFactor; - int mSubTextureSize; - - void CreateNewTexture(); - - FixedTextureAtlasManager( const FixedTextureAtlasManager& ) = delete; - FixedTextureAtlasManager& operator=( const FixedTextureAtlasManager& ) = delete; - -public: - FixedTextureAtlasManager(int nWidthFactor, int nHeightFactor, int nTextureSize); - ~FixedTextureAtlasManager(); - - OpenGLTexture InsertBuffer(int nWidth, int nHeight, int nFormat, int nType, sal_uInt8 const * pData); - OpenGLTexture Reserve(int nWidth, int nHeight); - - int GetSubtextureSize() const - { - return mSubTextureSize; - } -}; - -#endif // INCLUDED_VCL_INC_OPENGL_FIXEDTEXTUREATLAS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/LineRenderUtils.hxx b/vcl/inc/opengl/LineRenderUtils.hxx deleted file mode 100644 index 8d97fa3ee9dc..000000000000 --- a/vcl/inc/opengl/LineRenderUtils.hxx +++ /dev/null @@ -1,55 +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_OPENGL_LINERENDERUTILS_H -#define INCLUDED_VCL_INC_OPENGL_LINERENDERUTILS_H - -#include <opengl/RenderList.hxx> - -namespace vcl -{ -class LineBuilder -{ -private: - std::vector<Vertex>& mrVertices; - std::vector<GLuint>& mrIndices; - GLubyte mR, mG, mB, mA; - GLfloat mfLineWidth; - GLfloat mfLineWidthAndAA; - size_t mnInitialIndexSize; - bool mbIncomplete; - -public: - LineBuilder(std::vector<Vertex>& rVertices, std::vector<GLuint>& rIndices, - Color nColor, GLfloat fTransparency, - GLfloat fLineWidth, bool bUseAA); - - void appendLineSegment(const glm::vec2& rPoint1, const glm::vec2& rNormal1, GLfloat aExtrusion1, - const glm::vec2& rPoint2, const glm::vec2& rNormal2, GLfloat aExtrusion2); - - void appendLine(const glm::vec2& rPoint1, const glm::vec2& rPoint2); - - void appendAndConnectLinePoint(const glm::vec2& rPoint, const glm::vec2& aNormal, GLfloat aExtrusion); - - void appendMiterJoint(glm::vec2 const& point, const glm::vec2& prevLineVector, - glm::vec2 const& nextLineVector); - void appendBevelJoint(glm::vec2 const& point, const glm::vec2& prevLineVector, - const glm::vec2& nextLineVector); - void appendRoundJoint(glm::vec2 const& point, const glm::vec2& prevLineVector, - const glm::vec2& nextLineVector); - void appendRoundLineCapVertices(const glm::vec2& rPoint1, const glm::vec2& rPoint2); - void appendSquareLineCapVertices(const glm::vec2& rPoint1, const glm::vec2& rPoint2); -}; - -} // end vcl - -#endif // INCLUDED_VCL_INC_OPENGL_LINERENDERUTILS_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/PackedTextureAtlas.hxx b/vcl/inc/opengl/PackedTextureAtlas.hxx deleted file mode 100644 index 7a283aa4517b..000000000000 --- a/vcl/inc/opengl/PackedTextureAtlas.hxx +++ /dev/null @@ -1,57 +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_OPENGL_PACKEDTEXTUREATLAS_HXX -#define INCLUDED_VCL_INC_OPENGL_PACKEDTEXTUREATLAS_HXX - -#include <memory> -#include <opengl/texture.hxx> - -struct PackedTexture; - -/** - * Pack textures into one texture 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 PackedTextureAtlasManager final -{ - std::vector<std::unique_ptr<PackedTexture>> maPackedTextures; - - int mnTextureWidth; - int mnTextureHeight; - - void CreateNewTexture(); - - PackedTextureAtlasManager( const PackedTextureAtlasManager& ) = delete; - PackedTextureAtlasManager& operator=( const PackedTextureAtlasManager& ) = delete; - -public: - - /** - * nTextureWidth and nTextureHeight are the dimensions of the common texture(s) - * nTextureLimit is the maximum limit of that a texture atlas can have (0 or less - unlimited) - */ - PackedTextureAtlasManager(int nTextureWidth, int nTextureHeight); - ~PackedTextureAtlasManager(); - - OpenGLTexture InsertBuffer(int nWidth, int nHeight, int nFormat, int nType, sal_uInt8 const * pData); - OpenGLTexture Reserve(int nWidth, int nHeight); - std::vector<GLuint> ReduceTextureNumber(int nMaxNumberOfTextures); -}; - -#endif // INCLUDED_VCL_INC_OPENGL_PACKEDTEXTUREATLAS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/RenderList.hxx b/vcl/inc/opengl/RenderList.hxx deleted file mode 100644 index 236fa570aec1..000000000000 --- a/vcl/inc/opengl/RenderList.hxx +++ /dev/null @@ -1,173 +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_OPENGL_RENDERLIST_H -#define INCLUDED_VCL_INC_OPENGL_RENDERLIST_H - -#include <unordered_map> - -#include <glm/glm.hpp> - -#include <vcl/salgtype.hxx> -#include <basegfx/range/b2drange.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> - -#include <opengl/texture.hxx> - -#include <com/sun/star/drawing/LineCap.hpp> - -struct Vertex -{ - glm::vec2 position; - glm::vec4 color; - glm::vec4 lineData; -}; - -static_assert(sizeof(Vertex) == (2*4 + 4*4 + 4*4), "Vertex struct has wrong size/alignment"); - - -struct RenderParameters -{ - std::vector<Vertex> maVertices; - std::vector<GLuint> maIndices; -}; - -struct RenderTextureParameters -{ - std::vector<GLfloat> maVertices; - std::vector<GLfloat> maTextureCoords; - std::vector<GLubyte> maColors; - OpenGLTexture maTexture; -}; - -struct RenderEntry -{ - basegfx::B2DRange maOverlapTrackingRectangle; - - RenderParameters maTriangleParameters; - RenderParameters maLineParameters; - - std::unordered_map<GLuint, RenderTextureParameters> maTextureParametersMap; - - bool hasTriangles() const - { - return !maTriangleParameters.maVertices.empty(); - } - - bool hasLines() const - { - return !maLineParameters.maVertices.empty(); - } - - bool hasTextures() const - { - return !maTextureParametersMap.empty(); - } -}; - -class RenderList -{ -private: - std::vector<RenderEntry> maRenderEntries; - std::vector<basegfx::B2DRange> maRectangles; - - bool doesOverlap(const basegfx::B2DRange& rDrawRectangle) - { - if (!maRenderEntries.back().maOverlapTrackingRectangle.overlaps(rDrawRectangle)) - return false; - - for (const basegfx::B2DRange& rRectangle : maRectangles) - { - if (rRectangle.overlaps(rDrawRectangle)) - return true; - } - return false; - } - - void checkOverlapping(const basegfx::B2DRange& rDrawRectangle) - { - if (maRenderEntries.empty() || doesOverlap(rDrawRectangle)) - { - maRenderEntries.emplace_back(); - maRenderEntries.back().maOverlapTrackingRectangle = rDrawRectangle; - - maRectangles.clear(); - maRectangles.reserve(30); - maRectangles.push_back(rDrawRectangle); - } - else - { - maRenderEntries.back().maOverlapTrackingRectangle.expand(rDrawRectangle); - - if (maRectangles.size() < 30) - { - maRectangles.push_back(rDrawRectangle); - } - else - { - basegfx::B2DRange aTempRectangle(maRectangles[0]); - aTempRectangle.expand(rDrawRectangle); - double minArea = aTempRectangle.getWidth() * aTempRectangle.getHeight(); - size_t index = 0; - - double area; - for (size_t i = 1; i < maRectangles.size(); ++i) - { - aTempRectangle = maRectangles[i]; - aTempRectangle.expand(rDrawRectangle); - area = aTempRectangle.getWidth() * aTempRectangle.getHeight(); - if (area < minArea) - index = i; - } - maRectangles[index].expand(rDrawRectangle); - } - } - } - -public: - - RenderList() = default; - - bool empty() - { - return maRenderEntries.empty(); - } - - void clear() - { - maRenderEntries.clear(); - } - - std::vector<RenderEntry>& getEntries() - { - return maRenderEntries; - } - - VCL_DLLPUBLIC void addDrawTextureWithMaskColor(OpenGLTexture const & rTexture, Color nColor, const SalTwoRect& r2Rect); - - void addDrawPixel(tools::Long nX, tools::Long nY, Color nColor); - - void addDrawRectangle(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, double fTransparency, - Color nLineColor, Color nFillColor); - - void addDrawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2, Color nLineColor, bool bUseAA); - - void addDrawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency, - Color nLineColor, Color nFillColor, bool bUseAA); - - void addDrawPolyLine(const basegfx::B2DPolygon& rPolygon, double fTransparency, - double fLineWidth, basegfx::B2DLineJoin eLineJoin, - css::drawing::LineCap eLineCap, double fMiterMinimumAngle, - Color nLineColor, bool bUseAA); -}; - -#endif // INCLUDED_VCL_INC_OPENGL_RENDERLIST_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx deleted file mode 100644 index 3a89344e2e0e..000000000000 --- a/vcl/inc/opengl/RenderState.hxx +++ /dev/null @@ -1,188 +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_OPENGL_RENDER_STATE_H -#define INCLUDED_VCL_INC_OPENGL_RENDER_STATE_H - -#include <opengl/TextureState.hxx> - -template<GLenum ENUM_TYPE, typename TYPE> -class GenericCapabilityState -{ -protected: - bool mbTest; - - GenericCapabilityState() - : mbTest(false) - { - } - - static bool readState() - { - return glIsEnabled(ENUM_TYPE); - } - -public: - void sync() - { - mbTest = readState(); - } - - void enable() - { - if (!mbTest) - { - glEnable(ENUM_TYPE); - CHECK_GL_ERROR(); - mbTest = true; - } - else - { - VCL_GL_INFO(TYPE::className() << ": enable called but already enabled"); - } -#ifdef DBG_UTIL - checkState(); -#endif - } - - void disable() - { - if (mbTest) - { - glDisable(ENUM_TYPE); - CHECK_GL_ERROR(); - mbTest = false; - } - else - { - VCL_GL_INFO(TYPE::className() << ": disable called but already disabled"); - } -#ifdef DBG_UTIL - checkState(); -#endif - } - -#ifdef DBG_UTIL - void checkState() - { - bool bRealState = readState(); - if (mbTest != bRealState) - { - VCL_GL_INFO(TYPE::className() << " mismatch! " - << "Expected: " << (mbTest ? "enabled" : "disabled") - << " but is: " << (bRealState ? "enabled" : "disabled")); - } - } -#endif -}; - -class ScissorState : public GenericCapabilityState<GL_SCISSOR_TEST, ScissorState> -{ -private: - int mX; - int mY; - int mWidth; - int mHeight; - -public: - static std::string className() { return std::string("ScissorState"); } - - ScissorState() - : mX(0) - , mY(0) - , mWidth(0) - , mHeight(0) - {} - - void set(int x, int y, int width, int height) - { - if (x != mX || y != mY || width != mWidth || height != mHeight) - { - glScissor(x, y, width, height); - CHECK_GL_ERROR(); - - mX = x; - mY = y; - mWidth = width; - mHeight = height; - } - } -}; - -class StencilState : public GenericCapabilityState<GL_STENCIL_TEST, StencilState> -{ -public: - static std::string className() { return std::string("StencilState"); } -}; - -class BlendState : public GenericCapabilityState<GL_BLEND, BlendState> -{ - GLenum mnSourceMode; - GLenum mnDestinationMode; -public: - BlendState() - : mnSourceMode(GL_ZERO) - , mnDestinationMode(GL_ZERO) - {} - - static std::string className() { return std::string("BlendState"); } - - void func(GLenum nSource, GLenum nDestination) - { - if (mnSourceMode != nSource || mnDestinationMode != nDestination) - { - glBlendFunc(nSource, nDestination); - CHECK_GL_ERROR(); - mnSourceMode = nSource; - mnDestinationMode = nDestination; - } - } -}; - -class RenderState -{ - TextureState maTexture; - ScissorState maScissor; - StencilState maStencil; - BlendState maBlend; - - tools::Rectangle maCurrentViewport; - -public: - RenderState() - {} - - void viewport(tools::Rectangle aViewPort) - { - if (aViewPort != maCurrentViewport) - { - glViewport(aViewPort.Left(), aViewPort.Top(), aViewPort.GetWidth(), aViewPort.GetHeight()); - CHECK_GL_ERROR(); - maCurrentViewport = aViewPort; - } - } - - TextureState& texture() { return maTexture; } - ScissorState& scissor() { return maScissor; } - StencilState& stencil() { return maStencil; } - BlendState& blend() { return maBlend; } - - void sync() - { - VCL_GL_INFO("RenderState::sync"); - maScissor.sync(); - maStencil.sync(); - maBlend.sync(); - } -}; - -#endif // INCLUDED_VCL_INC_OPENGL_RENDER_STATE_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/TextureState.hxx b/vcl/inc/opengl/TextureState.hxx deleted file mode 100644 index e285cd7704fa..000000000000 --- a/vcl/inc/opengl/TextureState.hxx +++ /dev/null @@ -1,73 +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_OPENGL_TEXTURE_STATE_H -#define INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H - -#include <vcl/opengl/OpenGLHelper.hxx> - -class TextureState -{ -private: - GLuint mnCurrentTextureUnit; - std::vector<GLuint> maBoundTextures; - -public: - TextureState() - : mnCurrentTextureUnit(0) - , maBoundTextures(4, 0) - { - } - - static void generate(GLuint& nTexture) - { - glGenTextures(1, &nTexture); - CHECK_GL_ERROR(); - } - - void active(GLuint nTextureUnit) - { - if (mnCurrentTextureUnit != nTextureUnit) - { - glActiveTexture(GL_TEXTURE0 + nTextureUnit); - CHECK_GL_ERROR(); - mnCurrentTextureUnit = nTextureUnit; - } - } - - void bind(GLuint nTexture) - { - if (maBoundTextures[mnCurrentTextureUnit] != nTexture) - { - glBindTexture(GL_TEXTURE_2D, nTexture); - CHECK_GL_ERROR(); - maBoundTextures[mnCurrentTextureUnit] = nTexture; - } - } - - void unbindAndDelete(GLuint nTexture) - { - unbind(nTexture); - glDeleteTextures(1, &nTexture); - } - - void unbind(GLuint nTexture) - { - for (size_t i = 0; i < maBoundTextures.size(); i++) - { - if (nTexture == maBoundTextures[i]) - maBoundTextures[i] = 0; - } - } -}; - -#endif // INCLUDED_VCL_INC_OPENGL_TEXTURE_STATE_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/VertexUtils.hxx b/vcl/inc/opengl/VertexUtils.hxx deleted file mode 100644 index 9589d0e85775..000000000000 --- a/vcl/inc/opengl/VertexUtils.hxx +++ /dev/null @@ -1,118 +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_OPENGL_VERTEXUTILS_H -#define INCLUDED_VCL_INC_OPENGL_VERTEXUTILS_H - -#include <basegfx/numeric/ftools.hxx> -#include <epoxy/gl.h> -#include <glm/gtx/norm.hpp> -#include <tools/color.hxx> -#include <vector> - -namespace vcl::vertex -{ - -template<GLenum TYPE> -inline void addRectangle(std::vector<GLfloat>& rVertices, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); - -template<> -inline void addRectangle<GL_TRIANGLES>(std::vector<GLfloat>& rVertices, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) -{ - rVertices.insert(rVertices.end(), { - x1, y1, x2, y1, x1, y2, - x1, y2, x2, y1, x2, y2 - }); -} - -template<> -inline void addRectangle<GL_TRIANGLE_FAN>(std::vector<GLfloat>& rVertices, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) -{ - rVertices.insert(rVertices.end(), { - x1, y2, x1, y1, - x2, y1, x2, y2 - }); -} - -inline void createColor(Color nColor, GLfloat fTransparency, GLubyte& nR, GLubyte& nG, GLubyte& nB, GLubyte& nA) -{ - nR = nColor.GetRed(); - nG = nColor.GetGreen(); - nB = nColor.GetBlue(); - nA = (1.0f - fTransparency) * 255.0f; -} - -template<GLenum TYPE> -inline void addQuadColors(std::vector<GLubyte>& rColors, Color nColor, GLfloat fTransparency); - -template<> -inline void addQuadColors<GL_TRIANGLES>(std::vector<GLubyte>& rColors, Color nColor, GLfloat fTransparency) -{ - GLubyte nR, nG, nB, nA; - createColor(nColor, fTransparency, nR, nG, nB, nA); - - rColors.insert(rColors.end(), { - nR, nG, nB, nA, - nR, nG, nB, nA, - nR, nG, nB, nA, - nR, nG, nB, nA, - nR, nG, nB, nA, - nR, nG, nB, nA, - }); -} - -inline void addLineSegmentVertices(std::vector<GLfloat>& rVertices, std::vector<GLfloat>& rExtrusionVectors, - glm::vec2 prevPoint, glm::vec2 prevExtrusionVector, GLfloat prevLength, - glm::vec2 currPoint, glm::vec2 currExtrusionVector, GLfloat currLength) -{ - rVertices.insert(rVertices.end(), { - prevPoint.x, prevPoint.y, - prevPoint.x, prevPoint.y, - currPoint.x, currPoint.y, - currPoint.x, currPoint.y, - prevPoint.x, prevPoint.y, - currPoint.x, currPoint.y, - }); - - rExtrusionVectors.insert(rExtrusionVectors.end(), { - -prevExtrusionVector.x, -prevExtrusionVector.y, -prevLength, - prevExtrusionVector.x, prevExtrusionVector.y, prevLength, - -currExtrusionVector.x, -currExtrusionVector.y, -currLength, - -currExtrusionVector.x, -currExtrusionVector.y, -currLength, - prevExtrusionVector.x, prevExtrusionVector.y, prevLength, - currExtrusionVector.x, currExtrusionVector.y, currLength, - }); -} - -inline glm::vec2 normalize(const glm::vec2& vector) -{ - if (glm::length(vector) > 0.0) - return glm::normalize(vector); - return vector; -} - -inline glm::vec2 perpendicular(const glm::vec2& vector) -{ - return glm::vec2(-vector.y, vector.x); -} - -inline float lineVectorAngle(const glm::vec2& previous, const glm::vec2& next) -{ - float angle = std::atan2(previous.x * next.y - previous.y * next.x, - previous.x * next.x + previous.y * next.y); - - return F_PI - std::fabs(angle); -} - -} // end vcl::vertex - -#endif // INCLUDED_VCL_INC_OPENGL_VERTEXUTILS_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/framebuffer.hxx b/vcl/inc/opengl/framebuffer.hxx deleted file mode 100644 index 4445e6198458..000000000000 --- a/vcl/inc/opengl/framebuffer.hxx +++ /dev/null @@ -1,48 +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_OPENGL_FRAMEBUFFER_H -#define INCLUDED_VCL_INC_OPENGL_FRAMEBUFFER_H - -#include <vcl/dllapi.h> - -#include <opengl/texture.hxx> - -class OpenGLFramebuffer final -{ -private: - GLuint mnId; - int mnWidth; - int mnHeight; - GLuint mnAttachedTexture; - -public: - OpenGLFramebuffer(); - ~OpenGLFramebuffer(); - - int GetWidth() const { return mnWidth; }; - int GetHeight() const { return mnHeight; }; - - void Bind(GLenum eTarget = GL_FRAMEBUFFER); - - static void Unbind(GLenum eTarget = GL_FRAMEBUFFER); - - VCL_DLLPUBLIC bool IsFree() const; - bool IsAttached( GLuint nTexture ) const; - bool IsAttached( const OpenGLTexture& rTexture ) const; - void AttachTexture( const OpenGLTexture& rTexture ); - void DetachTexture(); - -public: - OpenGLFramebuffer* mpPrevFramebuffer; -}; - -#endif // INCLUDED_VCL_INC_OPENGL_FRAMEBUFFER_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/gdiimpl.hxx b/vcl/inc/opengl/gdiimpl.hxx deleted file mode 100644 index 8eaa454ef73e..000000000000 --- a/vcl/inc/opengl/gdiimpl.hxx +++ /dev/null @@ -1,396 +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_OPENGLGDIIMPL_HXX -#define INCLUDED_VCL_OPENGLGDIIMPL_HXX - -#include <vcl/dllapi.h> -#include <vcl/opengl/OpenGLContext.hxx> - -#include <regionband.hxx> -#include <salgeom.hxx> -#include <salgdiimpl.hxx> -#include <opengl/program.hxx> -#include <opengl/texture.hxx> -#include <opengl/RenderList.hxx> - -#include <memory> - -class SalFrame; -class SalVirtualDevice; -class OpenGLTests; - -namespace basegfx -{ -class B2DTrapezoid; -}; - -namespace tools -{ - class Polygon; - class PolyPolygon; -} - -struct TextureCombo -{ - std::unique_ptr<OpenGLTexture> mpTexture; - std::unique_ptr<OpenGLTexture> mpMask; -}; - -class OpenGLFlushIdle; - -class VCL_DLLPUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl -{ - friend class OpenGLTests; -protected: - - /// This context is solely for blitting maOffscreenTex - rtl::Reference<OpenGLContext> mpWindowContext; - - /// This context is whatever is most convenient to render - /// to maOffscreenTex with. - rtl::Reference<OpenGLContext> mpContext; - - SalGraphics& mrParent; - /// Pointer to the SalFrame or SalVirtualDevice - SalGeometryProvider* mpProvider; - OpenGLProgram* mpProgram; - - /// This idle handler is used to swap buffers after rendering. - std::unique_ptr<OpenGLFlushIdle> mpFlush; - - // clipping - vcl::Region maClipRegion; - bool mbUseScissor; - bool mbUseStencil; - - bool mbXORMode; - - bool mbAcquiringOpenGLContext; - - /** - * All rendering happens to this off-screen texture. For - * non-virtual devices, ie. windows - we will blit it and - * swapBuffers later. - */ - OpenGLTexture maOffscreenTex; - - Color mnLineColor; - Color mnFillColor; -#ifdef DBG_UTIL - bool mProgramIsSolidColor; -#endif - sal_uInt32 mnDrawCount; - sal_uInt32 mnDrawCountAtFlush; - Color mProgramSolidColor; - double mProgramSolidTransparency; - - std::unique_ptr<RenderList> mpRenderList; - - void ImplInitClipRegion(); - void ImplSetClipBit( const vcl::Region& rClip, GLuint nMask ); - void ImplDrawLineAA( double nX1, double nY1, double nX2, double nY2, bool edge ); - void CheckOffscreenTexture(); - - void ApplyProgramMatrices(float fPixelOffset = 0.0); - -public: - bool UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" ); - bool UseSolid( Color nColor, sal_uInt8 nTransparency ); - bool UseSolid( Color nColor, double fTransparency ); - bool UseSolid( Color nColor ); - void UseSolid(); - bool UseLine(Color nColor, double fTransparency, GLfloat fLineWidth, bool bUseAA); - void UseLine(GLfloat fLineWidth, bool bUseAA); - bool UseInvert50(); - bool UseInvert(SalInvert nFlags); - - void DrawConvexPolygon( sal_uInt32 nPoints, const Point* pPtAry, bool blockAA = false ); - void DrawConvexPolygon( const tools::Polygon& rPolygon, bool blockAA ); - void DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid, bool blockAA ); - void DrawRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ); - void DrawRect( const tools::Rectangle& rRect ); - void DrawPolygon( sal_uInt32 nPoints, const Point* pPtAry ); - void DrawLineSegment(float x1, float y1, float x2, float y2); - void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, bool blockAA = false ); - void DrawRegionBand( const RegionBand& rRegion ); - void DrawTextureRect( const SalTwoRect& rPosAry ); - void DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false ); - void DrawTransformedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY ); - void DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool pPremultiplied ); - void DrawTextureDiff( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry, bool bInverted ); - void DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry ); - void DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, OpenGLTexture& rAlpha, const SalTwoRect& rPosAry ); - void DrawMask( OpenGLTexture& rTexture, Color nMaskColor, const SalTwoRect& rPosAry ); - 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 FlushDeferredDrawing(); - void FlushLinesOrTriangles(DrawShaderType eType, RenderParameters const & rParameters); - -public: - // get the width of the device - GLfloat GetWidth() const { return mpProvider ? mpProvider->GetWidth() : 1; } - - // get the height of the device - GLfloat GetHeight() const { return mpProvider ? mpProvider->GetHeight() : 1; } - - /** - * check whether this instance is used for offscreen (Virtual Device) - * rendering ie. does it need its own context. - */ - bool IsOffscreen() const { return mpProvider == nullptr || mpProvider->IsOffScreen(); } - - /// Oddly not all operations obey the XOR option. - enum XOROption { IGNORE_XOR, IMPLEMENT_XOR }; - - // initialize pre-draw state - void InitializePreDrawState(XOROption eOpt); - - // operations to do before painting - void PreDraw(XOROption eOpt = IGNORE_XOR); - - // operations to do after painting - void PostDraw(); - - void PostBatchDraw(); - -protected: - bool AcquireContext(bool bForceCreate = false); - void ReleaseContext(); - - /// create a new context for rendering to the underlying window - virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0; - - /// check whether the given context can be used for off-screen rendering - static bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) - { - return pContext->isInitialized() && // not released by the OS etc. - pContext->isVCLOnly(); - } - -public: - OpenGLSalGraphicsImpl(SalGraphics& pParent, SalGeometryProvider *pProvider); - virtual ~OpenGLSalGraphicsImpl () override; - - rtl::Reference<OpenGLContext> GetOpenGLContext(); - - virtual void Init() override; - - virtual void DeInit() override; - - virtual void freeResources() override; - - virtual OUString getRenderBackendName() const override { return "opengl"; } - - const vcl::Region& getClipRegion() const; - virtual bool setClipRegion( const vcl::Region& ) override; - - // - // get the depth of the device - virtual sal_uInt16 GetBitCount() const override; - - // get the width of the device - virtual tools::Long GetGraphicsWidth() const override; - - // set the clip region to empty - virtual void ResetClipRegion() override; - - // set the line color to transparent (= don't draw lines) - - virtual void SetLineColor() override; - - // set the line color to a specific color - virtual void SetLineColor( Color nColor ) override; - - // set the fill color to transparent (= don't fill) - virtual void SetFillColor() override; - - // set the fill color to a specific color, shapes will be - // filled accordingly - virtual void SetFillColor( Color nColor ) override; - - // enable/disable XOR drawing - virtual void SetXORMode( bool bSet, bool bInvertOnly ) override; - - // set line color for raster operations - virtual void SetROPLineColor( SalROPColor nROPColor ) override; - - // set fill color for raster operations - virtual void SetROPFillColor( SalROPColor nROPColor ) override; - - // draw --> LineColor and FillColor and RasterOp and ClipRegion - virtual void drawPixel( tools::Long nX, tools::Long nY ) override; - virtual void drawPixel( tools::Long nX, tools::Long nY, Color nColor ) override; - - virtual void drawLine( tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2 ) override; - - virtual void drawRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; - - virtual void drawPolyLine( sal_uInt32 nPoints, const Point* pPtAry ) override; - - virtual void drawPolygon( sal_uInt32 nPoints, const Point* pPtAry ) override; - - virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, const Point** pPtAry ) override; - - virtual bool drawPolyPolygon( - const basegfx::B2DHomMatrix& rObjectToDevice, - const basegfx::B2DPolyPolygon&, - double fTransparency) override; - - virtual bool drawPolyLine( - const basegfx::B2DHomMatrix& rObjectToDevice, - const basegfx::B2DPolygon&, - double fTransparency, - double fLineWidth, - const std::vector< double >* pStroke, // MM01 - basegfx::B2DLineJoin, - css::drawing::LineCap, - double fMiterMinimumAngle, - bool bPixelSnapHairline) override; - - virtual bool drawPolyLineBezier( - sal_uInt32 nPoints, - const Point* pPtAry, - const PolyFlags* pFlgAry ) override; - - virtual bool drawPolygonBezier( - sal_uInt32 nPoints, - const Point* pPtAry, - const PolyFlags* pFlgAry ) override; - - virtual bool drawPolyPolygonBezier( - sal_uInt32 nPoly, - const sal_uInt32* pPoints, - const Point* const* pPtAry, - const PolyFlags* const* pFlgAry ) override; - - // CopyArea --> No RasterOp, but ClipRegion - virtual void copyArea( - tools::Long nDestX, tools::Long nDestY, - tools::Long nSrcX, tools::Long nSrcY, - tools::Long nSrcWidth, tools::Long nSrcHeight, - bool bWindowInvalidate ) override; - - // CopyBits and DrawBitmap --> RasterOp and ClipRegion - // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics - void DoCopyBits(const SalTwoRect& rPosAry, OpenGLSalGraphicsImpl &rSrcImpl); - - virtual bool blendBitmap( - const SalTwoRect&, - const SalBitmap& rBitmap ) override; - - virtual bool blendAlphaBitmap( - const SalTwoRect&, - const SalBitmap& rSrcBitmap, - const SalBitmap& rMaskBitmap, - const SalBitmap& rAlphaBitmap ) override; - - virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) override; - - virtual void drawBitmap( - const SalTwoRect& rPosAry, - const SalBitmap& rSalBitmap, - const SalBitmap& rMaskBitmap ) override; - - virtual void drawMask( - const SalTwoRect& rPosAry, - const SalBitmap& rSalBitmap, - Color nMaskColor ) override; - - virtual std::shared_ptr<SalBitmap> getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; - - virtual Color getPixel( tools::Long nX, tools::Long nY ) override; - - // invert --> ClipRegion (only Windows or VirDevs) - virtual void invert( - tools::Long nX, tools::Long nY, - tools::Long nWidth, tools::Long nHeight, - SalInvert nFlags) override; - - virtual void invert( sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags ) override; - - virtual bool drawEPS( - tools::Long nX, tools::Long nY, - tools::Long nWidth, tools::Long nHeight, - void* pPtr, - sal_uInt32 nSize ) override; - - /** Render bitmap with alpha channel - - @param rSourceBitmap - Source bitmap to blit - - @param rAlphaBitmap - Alpha channel to use for blitting - - @return true, if the operation succeeded, and false - otherwise. In this case, clients should try to emulate alpha - compositing themselves - */ - virtual bool drawAlphaBitmap( - const SalTwoRect&, - const SalBitmap& rSourceBitmap, - const SalBitmap& rAlphaBitmap ) override; - - /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */ - virtual bool drawTransformedBitmap( - const basegfx::B2DPoint& rNull, - const basegfx::B2DPoint& rX, - const basegfx::B2DPoint& rY, - const SalBitmap& rSourceBitmap, - const SalBitmap* pAlphaBitmap) override; - - /** Render solid rectangle with given transparency - - @param nX Top left coordinate of rectangle - - @param nY Bottom right coordinate of rectangle - - @param nWidth Width of rectangle - - @param nHeight Height of rectangle - - @param nTransparency Transparency value (0-255) to use. 0 blits and opaque, 255 a - fully transparent rectangle - - @returns true if successfully drawn, false if not able to draw rectangle - */ - virtual bool drawAlphaRect( - tools::Long nX, tools::Long nY, - tools::Long nWidth, tools::Long nHeight, - sal_uInt8 nTransparency ) override; - - virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override; - virtual bool implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolygon, SalGradient const & rGradient) override; - - virtual bool supportsOperation(OutDevSupportType eType) const override; - - /// queue an idle flush of contents of the back-buffer to the screen - void flush(); - -public: - /// do flush of contents of the back-buffer to the screen & swap. - void doFlush(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx deleted file mode 100644 index b69eb0282c88..000000000000 --- a/vcl/inc/opengl/program.hxx +++ /dev/null @@ -1,122 +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_OPENGL_PROGRAM_H -#define INCLUDED_VCL_INC_OPENGL_PROGRAM_H - -#include <sal/config.h> - -#include <vector> - -#include <vcl/dllapi.h> - -#include <basegfx/point/b2dpoint.hxx> -#include <rtl/ustring.hxx> -#include <opengl/texture.hxx> - -#include <unordered_map> - -class Color; - -enum class TextureShaderType -{ - Normal = 0, - Blend, - Masked, - Diff, - MaskedColor -}; - -enum class DrawShaderType -{ - Normal = 0, - Line -}; - -class OpenGLProgram -{ -private: - GLuint mnId; - std::unordered_map< OString, GLuint > - maUniformLocations; - sal_uInt32 mnEnabledAttribs; - GLuint mnPositionAttrib; - GLuint mnTexCoordAttrib; - GLuint mnAlphaCoordAttrib; - GLuint mnMaskCoordAttrib; - GLuint mnExtrusionVectorsAttrib; - GLuint mnVertexColorsAttrib; - - std::vector< OpenGLTexture > maTextures; - bool mbBlending; - - float mfLastWidth; - float mfLastHeight; - float mfLastPixelOffset; - - - OpenGLProgram(const OpenGLProgram &) = delete; -public: - OpenGLProgram(); - ~OpenGLProgram(); - - GLuint Id() { return mnId; } - - bool Load( const OUString& rVertexShader, const OUString& rFragmentShader, - const OString& preamble, const OString& rDigest ); - void Use(); - void Reuse(); - void Clean(); - - void SetVertices( const GLvoid* pData ); - void SetTextureCoord( const GLvoid* pData ); - void SetAlphaCoord( const GLvoid* pData ); - void SetMaskCoord(const GLvoid* pData); - void SetExtrusionVectors(const GLvoid* pData); - void SetVertexColors(std::vector<GLubyte>& rColorVector); - - void SetUniform1f( const OString& rName, GLfloat v1 ); - void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 ); - void SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat const * aValues ); - void SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat const * aValues ); - void SetUniform1i( const OString& rName, GLint v1 ); - void SetColor( const OString& rName, const Color& rColor ); - void SetColor( const OString& rName, Color nColor, sal_uInt8 nTransparency ); - void SetColorf( const OString& rName, Color nColor, double fTransparency ); - void SetColorWithIntensity( const OString& rName, const Color& rColor, tools::Long nFactor ); - void SetTexture( const OString& rName, OpenGLTexture& rTexture ); - void SetTransform( const OString& rName, const OpenGLTexture& rTexture, - const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, - const basegfx::B2DPoint& rY ); - void SetIdentityTransform(const OString& rName); - void SetShaderType(TextureShaderType eTextureShaderType); - void SetShaderType(DrawShaderType eDrawShaderType); - - void SetBlendMode( GLenum nSFactor, GLenum nDFactor ); - - void ApplyMatrix(float fWidth, float fHeight, float fPixelOffset = 0.0f); - - void DrawTexture( const OpenGLTexture& rTexture ); - - void DrawArrays(GLenum aMode, std::vector<GLfloat>& aVertices); - void DrawElements(GLenum aMode, GLuint nNumberOfVertices); - - bool EnableVertexAttrib(GLuint& rAttrib, const OString& rName); - - void SetVertexAttrib(GLuint& rAttrib, const OString& rName, GLint nSize, - GLenum eType, GLboolean bNormalized, GLsizei aStride, - const GLvoid* pPointer); - -private: - GLuint GetUniformLocation( const OString& rName ); -}; - -#endif // INCLUDED_VCL_INC_OPENGL_PROGRAM_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx deleted file mode 100644 index 61d2d37e90c2..000000000000 --- a/vcl/inc/opengl/salbmp.hxx +++ /dev/null @@ -1,113 +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_OPENGL_SALBMP_H -#define INCLUDED_VCL_INC_OPENGL_SALBMP_H - -#include <vcl/opengl/OpenGLContext.hxx> - -#include <opengl/texture.hxx> - -#include <salbmp.hxx> - -#include <memory> - -struct BitmapBuffer; -class BitmapPalette; -namespace vcl -{ - class Kernel; -} - -class VCL_PLUGIN_PUBLIC OpenGLSalBitmap final : public SalBitmap -{ -private: - OpenGLTexture maTexture; - bool mbDirtyTexture; - BitmapPalette maPalette; - std::shared_ptr<sal_uInt8> mpUserBuffer; - sal_uInt16 mnBits; - sal_uInt32 mnBytesPerRow; - int mnWidth; - int mnHeight; - - virtual void updateChecksum() const override; - - bool calcChecksumGL(OpenGLTexture& rInputTexture, BitmapChecksum& rChecksum) const; - -public: - OpenGLSalBitmap(); - virtual ~OpenGLSalBitmap() override; - -public: - - // SalBitmap methods - bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ) override; - bool Create( const SalBitmap& rSalBmp ) override; - bool Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) override; - bool Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) override; - virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas, - Size& rSize, - bool bMask = false ) override; - - void Destroy() final override; - - Size GetSize() const override; - sal_uInt16 GetBitCount() const override; - - BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override; - void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override; - - bool GetSystemData( BitmapSystemData& rData ) override; - - bool ScalingSupported() const override; - bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; - bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; - bool ConvertToGreyscale() override; - bool InterpretAs8Bit() override; - -public: - - void Create( const OpenGLTexture& rTex, tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ); - OpenGLTexture& GetTexture() const; - const BitmapPalette& GetBitmapPalette() const { return maPalette; } - -private: - - GLuint CreateTexture(); - bool AllocateUserData(); - void DeallocateUserData(); - bool ReadTexture(); - -private: - - bool ImplScaleFilter( const rtl::Reference< OpenGLContext > &xContext, const double& rScaleX, const double& rScaleY, GLenum nFilter ); - static void ImplCreateKernel( const double& fScale, const vcl::Kernel& rKernel, GLfloat*& pWeights, sal_uInt32& aKernelSize ); - bool ImplScaleConvolution(const rtl::Reference< OpenGLContext > &xContext, const double& rScaleX, const double& rScaleY, const vcl::Kernel& rKernel); - bool ImplScaleArea( const rtl::Reference< OpenGLContext > &xContext, - double rScaleX, double rScaleY ); - -public: - - void ImplScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ); -}; - -#endif // INCLUDED_VCL_INC_OPENGL_SALBMP_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx deleted file mode 100644 index 0438b9af1541..000000000000 --- a/vcl/inc/opengl/texture.hxx +++ /dev/null @@ -1,139 +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_OPENGL_TEXTURE_H -#define INCLUDED_VCL_INC_OPENGL_TEXTURE_H - -#include <epoxy/gl.h> -#include <vcl/dllapi.h> -#include <vcl/salgtype.hxx> -#include <rtl/ustring.hxx> -#include <tools/gen.hxx> - -#include <functional> -#include <memory> -#include <vector> - -class ImplOpenGLTexture -{ -public: - GLuint mnTexture; - int mnWidth; - int mnHeight; - GLenum mnFilter; - GLuint mnOptStencil; - - std::unique_ptr<std::vector<int>> mpSlotReferences; - std::function<void(int)> mFunctSlotDeallocateCallback; - - ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate ); - ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, void const * pData ); - ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight ); - ~ImplOpenGLTexture(); - - bool InsertBuffer(int nX, int nY, int nWidth, int nHeight, int nFormat, int nType, sal_uInt8 const * pData); - - void IncreaseRefCount(int nSlotNumber); - void DecreaseRefCount(int nSlotNumber); - - void InitializeSlotMechanism(int nInitialSlotSize); - - void SetSlotDeallocateCallback(std::function<void(int)> aCallback) - { - mFunctSlotDeallocateCallback = aCallback; - } - - void ResetSlotDeallocateCallback() - { - mFunctSlotDeallocateCallback = std::function<void(int)>(); - } - - GLuint AddStencil(); -}; - -class VCL_DLLPUBLIC OpenGLTexture final -{ -private: - // if the rect size doesn't match the mpImpl one, this instance - // is a sub-area from the real OpenGL texture - tools::Rectangle maRect; - std::shared_ptr<ImplOpenGLTexture> mpImpl; - int mnSlotNumber; - - inline void GetTextureRect(const SalTwoRect& rPosAry, GLfloat& x1, GLfloat& x2, GLfloat& y1, GLfloat& y2) const; - - bool IsValid() const - { - return (mpImpl && mpImpl->mnTexture != 0); - } - -public: - OpenGLTexture(); - OpenGLTexture(const std::shared_ptr<ImplOpenGLTexture>& pImpl, tools::Rectangle aRectangle, int nSlotNumber); - - OpenGLTexture( int nWidth, int nHeight, bool bAllocate = true ); - OpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, void const * pData ); - OpenGLTexture( int nX, int nY, int nWidth, int nHeight ); - OpenGLTexture( const OpenGLTexture& rTexture ); - OpenGLTexture( OpenGLTexture&& rTexture ) noexcept; - OpenGLTexture( const OpenGLTexture& rTexture, int nX, int nY, int nWidth, int nHeight ); - ~OpenGLTexture(); - - bool IsUnique() const; - - GLuint Id() const; - int GetWidth() const; - int GetHeight() const; - - void GetCoord( GLfloat* pCoord, const SalTwoRect& rPosAry, bool bInverted=false ) const; - void GetWholeCoord( GLfloat* pCoord ) const; - void Bind(); - void Unbind(); - void Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ); - GLuint AddStencil(); - GLuint StencilId() const; - - bool CopyData(int nWidth, int nHeight, int nFormat, int nType, sal_uInt8 const * pData); - - void SaveToFile(const OUString& rFileName); - - GLenum GetFilter() const; - void SetFilter( GLenum nFilter ); - - operator bool() const; - OpenGLTexture& operator=( const OpenGLTexture& rTexture ); - OpenGLTexture& operator=( OpenGLTexture&& rTexture ); - bool operator==( const OpenGLTexture& rTexture ) const; - bool operator!=( const OpenGLTexture& rTexture ) const; - - template<GLenum type> - void FillCoords(std::vector<GLfloat>& aCoordVector, const SalTwoRect& rPosAry) const; -}; - -template<> void OpenGLTexture::FillCoords<GL_TRIANGLES>( - std::vector<GLfloat>& aCoord, const SalTwoRect& rPosAry) - const; - -template<> void OpenGLTexture::FillCoords<GL_TRIANGLE_FAN>( - std::vector<GLfloat>& aCoord, const SalTwoRect& rPosAry) - const; - -#endif // INCLUDED_VCL_INC_OPENGL_TEXTURE_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx deleted file mode 100644 index dff47ef7e550..000000000000 --- a/vcl/inc/opengl/win/gdiimpl.hxx +++ /dev/null @@ -1,97 +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_OPENGL_WIN_GDIIMPL_HXX -#define INCLUDED_VCL_INC_OPENGL_WIN_GDIIMPL_HXX - -#include <memory> -#include <vcl/dllapi.h> - -#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 OpenGLCompatibleDC : public CompatibleDC -{ -public: - OpenGLCompatibleDC(SalGraphics &rGraphics, int x, int y, int width, int height); - - virtual std::unique_ptr<Texture> getAsMaskTexture() const override; - // caller must delete - OpenGLTexture* getOpenGLTexture() const; - - /// Copy bitmap data to the texture. Texture must be initialized and the correct size to hold the bitmap. - bool copyToTexture(Texture& aTexture) const; - - 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: - WinSalGraphics& mrWinParent; - - bool RenderCompatibleDC(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack, - int nX, int nY, TextureCombo& rCombo); - -public: - WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics, - SalGeometryProvider *mpProvider); - -protected: - virtual rtl::Reference<OpenGLContext> CreateWinContext() override; - - bool RenderTextureCombo(TextureCombo const & rCombo, int nX, int nY); - -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 DrawTextMask( 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; - - 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; - -}; - -typedef std::pair<ControlCacheKey, std::unique_ptr<TextureCombo>> OpenGLControlCachePair; -typedef o3tl::lru_map<ControlCacheKey, std::unique_ptr<TextureCombo>, ControlCacheHashFunction> OpenGLControlCacheType; - -class OpenGLControlsCache { - OpenGLControlCacheType cache; - - OpenGLControlsCache(); - -public: - static OpenGLControlCacheType & get(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/win/winlayout.hxx b/vcl/inc/opengl/win/winlayout.hxx deleted file mode 100644 index d017bc250497..000000000000 --- a/vcl/inc/opengl/win/winlayout.hxx +++ /dev/null @@ -1,51 +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_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, CompatibleDC* dc) override; - virtual void Prune() override; -}; - -class OpenGLWinGlyphCache : public WinGlyphCache -{ -public: - void RemoveTextures(std::vector<GLuint>& rTextureIDs); - -private: - // This class just "adds" RemoveTextures() to the base class, it's never instantiated. - OpenGLWinGlyphCache() = delete; -}; - -#endif // INCLUDED_VCL_INC_OPENGL_WIN_WINLAYOUT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/x11/cairotextrender.hxx b/vcl/inc/opengl/x11/cairotextrender.hxx deleted file mode 100644 index 137022fa847b..000000000000 --- a/vcl/inc/opengl/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_UNX_GENERIC_GDI_OPENGLX11CAIROTEXTRENDER_HXX -#define INCLUDED_VCL_UNX_GENERIC_GDI_OPENGLX11CAIROTEXTRENDER_HXX - -#include <unx/x11/x11cairotextrender.hxx> - -class OpenGLX11CairoTextRender final : public X11CairoTextRender -{ -public: - explicit OpenGLX11CairoTextRender(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/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx deleted file mode 100644 index e55c6f1095ba..000000000000 --- a/vcl/inc/opengl/x11/gdiimpl.hxx +++ /dev/null @@ -1,42 +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_OPENGL_X11_GDIIMPL_HXX -#define INCLUDED_VCL_INC_OPENGL_X11_GDIIMPL_HXX - -#include <vcl/dllapi.h> - -#include <unx/salgdi.h> -#include <unx/x11/x11gdiimpl.h> -#include <opengl/gdiimpl.hxx> -#include <ControlCacheKey.hxx> - -struct TextureCombo; - -class X11OpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl, public X11GraphicsImpl -{ -private: - X11SalGraphics& mrX11Parent; - -public: - X11OpenGLSalGraphicsImpl(X11SalGraphics& rParent); - virtual ~X11OpenGLSalGraphicsImpl() override; - -protected: - virtual rtl::Reference<OpenGLContext> CreateWinContext() override; - -public: - virtual void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override; - - virtual void Init() override; -}; - -#endif // INCLUDED_VCL_INC_OPENGL_X11_GDIIMPL_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/x11/salvd.hxx b/vcl/inc/opengl/x11/salvd.hxx deleted file mode 100644 index 9c8d3cb70165..000000000000 --- a/vcl/inc/opengl/x11/salvd.hxx +++ /dev/null @@ -1,57 +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_OPENGL_X11_SALVD_H -#define INCLUDED_VCL_INC_OPENGL_X11_SALVD_H - -#include <memory> -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -#include <unx/saltype.h> -#include <salvd.hxx> - -class SalDisplay; -class X11OpenGLSalGraphics; -class X11SalGraphics; - -class X11OpenGLSalVirtualDevice : public SalVirtualDevice -{ - SalDisplay *mpDisplay; - std::unique_ptr<X11SalGraphics> - mpGraphics; - bool mbGraphics; // is Graphics used - SalX11Screen mnXScreen; - int mnWidth; - int mnHeight; - -public: - X11OpenGLSalVirtualDevice( SalGraphics const *pGraphics, - tools::Long nDX, tools::Long nDY, - const SystemGraphicsData *pData, - std::unique_ptr<X11SalGraphics> pNewGraphics); - virtual ~X11OpenGLSalVirtualDevice() override; - - // SalGeometryProvider - virtual tools::Long GetWidth() const override { return mnWidth; } - virtual tools::Long GetHeight() const override { return mnHeight; } - - SalDisplay * GetDisplay() const { return mpDisplay; } - const SalX11Screen& GetXScreenNumber() const { return mnXScreen; } - - virtual SalGraphics* AcquireGraphics() override; - virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; - - // Set new size, without saving the old contents - virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) override; -}; - -#endif // INCLUDED_VCL_INC_OPENGL_X11_SALVD_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/opengl/zone.hxx b/vcl/inc/opengl/zone.hxx index f7f36ea22f84..726479b7c15c 100644 --- a/vcl/inc/opengl/zone.hxx +++ b/vcl/inc/opengl/zone.hxx @@ -29,22 +29,6 @@ public: static const char* name() { return "OpenGL"; } }; -/// Create this to not only enter the zone, but set VCL context. -class OpenGLVCLContextZone -{ - OpenGLZone aZone; - -public: - OpenGLVCLContextZone(); -}; - -class VCL_DLLPUBLIC PreDefaultWinNoOpenGLZone -{ -public: - PreDefaultWinNoOpenGLZone(); - ~PreDefaultWinNoOpenGLZone(); -}; - #endif // INCLUDED_VCL_INC_OPENGL_ZONE_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |