summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-04-02 20:14:41 +0300
committerStephan Bergmann <sbergman@redhat.com>2021-04-08 08:17:21 +0200
commit4f3b811d6249af4bfec2a0cb07fce9928baf07cd (patch)
tree95fa665a1b9f7a668ef3b7162b6d844acf8b5694
parent673297dea98892abca3e4421a2e40d8940d7220b (diff)
Compute permutation2D at compile time
Change-Id: Ia69913a11aa47a2c37a1c7cb8316cb9d34dffeec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113522 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--slideshow/source/engine/opengl/TransitionImpl.cxx91
1 files changed, 43 insertions, 48 deletions
diff --git a/slideshow/source/engine/opengl/TransitionImpl.cxx b/slideshow/source/engine/opengl/TransitionImpl.cxx
index f8d062d34941..d45b17c2e953 100644
--- a/slideshow/source/engine/opengl/TransitionImpl.cxx
+++ b/slideshow/source/engine/opengl/TransitionImpl.cxx
@@ -1431,60 +1431,55 @@ void PermTextureTransition::finishTransition()
CHECK_GL_ERROR();
}
-int permutation256 [256]= {
-215, 100, 200, 204, 233, 50, 85, 196,
- 71, 141, 122, 160, 93, 131, 243, 234,
-162, 183, 36, 155, 4, 62, 35, 205,
- 40, 102, 33, 27, 255, 55, 214, 156,
- 75, 163, 134, 126, 249, 74, 197, 228,
- 72, 90, 206, 235, 17, 22, 49, 169,
-227, 89, 16, 5, 117, 60, 248, 230,
-217, 68, 138, 96, 194, 170, 136, 10,
-112, 238, 184, 189, 176, 42, 225, 212,
- 84, 58, 175, 244, 150, 168, 219, 236,
-101, 208, 123, 37, 164, 110, 158, 201,
- 78, 114, 57, 48, 70, 142, 106, 43,
-232, 26, 32, 252, 239, 98, 191, 94,
- 59, 149, 39, 187, 203, 190, 19, 13,
-133, 45, 61, 247, 23, 34, 20, 52,
-118, 209, 146, 193, 222, 18, 1, 152,
- 46, 41, 91, 148, 115, 25, 135, 77,
-254, 147, 224, 161, 9, 213, 223, 250,
-231, 251, 127, 166, 63, 179, 81, 130,
-139, 28, 120, 151, 241, 86, 111, 0,
- 88, 153, 172, 182, 159, 105, 178, 47,
- 51, 167, 65, 66, 92, 73, 198, 211,
-245, 195, 31, 220, 140, 76, 221, 186,
-154, 185, 56, 83, 38, 165, 109, 67,
-124, 226, 132, 53, 229, 29, 12, 181,
-121, 24, 207, 199, 177, 113, 30, 80,
- 3, 97, 188, 79, 216, 173, 8, 145,
- 87, 128, 180, 237, 240, 137, 125, 104,
- 15, 242, 119, 246, 103, 143, 95, 144,
- 2, 44, 69, 157, 192, 174, 14, 54,
-218, 82, 64, 210, 11, 6, 129, 21,
-116, 171, 99, 202, 7, 107, 253, 108
-};
+constexpr auto permutation2D = []() constexpr {
+ int permutation256 [256]= {
+ 215, 100, 200, 204, 233, 50, 85, 196,
+ 71, 141, 122, 160, 93, 131, 243, 234,
+ 162, 183, 36, 155, 4, 62, 35, 205,
+ 40, 102, 33, 27, 255, 55, 214, 156,
+ 75, 163, 134, 126, 249, 74, 197, 228,
+ 72, 90, 206, 235, 17, 22, 49, 169,
+ 227, 89, 16, 5, 117, 60, 248, 230,
+ 217, 68, 138, 96, 194, 170, 136, 10,
+ 112, 238, 184, 189, 176, 42, 225, 212,
+ 84, 58, 175, 244, 150, 168, 219, 236,
+ 101, 208, 123, 37, 164, 110, 158, 201,
+ 78, 114, 57, 48, 70, 142, 106, 43,
+ 232, 26, 32, 252, 239, 98, 191, 94,
+ 59, 149, 39, 187, 203, 190, 19, 13,
+ 133, 45, 61, 247, 23, 34, 20, 52,
+ 118, 209, 146, 193, 222, 18, 1, 152,
+ 46, 41, 91, 148, 115, 25, 135, 77,
+ 254, 147, 224, 161, 9, 213, 223, 250,
+ 231, 251, 127, 166, 63, 179, 81, 130,
+ 139, 28, 120, 151, 241, 86, 111, 0,
+ 88, 153, 172, 182, 159, 105, 178, 47,
+ 51, 167, 65, 66, 92, 73, 198, 211,
+ 245, 195, 31, 220, 140, 76, 221, 186,
+ 154, 185, 56, 83, 38, 165, 109, 67,
+ 124, 226, 132, 53, 229, 29, 12, 181,
+ 121, 24, 207, 199, 177, 113, 30, 80,
+ 3, 97, 188, 79, 216, 173, 8, 145,
+ 87, 128, 180, 237, 240, 137, 125, 104,
+ 15, 242, 119, 246, 103, 143, 95, 144,
+ 2, 44, 69, 157, 192, 174, 14, 54,
+ 218, 82, 64, 210, 11, 6, 129, 21,
+ 116, 171, 99, 202, 7, 107, 253, 108
+ };
+ std::array<unsigned char, 256 * 256> a{};
+ for (int y = 0; y < 256; y++)
+ for (int x = 0; x < 256; x++)
+ a[x + y * 256] = permutation256[(y + permutation256[x]) & 0xff];
+ return a;
+}();
void initPermTexture(GLuint *texID)
{
CHECK_GL_ERROR();
glGenTextures(1, texID);
glBindTexture(GL_TEXTURE_2D, *texID);
-
- static bool initialized = false;
- static unsigned char permutation2D[256*256];
- if( !initialized ) {
- int x, y;
-
- for( y=0; y < 256; y++ )
- for( x=0; x < 256; x++ )
- permutation2D[x + y*256] = permutation256[(y + permutation256[x]) & 0xff];
-
- initialized = true;
- }
-
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RED, GL_UNSIGNED_BYTE, permutation2D );
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RED, GL_UNSIGNED_BYTE,
+ permutation2D.data());
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
CHECK_GL_ERROR();