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

Commit d1f74d0e authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Don't use the MemoryDealer in CursorWindow, it's not necessary.

instead use a MemoryHeapBase and MemoryBase directly.
parent 239d5b36
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
#define LOG_TAG "CursorWindow"

#include <utils/Log.h>
#include <binder/MemoryDealer.h>
#include <binder/MemoryHeapBase.h>
#include <binder/MemoryBase.h>

#include <assert.h>
#include <string.h>
@@ -37,7 +38,7 @@ CursorWindow::CursorWindow(size_t maxSize) :
{
}

bool CursorWindow::setMemory(sp<IMemory> memory)     
bool CursorWindow::setMemory(const sp<IMemory>& memory)
{
    mMemory = memory;
    mData = (uint8_t *) memory->pointer();
@@ -47,7 +48,6 @@ bool CursorWindow::setMemory(sp<IMemory> memory)
    mHeader = (window_header_t *) mData;

    // Make the window read-only
    mHeap = NULL;
    ssize_t size = memory->size();
    mSize = size;
    mMaxSize = size;
@@ -60,9 +60,10 @@ bool CursorWindow::initBuffer(bool localOnly)
{
    //TODO Use a non-memory dealer mmap region for localOnly

    mHeap = new MemoryDealer(mMaxSize, "CursorWindow");
    if (mHeap != NULL) {
        mMemory = mHeap->allocate(mMaxSize);
    sp<MemoryHeapBase> heap;
    heap = new MemoryHeapBase(mMaxSize, 0, "CursorWindow");
    if (heap != NULL) {
        mMemory = new MemoryBase(heap, 0, mMaxSize);
        if (mMemory != NULL) {
            mData = (uint8_t *) mMemory->pointer();
            if (mData) {
@@ -75,10 +76,10 @@ bool CursorWindow::initBuffer(bool localOnly)
                return true;                
            }
        } 
        LOGE("memory dealer allocation failed");
        LOGE("CursorWindow heap allocation failed");
        return false;
    } else {
        LOGE("failed to create the memory dealer");
        LOGE("failed to create the CursorWindow heap");
        return false;
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
#include <stddef.h>
#include <stdint.h>

#include <binder/MemoryDealer.h>
#include <binder/IMemory.h>
#include <utils/RefBase.h>

#include <jni.h>
@@ -101,7 +101,7 @@ class CursorWindow
public:
                        CursorWindow(size_t maxSize);
                        CursorWindow(){}
    bool                setMemory(sp<IMemory>);
    bool                setMemory(const sp<IMemory>&);
                        ~CursorWindow();

    bool                initBuffer(bool localOnly);
@@ -189,7 +189,6 @@ private:
    size_t mSize;
    size_t mMaxSize;
    window_header_t * mHeader;
    sp<MemoryDealer> mHeap;
    sp<IMemory> mMemory;

    /**