summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-05-17 17:29:52 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-05-17 17:29:52 -0700
commit2b2529f200e251808d7ef3e875cdf6d26d314445 (patch)
tree658ee0c90bc6365abe01f544d5e6a8ff2f792818
parenta8ec4bb6ec15d8edd344b85a5b5a9aa07048601d (diff)
parentcd30f4f849bb215509bd2645726048271b5db01e (diff)
downloadframeworks_base-2b2529f200e251808d7ef3e875cdf6d26d314445.zip
frameworks_base-2b2529f200e251808d7ef3e875cdf6d26d314445.tar.gz
frameworks_base-2b2529f200e251808d7ef3e875cdf6d26d314445.tar.bz2
Merge "fix some bugs in SharedBufferStack::resize" into kraken
-rw-r--r--include/private/surfaceflinger/SharedBufferStack.h9
-rw-r--r--libs/surfaceflinger_client/SharedBufferStack.cpp6
2 files changed, 9 insertions, 6 deletions
diff --git a/include/private/surfaceflinger/SharedBufferStack.h b/include/private/surfaceflinger/SharedBufferStack.h
index c23832d..a1a02e0 100644
--- a/include/private/surfaceflinger/SharedBufferStack.h
+++ b/include/private/surfaceflinger/SharedBufferStack.h
@@ -295,7 +295,8 @@ private:
friend class BufferList;
uint32_t mask, curr;
const_iterator(uint32_t mask) :
- mask(mask), curr(31 - __builtin_clz(mask)) { }
+ mask(mask), curr(__builtin_clz(mask)) {
+ }
public:
inline bool operator == (const const_iterator& rhs) const {
return mask == rhs.mask;
@@ -304,9 +305,9 @@ private:
return mask != rhs.mask;
}
inline int operator *() const { return curr; }
- inline const const_iterator& operator ++(int) {
- mask &= ~curr;
- curr = 31 - __builtin_clz(mask);
+ inline const const_iterator& operator ++() {
+ mask &= ~(1<<(31-curr));
+ curr = __builtin_clz(mask);
return *this;
}
};
diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp
index 4a98026..5705748 100644
--- a/libs/surfaceflinger_client/SharedBufferStack.cpp
+++ b/libs/surfaceflinger_client/SharedBufferStack.cpp
@@ -560,6 +560,7 @@ status_t SharedBufferServer::resize(int newNumBuffers)
int base = numBuffers;
int32_t avail = stack.available;
int tail = head - avail + 1;
+
if (tail >= 0) {
int8_t* const index = const_cast<int8_t*>(stack.index);
const int nb = numBuffers - head;
@@ -573,8 +574,9 @@ status_t SharedBufferServer::resize(int newNumBuffers)
// fill the new free space with unused buffers
BufferList::const_iterator curr(mBufferList.free_begin());
for (int i=0 ; i<extra ; i++) {
- stack.index[base+i] = *curr++;
- mBufferList.add(stack.index[base+i]);
+ stack.index[base+i] = *curr;
+ mBufferList.add(*curr);
+ ++curr;
}
mNumBuffers = newNumBuffers;