summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-04-14 18:22:21 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-04-16 13:45:12 +0200
commit1e3869ea1ce71922280ad9fc4e95e52fed722571 (patch)
tree1410eabfdfd5224e11c159d6166065ea67707dbb /vcl/opengl
parent0555bda4856626f520a14c33fa5ba8ff8dcb0ac8 (diff)
in dbgutil mode initialize texture contents with predictable garbage
So that textures do not start with random uninitialized contents. Change-Id: Ie240f5f71ed77d5c6c22a120e96540a2d0d7c2ed Reviewed-on: https://gerrit.libreoffice.org/70773 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/texture.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 19b48967e314..e0af455194c7 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -65,7 +65,21 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate )
CHECK_GL_ERROR();
if( bAllocate )
{
+#ifdef DBG_UTIL
+ std::vector< sal_uInt8 > buffer;
+ buffer.resize( nWidth * nHeight * 4 );
+ for( size_t i = 0; i < size_t( nWidth * nHeight ); ++i )
+ { // pre-fill the texture with deterministic garbage
+ bool odd = (i & 0x01);
+ buffer[ i * 4 ] = odd ? 0x40 : 0xBF;
+ buffer[ i * 4 + 1 ] = 0x80;
+ buffer[ i * 4 + 2 ] = odd ? 0xBF : 0x40;
+ buffer[ i * 4 + 3 ] = 0xFF;
+ }
+ glTexImage2D( GL_TEXTURE_2D, 0, constInternalFormat, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data());
+#else
glTexImage2D( GL_TEXTURE_2D, 0, constInternalFormat, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr );
+#endif
CHECK_GL_ERROR();
}