Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1bb20c0 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Cache shaders for rounded corners and window transition.

Previously we don't cache rounded corners shaders for color management and
window transition, which causes shader compilation during window transition and
takes 30+ ms. This patch caches all cases for both rounded corners and window
transition, as a result, we cache 12 more shaders.

BUG: 129274562
Test: Build, flash and boot. Verify no generateProgram in systrace.
Change-Id: I450836f4303b9e0eaabd4b3b75d089b73a4fce9d
parent 7c3ae9c7
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -102,14 +102,21 @@ void ProgramCache::primeCache(EGLContext context, bool useColorManagement) {
    // Prime for sRGB->P3 conversion
    if (useColorManagement) {
        Key shaderKey;
        shaderKey.set(Key::BLEND_MASK | Key::TEXTURE_MASK | Key::OUTPUT_TRANSFORM_MATRIX_MASK |
                              Key::INPUT_TF_MASK | Key::OUTPUT_TF_MASK,
                      Key::BLEND_PREMULT | Key::TEXTURE_EXT | Key::OUTPUT_TRANSFORM_MATRIX_ON |
                              Key::INPUT_TF_SRGB | Key::OUTPUT_TF_SRGB);
        for (int i = 0; i < 4; i++) {
        shaderKey.set(Key::BLEND_MASK | Key::OUTPUT_TRANSFORM_MATRIX_MASK | Key::INPUT_TF_MASK |
                              Key::OUTPUT_TF_MASK,
                      Key::BLEND_PREMULT | Key::OUTPUT_TRANSFORM_MATRIX_ON | Key::INPUT_TF_SRGB |
                              Key::OUTPUT_TF_SRGB);
        for (int i = 0; i < 16; i++) {
            shaderKey.set(Key::OPACITY_MASK,
                          (i & 1) ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT);
            shaderKey.set(Key::ALPHA_MASK, (i & 2) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE);

            // Cache rounded corners
            shaderKey.set(Key::ROUNDED_CORNERS_MASK,
                          (i & 4) ? Key::ROUNDED_CORNERS_ON : Key::ROUNDED_CORNERS_OFF);

            // Cache texture off option for window transition
            shaderKey.set(Key::TEXTURE_MASK, (i & 8) ? Key::TEXTURE_EXT : Key::TEXTURE_OFF);
            if (cache.count(shaderKey) == 0) {
                cache.emplace(shaderKey, generateProgram(shaderKey));
                shaderCount++;