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

Commit b027f805 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: run clang-format on RenderEngine

Run clang-format on all files.  In Program constructor, use mat4()
instead of manually construct a 4x4 identity matrix.

Test: builds
Change-Id: I84e5eec06d103383c715b1f03c521bbcca5bd92c
parent 1e24cceb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@ Description::Description() {
    mColorMatrixEnabled = false;
}

Description::~Description() {
}
Description::~Description() {}

void Description::setPremultipliedAlpha(bool premultipliedAlpha) {
    mPremultipliedAlpha = premultipliedAlpha;
+26 −42
Original line number Diff line number Diff line
@@ -33,15 +33,15 @@
#include <gui/ISurfaceComposer.h>
#include <math.h>

#include "Description.h"
#include "GLES20RenderEngine.h"
#include "Mesh.h"
#include "Program.h"
#include "ProgramCache.h"
#include "Description.h"
#include "Mesh.h"
#include "Texture.h"

#include <sstream>
#include <fstream>
#include <sstream>

// ---------------------------------------------------------------------------
bool checkGlError(const char* op, int lineNumber) {
@@ -107,11 +107,8 @@ void writePPM(const char* basename, GLuint width, GLuint height) {
namespace android {
// ---------------------------------------------------------------------------

GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) :
         mVpWidth(0),
         mVpHeight(0),
         mPlatformHasWideColor((featureFlags & WIDE_COLOR_SUPPORT) != 0) {

GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags)
      : mVpWidth(0), mVpHeight(0), mPlatformHasWideColor((featureFlags & WIDE_COLOR_SUPPORT) != 0) {
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);

@@ -125,8 +122,7 @@ GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) :
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0,
            GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);

    // mColorBlindnessCorrection = M;

@@ -134,7 +130,8 @@ GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) :
        // Compute sRGB to DisplayP3 color transform
        // NOTE: For now, we are limiting wide-color support to
        // Display-P3 only.
        mat3 srgbToP3 = ColorSpaceConnector(ColorSpace::sRGB(), ColorSpace::DisplayP3()).getTransform();
        mat3 srgbToP3 =
                ColorSpaceConnector(ColorSpace::sRGB(), ColorSpace::DisplayP3()).getTransform();

        // color transform needs to be expanded to 4x4 to be what the shader wants
        // mat has an initializer that expands mat3 to mat4, but
@@ -144,24 +141,19 @@ GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) :
    }
}

GLES20RenderEngine::~GLES20RenderEngine() {
}

GLES20RenderEngine::~GLES20RenderEngine() {}

size_t GLES20RenderEngine::getMaxTextureSize() const {
    return mMaxTextureSize;
}

size_t GLES20RenderEngine::getMaxViewportDims() const {
    return
        mMaxViewportDims[0] < mMaxViewportDims[1] ?
            mMaxViewportDims[0] : mMaxViewportDims[1];
    return mMaxViewportDims[0] < mMaxViewportDims[1] ? mMaxViewportDims[0] : mMaxViewportDims[1];
}

void GLES20RenderEngine::setViewportAndProjection(
        size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, bool yswap,
void GLES20RenderEngine::setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop,
                                                  size_t hwh, bool yswap,
                                                  Transform::orientation_flags rotation) {

    size_t l = sourceCrop.left;
    size_t r = sourceCrop.right;

@@ -200,8 +192,8 @@ void GLES20RenderEngine::setViewportAndProjection(
    mVpHeight = vph;
}

void GLES20RenderEngine::setupLayerBlending(bool premultipliedAlpha,
        bool opaque, bool disableTexture, const half4& color) {
void GLES20RenderEngine::setupLayerBlending(bool premultipliedAlpha, bool opaque,
                                            bool disableTexture, const half4& color) {
    mState.setPremultipliedAlpha(premultipliedAlpha);
    mState.setOpaque(opaque);
    mState.setColor(color);
@@ -288,9 +280,8 @@ void GLES20RenderEngine::disableBlending() {
    glDisable(GL_BLEND);
}


void GLES20RenderEngine::bindImageAsFramebuffer(EGLImageKHR image,
        uint32_t* texName, uint32_t* fbName, uint32_t* status) {
void GLES20RenderEngine::bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName,
                                                uint32_t* fbName, uint32_t* status) {
    GLuint tname, name;
    // turn our EGLImage into a texture
    glGenTextures(1, &tname);
@@ -322,21 +313,14 @@ void GLES20RenderEngine::setupFillWithColor(float r, float g, float b, float a)
}

void GLES20RenderEngine::drawMesh(const Mesh& mesh) {

    if (mesh.getTexCoordsSize()) {
        glEnableVertexAttribArray(Program::texCoords);
        glVertexAttribPointer(Program::texCoords,
                mesh.getTexCoordsSize(),
                GL_FLOAT, GL_FALSE,
                mesh.getByteStride(),
                mesh.getTexCoords());
    }

    glVertexAttribPointer(Program::position,
            mesh.getVertexSize(),
            GL_FLOAT, GL_FALSE,
            mesh.getByteStride(),
            mesh.getPositions());
        glVertexAttribPointer(Program::texCoords, mesh.getTexCoordsSize(), GL_FLOAT, GL_FALSE,
                              mesh.getByteStride(), mesh.getTexCoords());
    }

    glVertexAttribPointer(Program::position, mesh.getVertexSize(), GL_FLOAT, GL_FALSE,
                          mesh.getByteStride(), mesh.getPositions());

    if (usesWideColor()) {
        Description wideColorState = mState;
+8 −11
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 * limitations under the License.
 */


#ifndef SF_GLES20RENDERENGINE_H_
#define SF_GLES20RENDERENGINE_H_

@@ -24,9 +23,9 @@
#include <GLES2/gl2.h>
#include <Transform.h>

#include "RenderEngine.h"
#include "ProgramCache.h"
#include "Description.h"
#include "ProgramCache.h"
#include "RenderEngine.h"

// ---------------------------------------------------------------------------
namespace android {
@@ -54,8 +53,8 @@ class GLES20RenderEngine : public RenderEngine {
    Description mState;
    Vector<Group> mGroupStack;

    virtual void bindImageAsFramebuffer(EGLImageKHR image,
            uint32_t* texName, uint32_t* fbName, uint32_t* status);
    virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName,
                                        uint32_t* status);
    virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName);

public:
@@ -63,13 +62,11 @@ public:
    virtual ~GLES20RenderEngine();

protected:

    virtual void dump(String8& result);
    virtual void setViewportAndProjection(size_t vpw, size_t vph,
            Rect sourceCrop, size_t hwh, bool yswap,
            Transform::orientation_flags rotation);
    virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque,
            bool disableTexture, const half4& color) override;
    virtual void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, size_t hwh,
                                          bool yswap, Transform::orientation_flags rotation);
    virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture,
                                    const half4& color) override;

    // Color management related functions and state
    void setColorMode(android_color_mode mode);
+12 −20
Original line number Diff line number Diff line
@@ -14,9 +14,9 @@
 * limitations under the License.
 */

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#include "GLExtensions.h"

@@ -25,17 +25,10 @@ namespace android {

ANDROID_SINGLETON_STATIC_INSTANCE(GLExtensions)

GLExtensions::GLExtensions()
    : mHaveFramebufferObject(false)
{
}
GLExtensions::GLExtensions() : mHaveFramebufferObject(false) {}

void GLExtensions::initWithGLStrings(
        GLubyte const* vendor,
        GLubyte const* renderer,
        GLubyte const* version,
        GLubyte const* extensions)
{
void GLExtensions::initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer,
                                     GLubyte const* version, GLubyte const* extensions) {
    mVendor = (char const*)vendor;
    mRenderer = (char const*)renderer;
    mVersion = (char const*)version;
@@ -57,8 +50,7 @@ void GLExtensions::initWithGLStrings(
    }
}

bool GLExtensions::hasExtension(char const* extension) const
{
bool GLExtensions::hasExtension(char const* extension) const {
    const String8 s(extension);
    return mExtensionList.indexOf(s) >= 0;
}
+7 −15
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@
#include <stdint.h>
#include <sys/types.h>

#include <utils/String8.h>
#include <utils/SortedVector.h>
#include <utils/Singleton.h>
#include <utils/SortedVector.h>
#include <utils/String8.h>

#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -32,8 +32,7 @@
namespace android {
// ---------------------------------------------------------------------------

class GLExtensions : public Singleton<GLExtensions>
{
class GLExtensions : public Singleton<GLExtensions> {
    friend class Singleton<GLExtensions>;

    bool mHaveFramebufferObject : 1;
@@ -51,15 +50,9 @@ protected:
    GLExtensions();

public:
    inline bool haveFramebufferObject() const { return mHaveFramebufferObject; }

    inline bool haveFramebufferObject() const {
        return mHaveFramebufferObject;
    }

    void initWithGLStrings(
            GLubyte const* vendor,
            GLubyte const* renderer,
            GLubyte const* version,
    void initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer, GLubyte const* version,
                           GLubyte const* extensions);

    char const* getVendor() const;
@@ -70,7 +63,6 @@ public:
    bool hasExtension(char const* extension) const;
};


// ---------------------------------------------------------------------------
}; // namespace android

Loading