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

Commit e5df2314 authored by Romain Guy's avatar Romain Guy
Browse files

Make sure we correctly copy caches keys.

Bug #5136067

Change-Id: I366e840bef44415436dc7b13d89cfb610feed663
parent 1329192f
Loading
Loading
Loading
Loading
+27 −16
Original line number Diff line number Diff line
@@ -38,28 +38,27 @@ struct GradientCacheEntry {

    GradientCacheEntry(uint32_t* colors, float* positions, int count,
            SkShader::TileMode tileMode) {
        this->count = count;
        this->colors = new uint32_t[count];
        this->positions = new float[count];
        this->tileMode = tileMode;

        memcpy(this->colors, colors, count * sizeof(uint32_t));
        memcpy(this->positions, positions, count * sizeof(float));
        copy(colors, positions, count, tileMode);
    }

    GradientCacheEntry(const GradientCacheEntry& entry) {
        this->count = entry.count;
        this->colors = new uint32_t[count];
        this->positions = new float[count];
        this->tileMode = entry.tileMode;

        memcpy(this->colors, entry.colors, count * sizeof(uint32_t));
        memcpy(this->positions, entry.positions, count * sizeof(float));
        copy(entry.colors, entry.positions, entry.count, entry.tileMode);
    }

    ~GradientCacheEntry() {
        if (colors) delete[] colors;
        if (positions) delete[] positions;
        delete[] colors;
        delete[] positions;
    }

    GradientCacheEntry& operator=(const GradientCacheEntry& entry) {
        if (this != &entry) {
            delete[] colors;
            delete[] positions;

            copy(entry.colors, entry.positions, entry.count, entry.tileMode);
        }

        return *this;
    }

    bool operator<(const GradientCacheEntry& r) const {
@@ -82,6 +81,18 @@ struct GradientCacheEntry {
    int count;
    SkShader::TileMode tileMode;

private:

    void copy(uint32_t* colors, float* positions, int count, SkShader::TileMode tileMode) {
        this->count = count;
        this->colors = new uint32_t[count];
        this->positions = new float[count];
        this->tileMode = tileMode;

        memcpy(this->colors, colors, count * sizeof(uint32_t));
        memcpy(this->positions, positions, count * sizeof(float));
    }

}; // GradientCacheEntry

/**
+0 −4
Original line number Diff line number Diff line
@@ -119,10 +119,6 @@ private:
            mHeight = uint32_t(ceilf(layerHeight / float(LAYER_SIZE)) * LAYER_SIZE);
        }

        LayerEntry(const LayerEntry& entry):
            mLayer(entry.mLayer), mWidth(entry.mWidth), mHeight(entry.mHeight) {
        }

        LayerEntry(Layer* layer):
            mLayer(layer), mWidth(layer->getWidth()), mHeight(layer->getHeight()) {
        }
+0 −7
Original line number Diff line number Diff line
@@ -80,13 +80,6 @@ private:
                emptyCount(emptyCount), colorKey(colorKey) {
        }

        PatchDescription(const PatchDescription& description):
                bitmapWidth(description.bitmapWidth), bitmapHeight(description.bitmapHeight),
                pixelWidth(description.pixelWidth), pixelHeight(description.pixelHeight),
                xCount(description.xCount), yCount(description.yCount),
                emptyCount(description.emptyCount), colorKey(description.colorKey) {
        }

        bool operator<(const PatchDescription& rhs) const {
            LTE_FLOAT(bitmapWidth) {
                LTE_FLOAT(bitmapHeight) {
+0 −4
Original line number Diff line number Diff line
@@ -41,10 +41,6 @@ struct PathCacheEntry: public ShapeCacheEntry {
        path = NULL;
    }

    PathCacheEntry(const PathCacheEntry& entry): ShapeCacheEntry(entry) {
        path = entry.path;
    }

    bool lessThan(const ShapeCacheEntry& r) const {
        const PathCacheEntry& rhs = (const PathCacheEntry&) r;
        LTE_INT(path) {
+0 −40
Original line number Diff line number Diff line
@@ -96,12 +96,6 @@ struct ShapeCacheEntry {
        pathEffect = NULL;
    }

    ShapeCacheEntry(const ShapeCacheEntry& entry):
        shapeType(entry.shapeType), join(entry.join), cap(entry.cap),
        style(entry.style), miter(entry.miter),
        strokeWidth(entry.strokeWidth), pathEffect(entry.pathEffect) {
    }

    ShapeCacheEntry(ShapeType type, SkPaint* paint) {
        shapeType = type;
        join = paint->getStrokeJoin();
@@ -167,14 +161,6 @@ struct RoundRectShapeCacheEntry: public ShapeCacheEntry {
        mRy = 0;
    }

    RoundRectShapeCacheEntry(const RoundRectShapeCacheEntry& entry):
            ShapeCacheEntry(entry) {
        mWidth = entry.mWidth;
        mHeight = entry.mHeight;
        mRx = entry.mRx;
        mRy = entry.mRy;
    }

    bool lessThan(const ShapeCacheEntry& r) const {
        const RoundRectShapeCacheEntry& rhs = (const RoundRectShapeCacheEntry&) r;
        LTE_INT(mWidth) {
@@ -206,11 +192,6 @@ struct CircleShapeCacheEntry: public ShapeCacheEntry {
        mRadius = 0;
    }

    CircleShapeCacheEntry(const CircleShapeCacheEntry& entry):
            ShapeCacheEntry(entry) {
        mRadius = entry.mRadius;
    }

    bool lessThan(const ShapeCacheEntry& r) const {
        const CircleShapeCacheEntry& rhs = (const CircleShapeCacheEntry&) r;
        LTE_INT(mRadius) {
@@ -234,12 +215,6 @@ struct OvalShapeCacheEntry: public ShapeCacheEntry {
        mWidth = mHeight = 0;
    }

    OvalShapeCacheEntry(const OvalShapeCacheEntry& entry):
            ShapeCacheEntry(entry) {
        mWidth = entry.mWidth;
        mHeight = entry.mHeight;
    }

    bool lessThan(const ShapeCacheEntry& r) const {
        const OvalShapeCacheEntry& rhs = (const OvalShapeCacheEntry&) r;
        LTE_INT(mWidth) {
@@ -266,12 +241,6 @@ struct RectShapeCacheEntry: public ShapeCacheEntry {
        mWidth = mHeight = 0;
    }

    RectShapeCacheEntry(const RectShapeCacheEntry& entry):
            ShapeCacheEntry(entry) {
        mWidth = entry.mWidth;
        mHeight = entry.mHeight;
    }

    bool lessThan(const ShapeCacheEntry& r) const {
        const RectShapeCacheEntry& rhs = (const RectShapeCacheEntry&) r;
        LTE_INT(mWidth) {
@@ -306,15 +275,6 @@ struct ArcShapeCacheEntry: public ShapeCacheEntry {
        mUseCenter = 0;
    }

    ArcShapeCacheEntry(const ArcShapeCacheEntry& entry):
            ShapeCacheEntry(entry) {
        mWidth = entry.mWidth;
        mHeight = entry.mHeight;
        mStartAngle = entry.mStartAngle;
        mSweepAngle = entry.mSweepAngle;
        mUseCenter = entry.mUseCenter;
    }

    bool lessThan(const ShapeCacheEntry& r) const {
        const ArcShapeCacheEntry& rhs = (const ArcShapeCacheEntry&) r;
        LTE_INT(mWidth) {