diff options
| author | 2016-02-10 16:08:08 -0800 | |
|---|---|---|
| committer | 2016-02-10 16:11:26 -0800 | |
| commit | 499d83f21e7ffb687788bba1668b05fe38f6ebaf (patch) | |
| tree | 3323a0a06c5a7a5492aedec8e8ffe7730fd955b0 /libs/hwui/LayerBuilder.cpp | |
| parent | 28d901e53b67bfebe680234aeecfc9b81d56b408 (diff) | |
Fix all LA memory leaks forever!
Bug: 27072626
Or at least fix this one and make it harder to leak
going forward. static_asserts are cool, use them liberally
Also makes allocation via LA (slightly) faster by fixing create*
variants to use rvalue references & std::forward, preventing
an accidental pass-by-value
Change-Id: I5e0e36e72c6dd93324194ebf9a95f8204f05f261
Diffstat (limited to 'libs/hwui/LayerBuilder.cpp')
| -rw-r--r-- | libs/hwui/LayerBuilder.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/libs/hwui/LayerBuilder.cpp b/libs/hwui/LayerBuilder.cpp index 7170d4fbeea7..1ba3bf26c0d4 100644 --- a/libs/hwui/LayerBuilder.cpp +++ b/libs/hwui/LayerBuilder.cpp @@ -64,10 +64,6 @@ protected: class OpBatch : public BatchBase { public: - static void* operator new(size_t size, LinearAllocator& allocator) { - return allocator.alloc(size); - } - OpBatch(batchid_t batchId, BakedOpState* op) : BatchBase(batchId, op, false) { } @@ -80,10 +76,6 @@ public: class MergingOpBatch : public BatchBase { public: - static void* operator new(size_t size, LinearAllocator& allocator) { - return allocator.alloc(size); - } - MergingOpBatch(batchid_t batchId, BakedOpState* op) : BatchBase(batchId, op, true) , mClipSideFlags(op->computedState.clipSideFlags) { @@ -247,7 +239,7 @@ void LayerBuilder::flushLayerClears(LinearAllocator& allocator) { // put the verts in the frame allocator, since // 1) SimpleRectsOps needs verts, not rects // 2) even if mClearRects stored verts, std::vectors will move their contents - Vertex* const verts = (Vertex*) allocator.alloc(vertCount * sizeof(Vertex)); + Vertex* const verts = (Vertex*) allocator.alloc<Vertex>(vertCount * sizeof(Vertex)); Vertex* currentVert = verts; Rect bounds = mClearRects[0]; @@ -264,7 +256,7 @@ void LayerBuilder::flushLayerClears(LinearAllocator& allocator) { // Flush all of these clears with a single draw SkPaint* paint = allocator.create<SkPaint>(); paint->setXfermodeMode(SkXfermode::kClear_Mode); - SimpleRectsOp* op = new (allocator) SimpleRectsOp(bounds, + SimpleRectsOp* op = allocator.create_trivial<SimpleRectsOp>(bounds, Matrix4::identity(), nullptr, paint, verts, vertCount); BakedOpState* bakedState = BakedOpState::directConstruct(allocator, @@ -292,7 +284,7 @@ void LayerBuilder::deferUnmergeableOp(LinearAllocator& allocator, targetBatch->batchOp(op); } else { // new non-merging batch - targetBatch = new (allocator) OpBatch(batchId, op); + targetBatch = allocator.create<OpBatch>(batchId, op); mBatchLookup[batchId] = targetBatch; mBatches.insert(mBatches.begin() + insertBatchIndex, targetBatch); } @@ -323,7 +315,7 @@ void LayerBuilder::deferMergeableOp(LinearAllocator& allocator, targetBatch->mergeOp(op); } else { // new merging batch - targetBatch = new (allocator) MergingOpBatch(batchId, op); + targetBatch = allocator.create<MergingOpBatch>(batchId, op); mMergingBatchLookup[batchId].insert(std::make_pair(mergeId, targetBatch)); mBatches.insert(mBatches.begin() + insertBatchIndex, targetBatch); |