summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gui/SurfaceTextureClient.h16
-rw-r--r--include/utils/ZipFileRO.h15
-rw-r--r--libs/gui/SurfaceTexture.cpp25
-rw-r--r--libs/gui/SurfaceTextureClient.cpp6
-rw-r--r--libs/ui/GraphicBufferAllocator.cpp22
-rw-r--r--libs/ui/tests/Android.mk2
-rw-r--r--libs/utils/tests/Android.mk3
-rw-r--r--libs/utils/tests/ZipFileRO_test.cpp64
-rw-r--r--services/surfaceflinger/Layer.cpp24
9 files changed, 131 insertions, 46 deletions
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h
index 56f029f0c2..57f9e151de 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -135,24 +135,12 @@ private:
// a timestamp is auto-generated when queueBuffer is called.
int64_t mTimestamp;
- // mQueryWidth is the width returned by query(). It is set to width
- // of the last dequeued buffer or to mReqWidth if no buffer was dequeued.
- uint32_t mQueryWidth;
-
- // mQueryHeight is the height returned by query(). It is set to height
- // of the last dequeued buffer or to mReqHeight if no buffer was dequeued.
- uint32_t mQueryHeight;
-
- // mQueryFormat is the format returned by query(). It is set to the last
- // dequeued format or to mReqFormat if no buffer was dequeued.
- uint32_t mQueryFormat;
-
// mDefaultWidth is default width of the window, regardless of the
- // set_dimension call
+ // native_window_set_buffers_dimensions call
uint32_t mDefaultWidth;
// mDefaultHeight is default width of the window, regardless of the
- // set_dimension call
+ // native_window_set_buffers_dimensions call
uint32_t mDefaultHeight;
// mTransformHint is the transform probably applied to buffers of this
diff --git a/include/utils/ZipFileRO.h b/include/utils/ZipFileRO.h
index 3a999797b4..547e36a098 100644
--- a/include/utils/ZipFileRO.h
+++ b/include/utils/ZipFileRO.h
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <time.h>
namespace android {
@@ -174,6 +175,20 @@ public:
size_t uncompLen, size_t compLen);
/*
+ * Utility function to convert ZIP's time format to a timespec struct.
+ */
+ static inline void zipTimeToTimespec(long when, struct tm* timespec) {
+ const long date = when >> 16;
+ timespec->tm_year = ((date >> 9) & 0x7F) + 80; // Zip is years since 1980
+ timespec->tm_mon = (date >> 5) & 0x0F;
+ timespec->tm_mday = date & 0x1F;
+
+ timespec->tm_hour = (when >> 11) & 0x1F;
+ timespec->tm_min = (when >> 5) & 0x3F;
+ timespec->tm_sec = (when & 0x1F) << 1;
+ }
+
+ /*
* Some basic functions for raw data manipulation. "LE" means
* Little Endian.
*/
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 8d199574f4..4f51f03ddf 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -168,18 +168,18 @@ status_t SurfaceTexture::setBufferCount(int bufferCount) {
}
}
+ const int minBufferSlots = mSynchronousMode ?
+ MIN_SYNC_BUFFER_SLOTS : MIN_ASYNC_BUFFER_SLOTS;
if (bufferCount == 0) {
- const int minBufferSlots = mSynchronousMode ?
- MIN_SYNC_BUFFER_SLOTS : MIN_ASYNC_BUFFER_SLOTS;
mClientBufferCount = 0;
bufferCount = (mServerBufferCount >= minBufferSlots) ?
mServerBufferCount : minBufferSlots;
return setBufferCountServerLocked(bufferCount);
}
- // We don't allow the client to set a buffer-count less than
- // MIN_ASYNC_BUFFER_SLOTS (3), there is no reason for it.
- if (bufferCount < MIN_ASYNC_BUFFER_SLOTS) {
+ if (bufferCount < minBufferSlots) {
+ LOGE("setBufferCount: requested buffer count (%d) is less than "
+ "minimum (%d)", bufferCount, minBufferSlots);
return BAD_VALUE;
}
@@ -196,11 +196,14 @@ status_t SurfaceTexture::setBufferCount(int bufferCount) {
status_t SurfaceTexture::setDefaultBufferSize(uint32_t w, uint32_t h)
{
- Mutex::Autolock lock(mMutex);
- if ((w != mDefaultWidth) || (h != mDefaultHeight)) {
- mDefaultWidth = w;
- mDefaultHeight = h;
+ if (!w || !h) {
+ LOGE("setDefaultBufferSize: dimensions cannot be 0 (w=%d, h=%d)", w, h);
+ return BAD_VALUE;
}
+
+ Mutex::Autolock lock(mMutex);
+ mDefaultWidth = w;
+ mDefaultHeight = h;
return OK;
}
@@ -885,13 +888,9 @@ int SurfaceTexture::query(int what, int* outValue)
switch (what) {
case NATIVE_WINDOW_WIDTH:
value = mDefaultWidth;
- if (!mDefaultWidth && !mDefaultHeight && mCurrentTextureBuf!=0)
- value = mCurrentTextureBuf->width;
break;
case NATIVE_WINDOW_HEIGHT:
value = mDefaultHeight;
- if (!mDefaultWidth && !mDefaultHeight && mCurrentTextureBuf!=0)
- value = mCurrentTextureBuf->height;
break;
case NATIVE_WINDOW_FORMAT:
value = mPixelFormat;
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index df0ad5abe3..e6837ea360 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -52,9 +52,6 @@ void SurfaceTextureClient::init() {
mReqFormat = 0;
mReqUsage = 0;
mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO;
- mQueryWidth = 0;
- mQueryHeight = 0;
- mQueryFormat = 0;
mDefaultWidth = 0;
mDefaultHeight = 0;
mTransformHint = 0;
@@ -154,9 +151,6 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
result);
return result;
}
- mQueryWidth = gbuf->width;
- mQueryHeight = gbuf->height;
- mQueryFormat = gbuf->format;
}
*buffer = gbuf.get();
return OK;
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 33ef1fc894..e75415b37b 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -61,13 +61,19 @@ void GraphicBufferAllocator::dump(String8& result) const
const size_t c = list.size();
for (size_t i=0 ; i<c ; i++) {
const alloc_rec_t& rec(list.valueAt(i));
- snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n",
- list.keyAt(i), rec.size/1024.0f,
- rec.w, rec.s, rec.h, rec.format, rec.usage);
+ if (rec.size) {
+ snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n",
+ list.keyAt(i), rec.size/1024.0f,
+ rec.w, rec.s, rec.h, rec.format, rec.usage);
+ } else {
+ snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %8X | 0x%08x\n",
+ list.keyAt(i),
+ rec.w, rec.s, rec.h, rec.format, rec.usage);
+ }
result.append(buffer);
total += rec.size;
}
- snprintf(buffer, SIZE, "Total allocated: %.2f KB\n", total/1024.0f);
+ snprintf(buffer, SIZE, "Total allocated (estimate): %.2f KB\n", total/1024.0f);
result.append(buffer);
if (mAllocDev->common.version >= 1 && mAllocDev->dump) {
mAllocDev->dump(mAllocDev, buffer, SIZE);
@@ -101,13 +107,19 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma
if (err == NO_ERROR) {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
+ int bpp = bytesPerPixel(format);
+ if (bpp < 0) {
+ // probably a HAL custom format. in any case, we don't know
+ // what its pixel size is.
+ bpp = 0;
+ }
alloc_rec_t rec;
rec.w = w;
rec.h = h;
rec.s = *stride;
rec.format = format;
rec.usage = usage;
- rec.size = h * stride[0] * bytesPerPixel(format);
+ rec.size = h * stride[0] * bpp;
list.add(*handle, rec);
}
diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk
index 693a32aa02..700b60479a 100644
--- a/libs/ui/tests/Android.mk
+++ b/libs/ui/tests/Android.mk
@@ -45,4 +45,4 @@ $(foreach file,$(test_src_files), \
)
# Build the manual test programs.
-include $(call all-subdir-makefiles)
+include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libs/utils/tests/Android.mk b/libs/utils/tests/Android.mk
index 8726a536c4..b97f52f5b8 100644
--- a/libs/utils/tests/Android.mk
+++ b/libs/utils/tests/Android.mk
@@ -8,7 +8,8 @@ test_src_files := \
ObbFile_test.cpp \
Looper_test.cpp \
String8_test.cpp \
- Unicode_test.cpp
+ Unicode_test.cpp \
+ ZipFileRO_test.cpp \
shared_libraries := \
libz \
diff --git a/libs/utils/tests/ZipFileRO_test.cpp b/libs/utils/tests/ZipFileRO_test.cpp
new file mode 100644
index 0000000000..7a1d0bd958
--- /dev/null
+++ b/libs/utils/tests/ZipFileRO_test.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011 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 "ZipFileRO_test"
+#include <utils/Log.h>
+#include <utils/ZipFileRO.h>
+
+#include <gtest/gtest.h>
+
+#include <fcntl.h>
+#include <string.h>
+
+namespace android {
+
+class ZipFileROTest : public testing::Test {
+protected:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(ZipFileROTest, ZipTimeConvertSuccess) {
+ struct tm t;
+
+ // 2011-06-29 14:40:40
+ long when = 0x3EDD7514;
+
+ ZipFileRO::zipTimeToTimespec(when, &t);
+
+ EXPECT_EQ(2011, t.tm_year + 1900)
+ << "Year was improperly converted.";
+
+ EXPECT_EQ(6, t.tm_mon)
+ << "Month was improperly converted.";
+
+ EXPECT_EQ(29, t.tm_mday)
+ << "Day was improperly converted.";
+
+ EXPECT_EQ(14, t.tm_hour)
+ << "Hour was improperly converted.";
+
+ EXPECT_EQ(40, t.tm_min)
+ << "Minute was improperly converted.";
+
+ EXPECT_EQ(40, t.tm_sec)
+ << "Second was improperly converted.";
+}
+
+}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index e0268fa061..886bb2afeb 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -105,6 +105,7 @@ void Layer::onFrameQueued() {
// in the purgatory list
void Layer::onRemoved()
{
+ mSurfaceTexture->abandon();
}
sp<ISurface> Layer::createSurface()
@@ -326,8 +327,9 @@ bool Layer::isOpaque() const
{
// if we don't have a buffer yet, we're translucent regardless of the
// layer's opaque flag.
- if (mActiveBuffer == 0)
+ if (mActiveBuffer == 0) {
return false;
+ }
// if the layer has the opaque flag, then we're always opaque,
// otherwise we use the current buffer's format.
@@ -352,12 +354,13 @@ uint32_t Layer::doTransaction(uint32_t flags)
if (sizeChanged) {
// the size changed, we need to ask our client to request a new buffer
LOGD_IF(DEBUG_RESIZE,
+ "doTransaction: "
"resize (layer=%p), requested (%dx%d), drawing (%d,%d), "
- "fixedSize=%d",
+ "scalingMode=%d",
this,
int(temp.requested_w), int(temp.requested_h),
int(front.requested_w), int(front.requested_h),
- isFixedSize());
+ mCurrentScalingMode);
if (!isFixedSize()) {
// we're being resized and there is a freeze display request,
@@ -410,6 +413,8 @@ bool Layer::isCropped() const {
void Layer::lockPageFlip(bool& recomputeVisibleRegions)
{
if (mQueuedFrames > 0) {
+ const bool oldOpacity = isOpaque();
+
// signal another event if we have more frames pending
if (android_atomic_dec(&mQueuedFrames) > 1) {
mFlinger->signalEvent();
@@ -437,9 +442,8 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
mFlinger->invalidateHwcGeometry();
}
- const bool opacity(getOpacityForFormat(mActiveBuffer->format));
- if (opacity != mCurrentOpacity) {
- mCurrentOpacity = opacity;
+ mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format);
+ if (oldOpacity != isOpaque()) {
recomputeVisibleRegions = true;
}
@@ -492,6 +496,14 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
// we now have the correct size, unfreeze the screen
mFreezeLock.clear();
}
+
+ LOGD_IF(DEBUG_RESIZE,
+ "lockPageFlip : "
+ " (layer=%p), buffer (%ux%u, tr=%02x), "
+ "requested (%dx%d)",
+ this,
+ bufWidth, bufHeight, mCurrentTransform,
+ front.requested_w, front.requested_h);
}
}
}