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

Commit 03d3181b authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge changes I7c7dc150,Ib0328903 into main

* changes:
  Remove extra layering of HDR capabilities on top of HWC
  Remove Y410 fields from SurfaceFlinger
parents 4e5f5b29 c6aced20
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -1251,7 +1251,6 @@ void GLESRenderEngine::drawLayersInternal(
            texture.setFiltering(layer.source.buffer.useTextureFiltering);

            texture.setDimensions(gBuf->getWidth(), gBuf->getHeight());
            setSourceY410BT2020(layer.source.buffer.isY410BT2020);

            renderengine::Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>());
            texCoords[0] = vec2(0.0, 0.0);
@@ -1294,7 +1293,6 @@ void GLESRenderEngine::drawLayersInternal(
        // Cleanup if there's a buffer source
        if (layer.source.buffer.buffer != nullptr) {
            disableBlending();
            setSourceY410BT2020(false);
            disableTexturing();
        }
    }
@@ -1357,10 +1355,6 @@ void GLESRenderEngine::setupLayerBlending(bool premultipliedAlpha, bool opaque,
    }
}

void GLESRenderEngine::setSourceY410BT2020(bool enable) {
    mState.isY410BT2020 = enable;
}

void GLESRenderEngine::setSourceDataSpace(Dataspace source) {
    mDataSpace = source;
}
+0 −1
Original line number Diff line number Diff line
@@ -183,7 +183,6 @@ private:
    void setupCornerRadiusCropSize(float width, float height);

    // HDR and color management related functions and state
    void setSourceY410BT2020(bool enable);
    void setSourceDataSpace(ui::Dataspace source);
    void setOutputDataSpace(ui::Dataspace dataspace);
    void setDisplayMaxLuminance(const float maxLuminance);
+4 −28
Original line number Diff line number Diff line
@@ -98,9 +98,6 @@ void ProgramCache::primeCache(
            shaderKey.set(Key::INPUT_TF_MASK, (i & 1) ?
                    Key::INPUT_TF_HLG : Key::INPUT_TF_ST2084);

            // Cache Y410 input on or off
            shaderKey.set(Key::Y410_BT2020_MASK, (i & 2) ?
                    Key::Y410_BT2020_ON : Key::Y410_BT2020_OFF);
            if (cache.count(shaderKey) == 0) {
                cache.emplace(shaderKey, generateProgram(shaderKey));
                shaderCount++;
@@ -161,12 +158,10 @@ void ProgramCache::primeCache(
ProgramCache::Key ProgramCache::computeKey(const Description& description) {
    Key needs;
    needs.set(Key::TEXTURE_MASK,
              !description.textureEnabled
                      ? Key::TEXTURE_OFF
              !description.textureEnabled ? Key::TEXTURE_OFF
                      : description.texture.getTextureTarget() == GL_TEXTURE_EXTERNAL_OES
                      ? Key::TEXTURE_EXT
                              : description.texture.getTextureTarget() == GL_TEXTURE_2D
                                      ? Key::TEXTURE_2D
                      : description.texture.getTextureTarget() == GL_TEXTURE_2D ? Key::TEXTURE_2D
                                                                                : Key::TEXTURE_OFF)
            .set(Key::ALPHA_MASK, (description.color.a < 1) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE)
            .set(Key::BLEND_MASK,
@@ -186,8 +181,6 @@ ProgramCache::Key ProgramCache::computeKey(const Description& description) {
            .set(Key::ROUNDED_CORNERS_MASK,
                 description.cornerRadius > 0 ? Key::ROUNDED_CORNERS_ON : Key::ROUNDED_CORNERS_OFF)
            .set(Key::SHADOW_MASK, description.drawShadows ? Key::SHADOW_ON : Key::SHADOW_OFF);
    needs.set(Key::Y410_BT2020_MASK,
              description.isY410BT2020 ? Key::Y410_BT2020_ON : Key::Y410_BT2020_OFF);

    if (needs.hasTransformMatrix() ||
        (description.inputTransferFunction != description.outputTransferFunction)) {
@@ -650,20 +643,6 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
        fs << "uniform vec4 color;";
    }

    if (needs.isY410BT2020()) {
        fs << R"__SHADER__(
            vec3 convertY410BT2020(const vec3 color) {
                const vec3 offset = vec3(0.0625, 0.5, 0.5);
                const mat3 transform = mat3(
                    vec3(1.1678,  1.1678, 1.1678),
                    vec3(   0.0, -0.1878, 2.1481),
                    vec3(1.6836, -0.6523,   0.0));
                // Y is in G, U is in R, and V is in B
                return clamp(transform * (color.grb - offset), 0.0, 1.0);
            }
            )__SHADER__";
    }

    if (needs.hasTransformMatrix() || (needs.getInputTF() != needs.getOutputTF()) ||
        needs.hasDisplayColorMatrix()) {
        if (needs.needsToneMapping()) {
@@ -730,9 +709,6 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
    } else {
        if (needs.isTexturing()) {
            fs << "gl_FragColor = texture2D(sampler, outTexCoords);";
            if (needs.isY410BT2020()) {
                fs << "gl_FragColor.rgb = convertY410BT2020(gl_FragColor.rgb);";
            }
        } else {
            fs << "gl_FragColor.rgb = color.rgb;";
            fs << "gl_FragColor.a = 1.0;";
+0 −6
Original line number Diff line number Diff line
@@ -108,11 +108,6 @@ public:
            OUTPUT_TF_ST2084 = 2 << OUTPUT_TF_SHIFT,
            OUTPUT_TF_HLG = 3 << OUTPUT_TF_SHIFT,

            Y410_BT2020_SHIFT = 12,
            Y410_BT2020_MASK = 1 << Y410_BT2020_SHIFT,
            Y410_BT2020_OFF = 0 << Y410_BT2020_SHIFT,
            Y410_BT2020_ON = 1 << Y410_BT2020_SHIFT,

            SHADOW_SHIFT = 13,
            SHADOW_MASK = 1 << SHADOW_SHIFT,
            SHADOW_OFF = 0 << SHADOW_SHIFT,
@@ -180,7 +175,6 @@ public:
            outputTF >>= Key::OUTPUT_TF_SHIFT;
            return inputTF != outputTF;
        }
        inline bool isY410BT2020() const { return (mKey & Y410_BT2020_MASK) == Y410_BT2020_ON; }

        // for use by std::unordered_map

+1 −6
Original line number Diff line number Diff line
@@ -64,9 +64,6 @@ struct Buffer {
    // overrides the alpha channel of the buffer.
    bool isOpaque = false;

    // HDR color-space setting for Y410.
    bool isY410BT2020 = false;

    float maxLuminanceNits = 0.0;
};

@@ -189,8 +186,7 @@ static inline bool operator==(const Buffer& lhs, const Buffer& rhs) {
            lhs.useTextureFiltering == rhs.useTextureFiltering &&
            lhs.textureTransform == rhs.textureTransform &&
            lhs.usePremultipliedAlpha == rhs.usePremultipliedAlpha &&
            lhs.isOpaque == rhs.isOpaque && lhs.isY410BT2020 == rhs.isY410BT2020 &&
            lhs.maxLuminanceNits == rhs.maxLuminanceNits;
            lhs.isOpaque == rhs.isOpaque && lhs.maxLuminanceNits == rhs.maxLuminanceNits;
}

static inline bool operator==(const Geometry& lhs, const Geometry& rhs) {
@@ -247,7 +243,6 @@ static inline void PrintTo(const Buffer& settings, ::std::ostream* os) {
    PrintMatrix(settings.textureTransform, os);
    *os << "\n    .usePremultipliedAlpha = " << settings.usePremultipliedAlpha;
    *os << "\n    .isOpaque = " << settings.isOpaque;
    *os << "\n    .isY410BT2020 = " << settings.isY410BT2020;
    *os << "\n    .maxLuminanceNits = " << settings.maxLuminanceNits;
    *os << "\n}";
}
Loading