summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/binder/MemoryHeapPmem.h79
-rw-r--r--include/utils/Vector.h4
-rw-r--r--libs/binder/Android.mk1
-rw-r--r--libs/binder/MemoryHeapPmem.cpp248
-rw-r--r--libs/binder/ProcessState.cpp4
-rw-r--r--libs/gui/BufferQueue.cpp1
-rw-r--r--libs/ui/GraphicBufferAllocator.cpp4
-rw-r--r--libs/ui/GraphicBufferMapper.cpp6
-rw-r--r--libs/utils/BlobCache.cpp4
-rw-r--r--libs/utils/Debug.cpp2
-rw-r--r--libs/utils/Static.cpp4
-rw-r--r--libs/utils/StopWatch.cpp8
-rw-r--r--services/surfaceflinger/EventThread.cpp4
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp7
14 files changed, 37 insertions, 339 deletions
diff --git a/include/binder/MemoryHeapPmem.h b/include/binder/MemoryHeapPmem.h
deleted file mode 100644
index e1660c4..0000000
--- a/include/binder/MemoryHeapPmem.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_MEMORY_HEAP_PMEM_H
-#define ANDROID_MEMORY_HEAP_PMEM_H
-
-#include <stdlib.h>
-#include <stdint.h>
-
-#include <binder/MemoryHeapBase.h>
-#include <binder/IMemory.h>
-#include <utils/SortedVector.h>
-#include <utils/threads.h>
-
-namespace android {
-
-class MemoryHeapBase;
-
-// ---------------------------------------------------------------------------
-
-class MemoryHeapPmem : public MemoryHeapBase
-{
-public:
- class MemoryPmem : public BnMemory {
- public:
- MemoryPmem(const sp<MemoryHeapPmem>& heap);
- ~MemoryPmem();
- protected:
- const sp<MemoryHeapPmem>& getHeap() const { return mClientHeap; }
- private:
- friend class MemoryHeapPmem;
- virtual void revoke() = 0;
- sp<MemoryHeapPmem> mClientHeap;
- };
-
- MemoryHeapPmem(const sp<MemoryHeapBase>& pmemHeap, uint32_t flags = 0);
- ~MemoryHeapPmem();
-
- /* HeapInterface additions */
- virtual sp<IMemory> mapMemory(size_t offset, size_t size);
-
- /* make the whole heap visible (you know who you are) */
- virtual status_t slap();
-
- /* hide (revoke) the whole heap (the client will see the garbage page) */
- virtual status_t unslap();
-
- /* revoke all allocations made by this heap */
- virtual void revoke();
-
-private:
- /* use this to create your own IMemory for mapMemory */
- virtual sp<MemoryPmem> createMemory(size_t offset, size_t size);
- void remove(const wp<MemoryPmem>& memory);
-
-private:
- sp<MemoryHeapBase> mParentHeap;
- mutable Mutex mLock;
- SortedVector< wp<MemoryPmem> > mAllocations;
-};
-
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-
-#endif // ANDROID_MEMORY_HEAP_PMEM_H
diff --git a/include/utils/Vector.h b/include/utils/Vector.h
index b908e2a..5b5296b 100644
--- a/include/utils/Vector.h
+++ b/include/utils/Vector.h
@@ -186,8 +186,8 @@ public:
inline const_iterator end() const { return array() + size(); }
inline void reserve(size_t n) { setCapacity(n); }
inline bool empty() const{ return isEmpty(); }
- inline void push_back(const TYPE& item) { insertAt(item, size()); }
- inline void push_front(const TYPE& item) { insertAt(item, 0); }
+ inline void push_back(const TYPE& item) { insertAt(item, size(), 1); }
+ inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
inline iterator erase(iterator pos) {
return begin() + removeItemsAt(pos-array());
}
diff --git a/libs/binder/Android.mk b/libs/binder/Android.mk
index fd116b7..d449298 100644
--- a/libs/binder/Android.mk
+++ b/libs/binder/Android.mk
@@ -24,7 +24,6 @@ sources := \
MemoryDealer.cpp \
MemoryBase.cpp \
MemoryHeapBase.cpp \
- MemoryHeapPmem.cpp \
Parcel.cpp \
PermissionCache.cpp \
ProcessState.cpp \
diff --git a/libs/binder/MemoryHeapPmem.cpp b/libs/binder/MemoryHeapPmem.cpp
deleted file mode 100644
index 66bcf4d..0000000
--- a/libs/binder/MemoryHeapPmem.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "MemoryHeapPmem"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-
-#include <cutils/log.h>
-
-#include <binder/MemoryHeapPmem.h>
-#include <binder/MemoryHeapBase.h>
-
-#ifdef HAVE_ANDROID_OS
-#include <linux/android_pmem.h>
-#endif
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-MemoryHeapPmem::MemoryPmem::MemoryPmem(const sp<MemoryHeapPmem>& heap)
- : BnMemory(), mClientHeap(heap)
-{
-}
-
-MemoryHeapPmem::MemoryPmem::~MemoryPmem() {
- if (mClientHeap != NULL) {
- mClientHeap->remove(this);
- }
-}
-
-// ---------------------------------------------------------------------------
-
-class SubRegionMemory : public MemoryHeapPmem::MemoryPmem {
-public:
- SubRegionMemory(const sp<MemoryHeapPmem>& heap, ssize_t offset, size_t size);
- virtual ~SubRegionMemory();
- virtual sp<IMemoryHeap> getMemory(ssize_t* offset, size_t* size) const;
-private:
- friend class MemoryHeapPmem;
- void revoke();
- size_t mSize;
- ssize_t mOffset;
-};
-
-SubRegionMemory::SubRegionMemory(const sp<MemoryHeapPmem>& heap,
- ssize_t offset, size_t size)
- : MemoryHeapPmem::MemoryPmem(heap), mSize(size), mOffset(offset)
-{
-#ifndef NDEBUG
- void* const start_ptr = (void*)(intptr_t(getHeap()->base()) + offset);
- memset(start_ptr, 0xda, size);
-#endif
-
-#ifdef HAVE_ANDROID_OS
- if (size > 0) {
- const size_t pagesize = getpagesize();
- size = (size + pagesize-1) & ~(pagesize-1);
- int our_fd = heap->heapID();
- struct pmem_region sub = { offset, size };
- int err = ioctl(our_fd, PMEM_MAP, &sub);
- ALOGE_IF(err<0, "PMEM_MAP failed (%s), "
- "mFD=%d, sub.offset=%lu, sub.size=%lu",
- strerror(errno), our_fd, sub.offset, sub.len);
-}
-#endif
-}
-
-sp<IMemoryHeap> SubRegionMemory::getMemory(ssize_t* offset, size_t* size) const
-{
- if (offset) *offset = mOffset;
- if (size) *size = mSize;
- return getHeap();
-}
-
-SubRegionMemory::~SubRegionMemory()
-{
- revoke();
-}
-
-
-void SubRegionMemory::revoke()
-{
- // NOTE: revoke() doesn't need to be protected by a lock because it
- // can only be called from MemoryHeapPmem::revoke(), which means
- // that we can't be in ~SubRegionMemory(), or in ~SubRegionMemory(),
- // which means MemoryHeapPmem::revoke() wouldn't have been able to
- // promote() it.
-
-#ifdef HAVE_ANDROID_OS
- if (mSize != 0) {
- const sp<MemoryHeapPmem>& heap(getHeap());
- int our_fd = heap->heapID();
- struct pmem_region sub;
- sub.offset = mOffset;
- sub.len = mSize;
- int err = ioctl(our_fd, PMEM_UNMAP, &sub);
- ALOGE_IF(err<0, "PMEM_UNMAP failed (%s), "
- "mFD=%d, sub.offset=%lu, sub.size=%lu",
- strerror(errno), our_fd, sub.offset, sub.len);
- mSize = 0;
- }
-#endif
-}
-
-// ---------------------------------------------------------------------------
-
-MemoryHeapPmem::MemoryHeapPmem(const sp<MemoryHeapBase>& pmemHeap,
- uint32_t flags)
- : MemoryHeapBase()
-{
- char const * const device = pmemHeap->getDevice();
-#ifdef HAVE_ANDROID_OS
- if (device) {
- int fd = open(device, O_RDWR | (flags & NO_CACHING ? O_SYNC : 0));
- ALOGE_IF(fd<0, "couldn't open %s (%s)", device, strerror(errno));
- if (fd >= 0) {
- int err = ioctl(fd, PMEM_CONNECT, pmemHeap->heapID());
- if (err < 0) {
- ALOGE("PMEM_CONNECT failed (%s), mFD=%d, sub-fd=%d",
- strerror(errno), fd, pmemHeap->heapID());
- close(fd);
- } else {
- // everything went well...
- mParentHeap = pmemHeap;
- MemoryHeapBase::init(fd,
- pmemHeap->getBase(),
- pmemHeap->getSize(),
- pmemHeap->getFlags() | flags,
- device);
- }
- }
- }
-#else
- mParentHeap = pmemHeap;
- MemoryHeapBase::init(
- dup(pmemHeap->heapID()),
- pmemHeap->getBase(),
- pmemHeap->getSize(),
- pmemHeap->getFlags() | flags,
- device);
-#endif
-}
-
-MemoryHeapPmem::~MemoryHeapPmem()
-{
-}
-
-sp<IMemory> MemoryHeapPmem::mapMemory(size_t offset, size_t size)
-{
- sp<MemoryPmem> memory = createMemory(offset, size);
- if (memory != 0) {
- Mutex::Autolock _l(mLock);
- mAllocations.add(memory);
- }
- return memory;
-}
-
-sp<MemoryHeapPmem::MemoryPmem> MemoryHeapPmem::createMemory(
- size_t offset, size_t size)
-{
- sp<SubRegionMemory> memory;
- if (heapID() > 0)
- memory = new SubRegionMemory(this, offset, size);
- return memory;
-}
-
-status_t MemoryHeapPmem::slap()
-{
-#ifdef HAVE_ANDROID_OS
- size_t size = getSize();
- const size_t pagesize = getpagesize();
- size = (size + pagesize-1) & ~(pagesize-1);
- int our_fd = getHeapID();
- struct pmem_region sub = { 0, size };
- int err = ioctl(our_fd, PMEM_MAP, &sub);
- ALOGE_IF(err<0, "PMEM_MAP failed (%s), "
- "mFD=%d, sub.offset=%lu, sub.size=%lu",
- strerror(errno), our_fd, sub.offset, sub.len);
- return -errno;
-#else
- return NO_ERROR;
-#endif
-}
-
-status_t MemoryHeapPmem::unslap()
-{
-#ifdef HAVE_ANDROID_OS
- size_t size = getSize();
- const size_t pagesize = getpagesize();
- size = (size + pagesize-1) & ~(pagesize-1);
- int our_fd = getHeapID();
- struct pmem_region sub = { 0, size };
- int err = ioctl(our_fd, PMEM_UNMAP, &sub);
- ALOGE_IF(err<0, "PMEM_UNMAP failed (%s), "
- "mFD=%d, sub.offset=%lu, sub.size=%lu",
- strerror(errno), our_fd, sub.offset, sub.len);
- return -errno;
-#else
- return NO_ERROR;
-#endif
-}
-
-void MemoryHeapPmem::revoke()
-{
- SortedVector< wp<MemoryPmem> > allocations;
-
- { // scope for lock
- Mutex::Autolock _l(mLock);
- allocations = mAllocations;
- }
-
- ssize_t count = allocations.size();
- for (ssize_t i=0 ; i<count ; i++) {
- sp<MemoryPmem> memory(allocations[i].promote());
- if (memory != 0)
- memory->revoke();
- }
-}
-
-void MemoryHeapPmem::remove(const wp<MemoryPmem>& memory)
-{
- Mutex::Autolock _l(mLock);
- mAllocations.remove(memory);
-}
-
-// ---------------------------------------------------------------------------
-}; // namespace android
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index f96fe50..9fa412c 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -286,8 +286,8 @@ void ProcessState::spawnPooledThread(bool isMain)
{
if (mThreadPoolStarted) {
int32_t s = android_atomic_add(1, &mThreadPoolSeq);
- char buf[32];
- sprintf(buf, "Binder Thread #%d", s);
+ char buf[16];
+ snprintf(buf, sizeof(buf), "Binder_%X", s);
ALOGV("Spawning new pooled thread, name=%s\n", buf);
sp<Thread> t = new PoolThread(isMain);
t->run(buf);
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index d761680..f0641e0 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -828,6 +828,7 @@ status_t BufferQueue::acquire(BufferItem *buffer) {
buffer->mTransform = mSlots[buf].mTransform;
buffer->mScalingMode = mSlots[buf].mScalingMode;
buffer->mFrameNumber = mSlots[buf].mFrameNumber;
+ buffer->mTimestamp = mSlots[buf].mTimestamp;
buffer->mBuf = buf;
mSlots[buf].mAcquireCalled = true;
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index d344737..ff550d9 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -16,11 +16,13 @@
*/
#define LOG_TAG "GraphicBufferAllocator"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <cutils/log.h>
#include <utils/Singleton.h>
#include <utils/String8.h>
+#include <utils/Trace.h>
#include <ui/GraphicBufferAllocator.h>
@@ -91,6 +93,7 @@ void GraphicBufferAllocator::dumpToSystemLog()
status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format,
int usage, buffer_handle_t* handle, int32_t* stride)
{
+ ATRACE_CALL();
// make sure to not allocate a N x 0 or 0 x N buffer, since this is
// allowed from an API stand-point allocate a 1x1 buffer instead.
if (!w || !h)
@@ -128,6 +131,7 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma
status_t GraphicBufferAllocator::free(buffer_handle_t handle)
{
+ ATRACE_CALL();
status_t err;
err = mAllocDev->free(mAllocDev, handle);
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index b173c85..967da98 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -15,12 +15,14 @@
*/
#define LOG_TAG "GraphicBufferMapper"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <stdint.h>
#include <errno.h>
#include <utils/Errors.h>
#include <utils/Log.h>
+#include <utils/Trace.h>
#include <ui/GraphicBufferMapper.h>
#include <ui/Rect.h>
@@ -46,6 +48,7 @@ GraphicBufferMapper::GraphicBufferMapper()
status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle)
{
+ ATRACE_CALL();
status_t err;
err = mAllocMod->registerBuffer(mAllocMod, handle);
@@ -57,6 +60,7 @@ status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle)
status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle)
{
+ ATRACE_CALL();
status_t err;
err = mAllocMod->unregisterBuffer(mAllocMod, handle);
@@ -69,6 +73,7 @@ status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle)
status_t GraphicBufferMapper::lock(buffer_handle_t handle,
int usage, const Rect& bounds, void** vaddr)
{
+ ATRACE_CALL();
status_t err;
err = mAllocMod->lock(mAllocMod, handle, usage,
@@ -81,6 +86,7 @@ status_t GraphicBufferMapper::lock(buffer_handle_t handle,
status_t GraphicBufferMapper::unlock(buffer_handle_t handle)
{
+ ATRACE_CALL();
status_t err;
err = mAllocMod->unlock(mAllocMod, handle);
diff --git a/libs/utils/BlobCache.cpp b/libs/utils/BlobCache.cpp
index e52cf2f..be398ee 100644
--- a/libs/utils/BlobCache.cpp
+++ b/libs/utils/BlobCache.cpp
@@ -183,7 +183,7 @@ size_t BlobCache::getFdCount() const {
status_t BlobCache::flatten(void* buffer, size_t size, int fds[], size_t count)
const {
if (count != 0) {
- ALOGE("flatten: nonzero fd count: %d", count);
+ ALOGE("flatten: nonzero fd count: %zu", count);
return BAD_VALUE;
}
@@ -234,7 +234,7 @@ status_t BlobCache::unflatten(void const* buffer, size_t size, int fds[],
mCacheEntries.clear();
if (count != 0) {
- ALOGE("unflatten: nonzero fd count: %d", count);
+ ALOGE("unflatten: nonzero fd count: %zu", count);
return BAD_VALUE;
}
diff --git a/libs/utils/Debug.cpp b/libs/utils/Debug.cpp
index f7988ec..e8ac983 100644
--- a/libs/utils/Debug.cpp
+++ b/libs/utils/Debug.cpp
@@ -199,7 +199,7 @@ void printHexData(int32_t indent, const void *buf, size_t length,
if ((int32_t)length < 0) {
if (singleLineBytesCutoff < 0) func(cookie, "\n");
char buf[64];
- sprintf(buf, "(bad length: %d)", length);
+ sprintf(buf, "(bad length: %zu)", length);
func(cookie, buf);
return;
}
diff --git a/libs/utils/Static.cpp b/libs/utils/Static.cpp
index bfcb2da..624e917 100644
--- a/libs/utils/Static.cpp
+++ b/libs/utils/Static.cpp
@@ -57,8 +57,8 @@ protected:
virtual status_t writeLines(const struct iovec& vec, size_t N)
{
//android_writevLog(&vec, N); <-- this is now a no-op
- if (N != 1) ALOGI("WARNING: writeLines N=%d\n", N);
- ALOGI("%.*s", vec.iov_len, (const char*) vec.iov_base);
+ if (N != 1) ALOGI("WARNING: writeLines N=%zu\n", N);
+ ALOGI("%.*s", (int)vec.iov_len, (const char*) vec.iov_base);
return NO_ERROR;
}
};
diff --git a/libs/utils/StopWatch.cpp b/libs/utils/StopWatch.cpp
index 595aec3..b1708d6 100644
--- a/libs/utils/StopWatch.cpp
+++ b/libs/utils/StopWatch.cpp
@@ -20,6 +20,10 @@
#include <stdlib.h>
#include <stdio.h>
+/* for PRId64 */
+#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>
+
#include <utils/Log.h>
#include <utils/Errors.h>
#include <utils/StopWatch.h>
@@ -39,11 +43,11 @@ StopWatch::~StopWatch()
{
nsecs_t elapsed = elapsedTime();
const int n = mNumLaps;
- ALOGD("StopWatch %s (us): %lld ", mName, ns2us(elapsed));
+ ALOGD("StopWatch %s (us): %" PRId64 " ", mName, ns2us(elapsed));
for (int i=0 ; i<n ; i++) {
const nsecs_t soFar = mLaps[i].soFar;
const nsecs_t thisLap = mLaps[i].thisLap;
- ALOGD(" [%d: %lld, %lld]", i, ns2us(soFar), ns2us(thisLap));
+ ALOGD(" [%d: %" PRId64 ", %" PRId64, i, ns2us(soFar), ns2us(thisLap));
}
}
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index af0da0b..3c045d7 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+
#include <stdint.h>
#include <sys/types.h>
@@ -21,6 +23,7 @@
#include <gui/DisplayEventReceiver.h>
#include <utils/Errors.h>
+#include <utils/Trace.h>
#include "DisplayHardware/DisplayHardware.h"
#include "DisplayEventConnection.h"
@@ -146,6 +149,7 @@ bool EventThread::threadLoop() {
// at least one listener requested VSYNC
mLock.unlock();
timestamp = mHw.waitForRefresh();
+ ATRACE_INT("VSYNC", mDeliveredEvents&1);
mLock.lock();
mDeliveredEvents++;
mLastVSyncTimestamp = timestamp;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 42ed4fa..7f61fe4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -460,6 +460,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what)
void SurfaceFlinger::postFramebuffer()
{
+ ATRACE_CALL();
// mSwapRegion can be empty here is some cases, for instance if a hidden
// or fully transparent window is updating.
// in that case, we need to flip anyways to not risk a deadlock with
@@ -504,6 +505,8 @@ void SurfaceFlinger::handleConsoleEvents()
void SurfaceFlinger::handleTransaction(uint32_t transactionFlags)
{
+ ATRACE_CALL();
+
Mutex::Autolock _l(mStateLock);
const nsecs_t now = systemTime();
mDebugInTransaction = now;
@@ -601,6 +604,8 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
void SurfaceFlinger::computeVisibleRegions(
const LayerVector& currentLayers, Region& dirtyRegion, Region& opaqueRegion)
{
+ ATRACE_CALL();
+
const GraphicPlane& plane(graphicPlane(0));
const Transform& planeTransform(plane.transform());
const DisplayHardware& hw(plane.displayHardware());
@@ -841,6 +846,8 @@ void SurfaceFlinger::handleWorkList()
void SurfaceFlinger::handleRepaint()
{
+ ATRACE_CALL();
+
// compute the invalid region
mSwapRegion.orSelf(mDirtyRegion);