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

Commit 20c825ae authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Fix createLut in ColorSpace.

Previously createLut returns unique_ptr<float3>, which calls delete when it's
destroyed. However, the actual allocation happens using new float3[size * size
* size], which should cal delete [] when it's destroyed. This patch changes the
type to float3[] such that delete [] is called when it's destroyed.

BUG: 112717608
Test: N/A
Change-Id: Ida0671e33c0659c31d599eacc12fffbe35923876
parent b2069eba
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -351,13 +351,12 @@ const ColorSpace ColorSpace::ACEScg() {
    };
}

std::unique_ptr<float3> ColorSpace::createLUT(uint32_t size,
        const ColorSpace& src, const ColorSpace& dst) {

std::unique_ptr<float3[]> ColorSpace::createLUT(uint32_t size, const ColorSpace& src,
                                                const ColorSpace& dst) {
    size = clamp(size, 2u, 256u);
    float m = 1.0f / float(size - 1);

    std::unique_ptr<float3> lut(new float3[size * size * size]);
    std::unique_ptr<float3[]> lut(new float3[size * size * size]);
    float3* data = lut.get();

    ColorSpaceConnector connector(src, dst);
+2 −2
Original line number Diff line number Diff line
@@ -250,8 +250,8 @@ public:
    // axis is thus already flipped
    // The source color space must define its values in the domain [0..1]
    // The generated LUT transforms from gamma space to gamma space
    static std::unique_ptr<float3> createLUT(uint32_t size,
            const ColorSpace& src, const ColorSpace& dst);
    static std::unique_ptr<float3[]> createLUT(uint32_t size, const ColorSpace& src,
                                               const ColorSpace& dst);

private:
    static constexpr mat3 computeXYZMatrix(