Kaydet (Commit) cde22222 authored tarafından Zolnai Tamás's avatar Zolnai Tamás Kaydeden (comit) Markus Mohrhard

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
üst f71aae75
......@@ -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();
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment