Loading core/jni/CursorWindow.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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(); Loading @@ -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; Loading @@ -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) { Loading @@ -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; } } Loading core/jni/CursorWindow.h +2 −3 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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); Loading Loading @@ -189,7 +189,6 @@ private: size_t mSize; size_t mMaxSize; window_header_t * mHeader; sp<MemoryDealer> mHeap; sp<IMemory> mMemory; /** Loading Loading
core/jni/CursorWindow.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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(); Loading @@ -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; Loading @@ -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) { Loading @@ -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; } } Loading
core/jni/CursorWindow.h +2 −3 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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); Loading Loading @@ -189,7 +189,6 @@ private: size_t mSize; size_t mMaxSize; window_header_t * mHeader; sp<MemoryDealer> mHeap; sp<IMemory> mMemory; /** Loading