diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-09-20 14:55:44 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:05 +0100 |
commit | 534d89fed30983bcc48387facc3410f13e230683 (patch) | |
tree | 68655d6fc7f3b66a43b0e3cd3687678515526bbe /vcl/opengl | |
parent | 736e7ceee814eac3689e588b5032fe29cc229bf7 (diff) |
move opengl vcl files to opengl/
Better to have all of them together rather than scattered.
Change-Id: I1f8bbfb7018a6c28c87e4dfa2acbf4efde62894b
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 2 | ||||
-rw-r--r-- | vcl/opengl/x11/cairotextrender.cxx | 84 |
2 files changed, 85 insertions, 1 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index b7443ffd6d26..30d2299978ea 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <openglgdiimpl.hxx> +#include <opengl/gdiimpl.hxx> #include <opengl/framebuffer.hxx> #include <vcl/gradient.hxx> diff --git a/vcl/opengl/x11/cairotextrender.cxx b/vcl/opengl/x11/cairotextrender.cxx new file mode 100644 index 000000000000..39b5f661dca0 --- /dev/null +++ b/vcl/opengl/x11/cairotextrender.cxx @@ -0,0 +1,84 @@ +/* -*- 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 <opengl/x11/cairotextrender.hxx> + +#include <opengl/gdiimpl.hxx> + +#include <cairo.h> + +OpenGLX11CairoTextRender::OpenGLX11CairoTextRender(X11SalGraphics& rParent) + : X11CairoTextRender(rParent) +{ +} + +cairo_t* OpenGLX11CairoTextRender::getCairoContext() +{ + cairo_surface_t* surface = nullptr; + OpenGLSalGraphicsImpl *pImpl = dynamic_cast< OpenGLSalGraphicsImpl* >(mrParent.GetImpl()); + if( pImpl ) + { + tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); + if( aClipRect.GetWidth() == 0 || aClipRect.GetHeight() == 0 ) + { + 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 OpenGLX11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY ) +{ + OpenGLSalGraphicsImpl *pImpl = dynamic_cast< OpenGLSalGraphicsImpl* >(mrParent.GetImpl()); + if( pImpl ) + { + tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); + nDX = -aClipRect.Left(); + nDY = -aClipRect.Top(); + } +} + +void OpenGLX11CairoTextRender::releaseCairoContext(cairo_t* cr) +{ + // XXX: lfrb: GLES 2.0 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV + OpenGLSalGraphicsImpl *pImpl = dynamic_cast< OpenGLSalGraphicsImpl* >(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 ); + + // XXX: lfrb: GLES 2.0 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV + tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); + + SalTwoRect aRect(0, 0, nWidth, nHeight, + aClipRect.Left(), aClipRect.Top(), nWidth, nHeight); + + // Cairo surface data is ARGB with premultiplied alpha and is Y-inverted + OpenGLTexture aTexture( nWidth, nHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pSrc ); + pImpl->PreDraw(); + pImpl->DrawAlphaTexture( aTexture, aRect, true, true ); + pImpl->PostDraw(); + + cairo_destroy(cr); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |