Loading libs/hwui/LayerBuilder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -239,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<Vertex>(vertCount * sizeof(Vertex)); Vertex* const verts = (Vertex*) allocator.create_trivial_array<Vertex>(vertCount); Vertex* currentVert = verts; Rect bounds = mClearRects[0]; Loading libs/hwui/RecordingCanvas.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,7 @@ void RecordingCanvas::drawRect(float left, float top, float right, float bottom, void RecordingCanvas::drawSimpleRects(const float* rects, int vertexCount, const SkPaint* paint) { if (rects == nullptr) return; Vertex* rectData = (Vertex*) mDisplayList->allocator.alloc<Vertex>(vertexCount * sizeof(Vertex)); Vertex* rectData = (Vertex*) mDisplayList->allocator.create_trivial_array<Vertex>(vertexCount); Vertex* vertex = rectData; float left = FLT_MAX; Loading libs/hwui/Snapshot.h +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ namespace uirenderer { */ class RoundRectClipState { public: /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/ static void* operator new(size_t size) = delete; static void* operator new(size_t size, LinearAllocator& allocator) { return allocator.alloc<RoundRectClipState>(size); } Loading @@ -65,7 +65,7 @@ public: class ProjectionPathMask { public: /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/ static void* operator new(size_t size) = delete; static void* operator new(size_t size, LinearAllocator& allocator) { return allocator.alloc<ProjectionPathMask>(size); } Loading libs/hwui/utils/LinearAllocator.h +7 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,13 @@ public: return new (allocImpl(sizeof(T))) T(std::forward<Params>(params)...); } template<class T> T* create_trivial_array(int count) { static_assert(std::is_trivially_destructible<T>::value, "Error, called create_trivial_array on a non-trivial type"); return reinterpret_cast<T*>(allocImpl(sizeof(T) * count)); } /** * Attempt to deallocate the given buffer, with the LinearAllocator attempting to rewind its * state if possible. Loading Loading
libs/hwui/LayerBuilder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -239,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<Vertex>(vertCount * sizeof(Vertex)); Vertex* const verts = (Vertex*) allocator.create_trivial_array<Vertex>(vertCount); Vertex* currentVert = verts; Rect bounds = mClearRects[0]; Loading
libs/hwui/RecordingCanvas.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,7 @@ void RecordingCanvas::drawRect(float left, float top, float right, float bottom, void RecordingCanvas::drawSimpleRects(const float* rects, int vertexCount, const SkPaint* paint) { if (rects == nullptr) return; Vertex* rectData = (Vertex*) mDisplayList->allocator.alloc<Vertex>(vertexCount * sizeof(Vertex)); Vertex* rectData = (Vertex*) mDisplayList->allocator.create_trivial_array<Vertex>(vertexCount); Vertex* vertex = rectData; float left = FLT_MAX; Loading
libs/hwui/Snapshot.h +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ namespace uirenderer { */ class RoundRectClipState { public: /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/ static void* operator new(size_t size) = delete; static void* operator new(size_t size, LinearAllocator& allocator) { return allocator.alloc<RoundRectClipState>(size); } Loading @@ -65,7 +65,7 @@ public: class ProjectionPathMask { public: /** static void* operator new(size_t size); PURPOSELY OMITTED, allocator only **/ static void* operator new(size_t size) = delete; static void* operator new(size_t size, LinearAllocator& allocator) { return allocator.alloc<ProjectionPathMask>(size); } Loading
libs/hwui/utils/LinearAllocator.h +7 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,13 @@ public: return new (allocImpl(sizeof(T))) T(std::forward<Params>(params)...); } template<class T> T* create_trivial_array(int count) { static_assert(std::is_trivially_destructible<T>::value, "Error, called create_trivial_array on a non-trivial type"); return reinterpret_cast<T*>(allocImpl(sizeof(T) * count)); } /** * Attempt to deallocate the given buffer, with the LinearAllocator attempting to rewind its * state if possible. Loading