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

Commit 904113b5 authored by John Reck's avatar John Reck Committed by android-build-merger
Browse files

Fix all LA memory leaks forever! am: 7df9ff2a

am: b223af93

* commit 'b223af93':
  Fix all LA memory leaks forever!
parents 5877e38d b223af93
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ public:
    static BakedOpState* tryConstruct(LinearAllocator& allocator,
            Snapshot& snapshot, const RecordedOp& recordedOp) {
        if (CC_UNLIKELY(snapshot.getRenderTargetClip().isEmpty())) return nullptr;
        BakedOpState* bakedState = new (allocator) BakedOpState(
        BakedOpState* bakedState = allocator.create_trivial<BakedOpState>(
                allocator, snapshot, recordedOp, false);
        if (bakedState->computedState.clippedBounds.isEmpty()) {
            // bounds are empty, so op is rejected
@@ -124,7 +124,7 @@ public:
                ? (recordedOp.paint && recordedOp.paint->getStyle() != SkPaint::kFill_Style)
                : true;

        BakedOpState* bakedState = new (allocator) BakedOpState(
        BakedOpState* bakedState = allocator.create_trivial<BakedOpState>(
                allocator, snapshot, recordedOp, expandForStroke);
        if (bakedState->computedState.clippedBounds.isEmpty()) {
            // bounds are empty, so op is rejected
@@ -140,16 +140,12 @@ public:
        if (CC_UNLIKELY(snapshot.getRenderTargetClip().isEmpty())) return nullptr;

        // clip isn't empty, so construct the op
        return new (allocator) BakedOpState(allocator, snapshot, shadowOpPtr);
        return allocator.create_trivial<BakedOpState>(allocator, snapshot, shadowOpPtr);
    }

    static BakedOpState* directConstruct(LinearAllocator& allocator,
            const ClipRect* clip, const Rect& dstRect, const RecordedOp& recordedOp) {
        return new (allocator) BakedOpState(clip, dstRect, recordedOp);
    }

    static void* operator new(size_t size, LinearAllocator& allocator) {
        return allocator.alloc(size);
        return allocator.create_trivial<BakedOpState>(clip, dstRect, recordedOp);
    }

    // computed state:
@@ -162,6 +158,8 @@ public:
    const RecordedOp* op;

private:
    friend class LinearAllocator;

    BakedOpState(LinearAllocator& allocator, Snapshot& snapshot,
            const RecordedOp& recordedOp, bool expandForStroke)
            : computedState(allocator, snapshot, recordedOp, expandForStroke)
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ struct DirtyStack {
};

DamageAccumulator::DamageAccumulator() {
    mHead = (DirtyStack*) mAllocator.alloc(sizeof(DirtyStack));
    mHead = mAllocator.create_trivial<DirtyStack>();
    memset(mHead, 0, sizeof(DirtyStack));
    // Create a root that we will not pop off
    mHead->prev = mHead;
@@ -78,7 +78,7 @@ void DamageAccumulator::computeCurrentTransform(Matrix4* outMatrix) const {

void DamageAccumulator::pushCommon() {
    if (!mHead->next) {
        DirtyStack* nextFrame = (DirtyStack*) mAllocator.alloc(sizeof(DirtyStack));
        DirtyStack* nextFrame = mAllocator.create_trivial<DirtyStack>();
        nextFrame->next = nullptr;
        nextFrame->prev = mHead;
        mHead->next = nextFrame;
+1 −6
Original line number Diff line number Diff line
@@ -49,11 +49,6 @@ typedef const void* mergeid_t;

class DeferredDisplayState {
public:
    static void* operator new(size_t size) = delete;
    static void* operator new(size_t size, LinearAllocator& allocator) {
        return allocator.alloc(size);
    }

    // global op bounds, mapped by mMatrix to be in screen space coordinates, clipped
    Rect mBounds;

@@ -124,7 +119,7 @@ private:
    DeferredDisplayList(const DeferredDisplayList& other); // disallow copy

    DeferredDisplayState* createState() {
        return new (mAllocator) DeferredDisplayState();
        return mAllocator.create_trivial<DeferredDisplayState>();
    }

    void tryRecycleState(DeferredDisplayState* state) {
+2 −3
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ private:
    inline const T* refBuffer(const T* srcBuffer, int32_t count) {
        if (!srcBuffer) return nullptr;

        T* dstBuffer = (T*) mDisplayList->allocator.alloc(count * sizeof(T));
        T* dstBuffer = (T*) mDisplayList->allocator.alloc<T>(count * sizeof(T));
        memcpy(dstBuffer, srcBuffer, count * sizeof(T));
        return dstBuffer;
    }
@@ -320,8 +320,7 @@ private:
        // correctly, such as creating the bitmap from scratch, drawing with it, changing its
        // contents, and drawing again. The only fix would be to always copy it the first time,
        // which doesn't seem worth the extra cycles for this unlikely case.
        SkBitmap* localBitmap = new (alloc()) SkBitmap(bitmap);
        alloc().autoDestroy(localBitmap);
        SkBitmap* localBitmap = alloc().create<SkBitmap>(bitmap);
        mDisplayList->bitmapResources.push_back(localBitmap);
        return localBitmap;
    }
+3 −1
Original line number Diff line number Diff line
@@ -64,7 +64,9 @@ public:
    static void operator delete(void* ptr) { LOG_ALWAYS_FATAL("delete not supported"); }
    static void* operator new(size_t size) = delete; /** PURPOSELY OMITTED **/
    static void* operator new(size_t size, LinearAllocator& allocator) {
        return allocator.alloc(size);
        // FIXME: Quick hack to keep old pipeline working, delete this when
        // we no longer need to support HWUI_NEWOPS := false
        return allocator.alloc<char>(size);
    }

    enum OpLogFlag {
Loading