diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-08-11 10:18:04 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-08-29 17:40:28 +0200 |
commit | cde22222cff549c63045eec968c80c9db0c523f2 (patch) | |
tree | 06249bb0e01b2ed36919cec94df0480ae197e3af | |
parent | f71aae75017308545d0f835de6a5e39603d17002 (diff) |
Mirror vertically the texture bitmaps for OpenGL
In case of glTF models it saves a Mirror() call.
In case of OpenGL charts it avoid flipped texts.
Change-Id: I1ac980e16bcb5ba6a9a025b638aaac3b08b4aab3
-rw-r--r-- | avmedia/source/opengl/oglplayer.cxx | 3 | ||||
-rw-r--r-- | chart2/source/view/main/OpenGLRender.cxx | 2 | ||||
-rw-r--r-- | include/vcl/opengl/OpenGLHelper.hxx | 8 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLHelper.cxx | 4 |
4 files changed, 9 insertions, 8 deletions
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index 917ab2d12c6a..a21d5db403d1 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -102,9 +102,8 @@ bool OGLPlayer::create( const OUString& rURL ) return false; } BitmapEx aBitmapEx = aGraphic.GetBitmapEx(); - aBitmapEx.Mirror(BMP_MIRROR_VERT); rFile.buffer = new char[4 * aBitmapEx.GetSizePixel().Width() * aBitmapEx.GetSizePixel().Height()]; - OpenGLHelper::ConvertBitmapExToRGBABuffer(aBitmapEx, reinterpret_cast<sal_uInt8*>(rFile.buffer)); + OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(aBitmapEx, reinterpret_cast<sal_uInt8*>(rFile.buffer)); rFile.imagewidth = aBitmapEx.GetSizePixel().Width(); rFile.imageheight = aBitmapEx.GetSizePixel().Height(); } diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 42b21cf67b1a..1075b86cc497 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -699,7 +699,7 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point& boost::shared_array<sal_uInt8> bitmapBuf(new sal_uInt8[4 * rBitmapEx.GetSizePixel().Width() * rBitmapEx.GetSizePixel().Height()]); - OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx, bitmapBuf.get()); + OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(rBitmapEx, bitmapBuf.get()); return CreateTextTexture(bitmapBuf, rBitmapEx.GetSizePixel(), awt::Point(), aSize, rotation, rTrans); diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx index aa9448c2b3b7..8b18964eb5f6 100644 --- a/include/vcl/opengl/OpenGLHelper.hxx +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -22,10 +22,12 @@ public: static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName); /** - * Note: The caller is responsible for allocate the memory for the RGBA buffer, before call - * this method. RGBA buffer size is assumed to be 4*width*height + * The caller is responsible for allocate the memory for the RGBA buffer, before call + * this method. RGBA buffer size is assumed to be 4*width*height. + * Since OpenGL uses textures flipped relative to BitmapEx storage this method + * also mirrors the bitmap vertically. **/ - static void ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer); + static void ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer); static BitmapEx ConvertBGRABufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight); static void renderToFile(long nWidth, long nHeight, const OUString& rFileName); diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index c028246b8b06..16dd5b7a9411 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -146,7 +146,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString return ProgramID; } -void OpenGLHelper::ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer) +void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer) { long nBmpWidth = rBitmapEx.GetSizePixel().Width(); long nBmpHeight = rBitmapEx.GetSizePixel().Height(); @@ -156,7 +156,7 @@ void OpenGLHelper::ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx, sal_uI Bitmap::ScopedReadAccess pReadAccces( aBitmap ); AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha ); size_t i = 0; - for (long ny = 0; ny < nBmpHeight; ny++) + for (long ny = nBmpHeight - 1; ny >= 0; ny--) { Scanline pAScan = pAlphaReadAccess ? pAlphaReadAccess->GetScanline(ny) : 0; for(long nx = 0; nx < nBmpWidth; nx++) |