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

Commit df90a8c8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update shadow render code to use lookup texture"

parents d1233911 f19544f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ filegroup {
        "gl/GLExtensions.cpp",
        "gl/GLFramebuffer.cpp",
        "gl/GLImage.cpp",
        "gl/GLShadowTexture.cpp",
        "gl/GLShadowVertexGenerator.cpp",
        "gl/GLSkiaShadowPort.cpp",
        "gl/ImageManager.cpp",
+1 −0
Original line number Diff line number Diff line
@@ -1661,6 +1661,7 @@ void GLESRenderEngine::handleShadow(const FloatRect& casterRect, float casterCor

    mState.cornerRadius = 0.0f;
    mState.drawShadows = true;
    setupLayerTexturing(mShadowTexture.getTexture());
    drawMesh(mesh);
    mState.drawShadows = false;
}
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <renderengine/RenderEngine.h>
#include <renderengine/private/Description.h>
#include <sys/types.h>
#include "GLShadowTexture.h"
#include "ImageManager.h"

#define EGL_NO_CONFIG ((EGLConfig)0)
@@ -183,6 +184,7 @@ private:
    GLuint mVpWidth;
    GLuint mVpHeight;
    Description mState;
    GLShadowTexture mShadowTexture;

    mat4 mSrgbToXyz;
    mat4 mDisplayP3ToXyz;
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES3/gl3.h>

#include "GLShadowTexture.h"
#include "GLSkiaShadowPort.h"

namespace android {
namespace renderengine {
namespace gl {

GLShadowTexture::GLShadowTexture() {
    fillShadowTextureData(mTextureData, SHADOW_TEXTURE_WIDTH);

    glGenTextures(1, &mName);
    glBindTexture(GL_TEXTURE_2D, mName);
    glTexImage2D(GL_TEXTURE_2D, 0 /* base image level */, GL_ALPHA, SHADOW_TEXTURE_WIDTH,
                 SHADOW_TEXTURE_HEIGHT, 0 /* border */, GL_ALPHA, GL_UNSIGNED_BYTE, mTextureData);
    mTexture.init(Texture::TEXTURE_2D, mName);
    mTexture.setFiltering(true);
    mTexture.setDimensions(SHADOW_TEXTURE_WIDTH, 1);
}

GLShadowTexture::~GLShadowTexture() {
    glDeleteTextures(1, &mName);
}

const Texture& GLShadowTexture::getTexture() {
    return mTexture;
}

} // namespace gl
} // namespace renderengine
} // namespace android
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <renderengine/Texture.h>
#include <cstdint>

namespace android {
namespace renderengine {
namespace gl {

class GLShadowTexture {
public:
    GLShadowTexture();
    ~GLShadowTexture();

    const Texture& getTexture();

private:
    static constexpr int SHADOW_TEXTURE_WIDTH = 128;
    static constexpr int SHADOW_TEXTURE_HEIGHT = 1;

    GLuint mName;
    Texture mTexture;
    uint8_t mTextureData[SHADOW_TEXTURE_WIDTH];
};

} // namespace gl
} // namespace renderengine
} // namespace android
Loading