Reconcile with ics-factoryrom-release
Change-Id: Ibd1dca227b44e13538ea0b9f6aea45d180a010d3
diff --git a/include/binder/CursorWindow.h b/include/binder/CursorWindow.h
index f0b2909..d227244 100644
--- a/include/binder/CursorWindow.h
+++ b/include/binder/CursorWindow.h
@@ -143,8 +143,6 @@
*/
uint32_t alloc(size_t size, bool aligned = false);
- uint32_t read_field_slot(int row, int column, field_slot_t * slot);
-
/**
* Copy data into the window at the given offset.
*/
@@ -181,6 +179,32 @@
return ((field_slot_t *)offsetToPtr(fieldDirOffset)) + column;
}
+ int64_t getFieldSlotValueLong(field_slot_t* fieldSlot) {
+#if WINDOW_STORAGE_INLINE_NUMERICS
+ return fieldSlot->data.l;
+#else
+ return copyOutLong(fieldSlot->data.buffer.offset);
+#endif
+ }
+
+ double getFieldSlotValueDouble(field_slot_t* fieldSlot) {
+#if WINDOW_STORAGE_INLINE_NUMERICS
+ return fieldSlot->data.d;
+#else
+ return copyOutDouble(fieldSlot->data.buffer.offset);
+#endif
+ }
+
+#if WINDOW_STORAGE_UTF8
+ char* getFieldSlotValueString(field_slot_t* fieldSlot) {
+ return reinterpret_cast<char*>(offsetToPtr(fieldSlot->data.buffer.offset));
+ }
+#else
+ char16_t* getFieldSlotValueString(field_slot_t* fieldSlot) {
+ return reinterpret_cast<char16_t*>(offsetToPtr(fieldSlot->data.buffer.offset));
+ }
+#endif
+
private:
uint8_t * mData;
size_t mSize;
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index bfe13f0..3fa2acb 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -38,6 +38,9 @@
class Parcel
{
public:
+ class ReadableBlob;
+ class WritableBlob;
+
Parcel();
~Parcel();
@@ -46,7 +49,7 @@
size_t dataAvail() const;
size_t dataPosition() const;
size_t dataCapacity() const;
-
+
status_t setDataSize(size_t size);
void setDataPosition(size_t pos) const;
status_t setDataCapacity(size_t size);
@@ -56,6 +59,9 @@
status_t appendFrom(const Parcel *parcel,
size_t start, size_t len);
+ bool pushAllowFds(bool allowFds);
+ void restoreAllowFds(bool lastValue);
+
bool hasFileDescriptors() const;
// Writes the RPC header.
@@ -109,7 +115,13 @@
// Place a file descriptor into the parcel. A dup of the fd is made, which
// will be closed once the parcel is destroyed.
status_t writeDupFileDescriptor(int fd);
-
+
+ // Writes a blob to the parcel.
+ // If the blob is small, then it is stored in-place, otherwise it is
+ // transferred by way of an anonymous shared memory region.
+ // The caller should call release() on the blob after writing its contents.
+ status_t writeBlob(size_t len, WritableBlob* outBlob);
+
status_t writeObject(const flat_binder_object& val, bool nullMetaData);
// Like Parcel.java's writeNoException(). Just writes a zero int32.
@@ -157,7 +169,11 @@
// Retrieve a file descriptor from the parcel. This returns the raw fd
// in the parcel, which you do not own -- use dup() to get your own copy.
int readFileDescriptor() const;
-
+
+ // Reads a blob from the parcel.
+ // The caller should call release() on the blob after reading its contents.
+ status_t readBlob(size_t len, ReadableBlob* outBlob) const;
+
const flat_binder_object* readObject(bool nullMetaData) const;
// Explicitly close all file descriptors in the parcel.
@@ -177,7 +193,7 @@
release_func relFunc, void* relCookie);
void print(TextOutput& to, uint32_t flags = 0) const;
-
+
private:
Parcel(const Parcel& o);
Parcel& operator=(const Parcel& o);
@@ -212,9 +228,40 @@
mutable bool mFdsKnown;
mutable bool mHasFds;
+ bool mAllowFds;
release_func mOwner;
void* mOwnerCookie;
+
+ class Blob {
+ public:
+ Blob();
+ ~Blob();
+
+ void release();
+ inline size_t size() const { return mSize; }
+
+ protected:
+ void init(bool mapped, void* data, size_t size);
+ void clear();
+
+ bool mMapped;
+ void* mData;
+ size_t mSize;
+ };
+
+public:
+ class ReadableBlob : public Blob {
+ friend class Parcel;
+ public:
+ inline const void* data() const { return mData; }
+ };
+
+ class WritableBlob : public Blob {
+ friend class Parcel;
+ public:
+ inline void* data() { return mData; }
+ };
};
// ---------------------------------------------------------------------------
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 493993d..e2d6179 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -20,13 +20,15 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#include <gui/ISurfaceTexture.h>
#include <ui/GraphicBuffer.h>
-#include <utils/threads.h>
+#include <utils/String8.h>
#include <utils/Vector.h>
+#include <utils/threads.h>
#define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture"
@@ -60,7 +62,8 @@
// tex indicates the name OpenGL texture to which images are to be streamed.
// This texture name cannot be changed once the SurfaceTexture is created.
- SurfaceTexture(GLuint tex, bool allowSynchronousMode = true);
+ SurfaceTexture(GLuint tex, bool allowSynchronousMode = true,
+ GLenum texTarget = GL_TEXTURE_EXTERNAL_OES);
virtual ~SurfaceTexture();
@@ -202,6 +205,10 @@
// by OpenGL ES as a texture) then those buffer will remain allocated.
void abandon();
+ // set the name of the SurfaceTexture that will be used to identify it in
+ // log messages.
+ void setName(const String8& name);
+
// dump our state in a String
void dump(String8& result) const;
void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const;
@@ -444,11 +451,23 @@
// all ISurfaceTexture methods capable of returning an error.
bool mAbandoned;
+ // mName is a string used to identify the SurfaceTexture in log messages.
+ // It is set by the setName method.
+ String8 mName;
+
// mMutex is the mutex used to prevent concurrent access to the member
// variables of SurfaceTexture objects. It must be locked whenever the
// member variables are accessed.
mutable Mutex mMutex;
+ // mTexTarget is the GL texture target with which the GL texture object is
+ // associated. It is set in the constructor and never changed. It is
+ // almost always GL_TEXTURE_EXTERNAL_OES except for one use case in Android
+ // Browser. In that case it is set to GL_TEXTURE_2D to allow
+ // glCopyTexSubImage to read from the texture. This is a hack to work
+ // around a GL driver limitation on the number of FBO attachments, which the
+ // browser's tile cache exceeds.
+ const GLenum mTexTarget;
};
// ----------------------------------------------------------------------------
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h
index 6b31ca4..e0f4cf9 100644
--- a/include/surfaceflinger/ISurfaceComposer.h
+++ b/include/surfaceflinger/ISurfaceComposer.h
@@ -88,11 +88,6 @@
eElectronBeamAnimationOff = 0x10
};
- // flags for setOrientation
- enum {
- eOrientationAnimationDisable = 0x00000001
- };
-
/* create connection with surface flinger, requires
* ACCESS_SURFACE_FLINGER permission
*/
@@ -112,7 +107,8 @@
virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) = 0;
virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;
- /* Set display orientation. requires ACCESS_SURFACE_FLINGER permission */
+ /* Set display orientation. requires ACCESS_SURFACE_FLINGER permission
+ * No flags are currently defined. Set flags to 0. */
virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0;
/* signal that we're done booting.
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index 4e65a2d..9e98bc5 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -27,7 +27,7 @@
class Rect : public ARect
{
public:
- typedef int32_t value_type;
+ typedef ARect::value_type value_type;
// we don't provide copy-ctor and operator= on purpose
// because we want the compiler generated versions
diff --git a/include/utils/Errors.h b/include/utils/Errors.h
index 81f818b..0b75b19 100644
--- a/include/utils/Errors.h
+++ b/include/utils/Errors.h
@@ -72,6 +72,7 @@
TIMED_OUT = 0x80000005,
UNKNOWN_TRANSACTION = 0x80000006,
#endif
+ FDS_NOT_ALLOWED = 0x80000007,
};
// Restore define; enumeration is in "android" namespace, so the value defined
diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h
index 6afb291..9273533 100644
--- a/include/utils/Unicode.h
+++ b/include/utils/Unicode.h
@@ -150,6 +150,13 @@
ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen);
/**
+ * Convert UTF-8 to UTF-16 including surrogate pairs.
+ * Returns a pointer to the end of the string (where a null terminator might go
+ * if you wanted to add one).
+ */
+char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst);
+
+/**
* Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer
* must be large enough to hold the result as measured by utf8_to_utf16_length
* plus an added NULL terminator.
diff --git a/include/utils/threads.h b/include/utils/threads.h
index c685625..ab3e8cd 100644
--- a/include/utils/threads.h
+++ b/include/utils/threads.h
@@ -143,6 +143,10 @@
// in either case errno is set. Thread ID zero means current thread.
extern int androidSetThreadPriority(pid_t tid, int prio);
+// Get the current priority of a particular thread. Returns one of the
+// ANDROID_PRIORITY constants or a negative result in case of error.
+extern int androidGetThreadPriority(pid_t tid);
+
// Get the current scheduling group of a particular thread. Normally returns
// one of the ANDROID_TGROUP constants other than ANDROID_TGROUP_DEFAULT.
// Returns ANDROID_TGROUP_DEFAULT if no pthread support (e.g. on host) or if
diff --git a/libs/binder/CursorWindow.cpp b/libs/binder/CursorWindow.cpp
index 47bbd04..b02374f 100644
--- a/libs/binder/CursorWindow.cpp
+++ b/libs/binder/CursorWindow.cpp
@@ -236,33 +236,6 @@
return ((field_slot_t *)offsetToPtr(fieldDirOffset)) + column;
}
-uint32_t CursorWindow::read_field_slot(int row, int column, field_slot_t * slotOut)
-{
- if (row < 0 || row >= mHeader->numRows || column < 0 || column >= mHeader->numColumns) {
- LOGE("Can't read row# %d, col# %d from CursorWindow. Make sure your Cursor is initialized correctly.",
- row, column);
- return -1;
- }
- row_slot_t * rowSlot = getRowSlot(row);
- if (!rowSlot) {
- LOGE("Failed to find rowSlot for row %d", row);
- return -1;
- }
- if (rowSlot->offset == 0 || rowSlot->offset >= mSize) {
- LOGE("Invalid rowSlot, offset = %d", rowSlot->offset);
- return -1;
- }
-LOG_WINDOW("Found field directory for %d,%d at rowSlot %d, offset %d", row, column, (uint8_t *)rowSlot - mData, rowSlot->offset);
- field_slot_t * fieldDir = (field_slot_t *)offsetToPtr(rowSlot->offset);
-LOG_WINDOW("Read field_slot_t %d,%d: offset = %d, size = %d, type = %d", row, column, fieldDir[column].data.buffer.offset, fieldDir[column].data.buffer.size, fieldDir[column].type);
-
- // Copy the data to the out param
- slotOut->data.buffer.offset = fieldDir[column].data.buffer.offset;
- slotOut->data.buffer.size = fieldDir[column].data.buffer.size;
- slotOut->type = fieldDir[column].type;
- return 0;
-}
-
void CursorWindow::copyIn(uint32_t offset, uint8_t const * data, size_t size)
{
assert(offset + size <= mSize);
@@ -370,12 +343,8 @@
if (!fieldSlot || fieldSlot->type != FIELD_TYPE_INTEGER) {
return false;
}
-
-#if WINDOW_STORAGE_INLINE_NUMERICS
- *valueOut = fieldSlot->data.l;
-#else
- *valueOut = copyOutLong(fieldSlot->data.buffer.offset);
-#endif
+
+ *valueOut = getFieldSlotValueLong(fieldSlot);
return true;
}
@@ -386,11 +355,7 @@
return false;
}
-#if WINDOW_STORAGE_INLINE_NUMERICS
- *valueOut = fieldSlot->data.d;
-#else
- *valueOut = copyOutDouble(fieldSlot->data.buffer.offset);
-#endif
+ *valueOut = getFieldSlotValueDouble(fieldSlot);
return true;
}
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index a0fc4d0..608877e 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -30,12 +30,14 @@
#include <utils/TextOutput.h>
#include <utils/misc.h>
#include <utils/Flattenable.h>
+#include <cutils/ashmem.h>
#include <private/binder/binder_module.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <sys/mman.h>
#ifndef INT32_MAX
#define INT32_MAX ((int32_t)(2147483647))
@@ -54,6 +56,9 @@
// Note: must be kept in sync with android/os/Parcel.java's EX_HAS_REPLY_HEADER
#define EX_HAS_REPLY_HEADER -128
+// Maximum size of a blob to transfer in-place.
+static const size_t IN_PLACE_BLOB_LIMIT = 40 * 1024;
+
// XXX This can be made public if we want to provide
// support for typed data.
struct small_flat_data
@@ -399,6 +404,8 @@
mDataPos += len;
mDataSize += len;
+ err = NO_ERROR;
+
if (numObjects > 0) {
// grow objects
if (mObjectsCapacity < mObjectsSize + numObjects) {
@@ -430,11 +437,28 @@
flat->handle = dup(flat->handle);
flat->cookie = (void*)1;
mHasFds = mFdsKnown = true;
+ if (!mAllowFds) {
+ err = FDS_NOT_ALLOWED;
+ }
}
}
}
- return NO_ERROR;
+ return err;
+}
+
+bool Parcel::pushAllowFds(bool allowFds)
+{
+ const bool origValue = mAllowFds;
+ if (!allowFds) {
+ mAllowFds = false;
+ }
+ return origValue;
+}
+
+void Parcel::restoreAllowFds(bool lastValue)
+{
+ mAllowFds = lastValue;
}
bool Parcel::hasFileDescriptors() const
@@ -706,6 +730,54 @@
return writeObject(obj, true);
}
+status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)
+{
+ status_t status;
+
+ if (!mAllowFds || len <= IN_PLACE_BLOB_LIMIT) {
+ LOGV("writeBlob: write in place");
+ status = writeInt32(0);
+ if (status) return status;
+
+ void* ptr = writeInplace(len);
+ if (!ptr) return NO_MEMORY;
+
+ outBlob->init(false /*mapped*/, ptr, len);
+ return NO_ERROR;
+ }
+
+ LOGV("writeBlob: write to ashmem");
+ int fd = ashmem_create_region("Parcel Blob", len);
+ if (fd < 0) return NO_MEMORY;
+
+ int result = ashmem_set_prot_region(fd, PROT_READ | PROT_WRITE);
+ if (result < 0) {
+ status = -result;
+ } else {
+ void* ptr = ::mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (ptr == MAP_FAILED) {
+ status = -errno;
+ } else {
+ result = ashmem_set_prot_region(fd, PROT_READ);
+ if (result < 0) {
+ status = -result;
+ } else {
+ status = writeInt32(1);
+ if (!status) {
+ status = writeFileDescriptor(fd);
+ if (!status) {
+ outBlob->init(true /*mapped*/, ptr, len);
+ return NO_ERROR;
+ }
+ }
+ }
+ }
+ ::munmap(ptr, len);
+ }
+ ::close(fd);
+ return status;
+}
+
status_t Parcel::write(const Flattenable& val)
{
status_t err;
@@ -759,6 +831,9 @@
// remember if it's a file descriptor
if (val.type == BINDER_TYPE_FD) {
+ if (!mAllowFds) {
+ return FDS_NOT_ALLOWED;
+ }
mHasFds = mFdsKnown = true;
}
@@ -1025,6 +1100,32 @@
return BAD_TYPE;
}
+status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const
+{
+ int32_t useAshmem;
+ status_t status = readInt32(&useAshmem);
+ if (status) return status;
+
+ if (!useAshmem) {
+ LOGV("readBlob: read in place");
+ const void* ptr = readInplace(len);
+ if (!ptr) return BAD_VALUE;
+
+ outBlob->init(false /*mapped*/, const_cast<void*>(ptr), len);
+ return NO_ERROR;
+ }
+
+ LOGV("readBlob: read from ashmem");
+ int fd = readFileDescriptor();
+ if (fd == int(BAD_TYPE)) return BAD_VALUE;
+
+ void* ptr = ::mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
+ if (!ptr) return NO_MEMORY;
+
+ outBlob->init(true /*mapped*/, ptr, len);
+ return NO_ERROR;
+}
+
status_t Parcel::read(Flattenable& val) const
{
// size
@@ -1283,6 +1384,7 @@
mNextObjectHint = 0;
mHasFds = false;
mFdsKnown = true;
+ mAllowFds = true;
return NO_ERROR;
}
@@ -1434,6 +1536,7 @@
mNextObjectHint = 0;
mHasFds = false;
mFdsKnown = true;
+ mAllowFds = true;
mOwner = NULL;
}
@@ -1452,4 +1555,33 @@
mFdsKnown = true;
}
+// --- Parcel::Blob ---
+
+Parcel::Blob::Blob() :
+ mMapped(false), mData(NULL), mSize(0) {
+}
+
+Parcel::Blob::~Blob() {
+ release();
+}
+
+void Parcel::Blob::release() {
+ if (mMapped && mData) {
+ ::munmap(mData, mSize);
+ }
+ clear();
+}
+
+void Parcel::Blob::init(bool mapped, void* data, size_t size) {
+ mMapped = mapped;
+ mData = data;
+ mSize = size;
+}
+
+void Parcel::Blob::clear() {
+ mMapped = false;
+ mData = NULL;
+ mSize = 0;
+}
+
}; // namespace android
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 79a01a3..c72a45b 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -39,6 +39,12 @@
#define ALLOW_DEQUEUE_CURRENT_BUFFER false
+// Macros for including the SurfaceTexture name in log messages
+#define ST_LOGV(x, ...) LOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define ST_LOGD(x, ...) LOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define ST_LOGI(x, ...) LOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define ST_LOGW(x, ...) LOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define ST_LOGE(x, ...) LOGE("[%s] "x, mName.string(), ##__VA_ARGS__)
namespace android {
@@ -82,7 +88,14 @@
static void mtxMul(float out[16], const float a[16], const float b[16]);
-SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode) :
+// Get an ID that's unique within this process.
+static int32_t createProcessUniqueId() {
+ static volatile int32_t globalCounter = 0;
+ return android_atomic_inc(&globalCounter);
+}
+
+SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode,
+ GLenum texTarget) :
mDefaultWidth(1),
mDefaultHeight(1),
mPixelFormat(PIXEL_FORMAT_RGBA_8888),
@@ -98,16 +111,21 @@
mSynchronousMode(false),
mAllowSynchronousMode(allowSynchronousMode),
mConnectedApi(NO_CONNECTED_API),
- mAbandoned(false) {
- LOGV("SurfaceTexture::SurfaceTexture");
+ mAbandoned(false),
+ mTexTarget(texTarget) {
+ // Choose a name using the PID and a process-unique ID.
+ mName = String8::format("unnamed-%d-%d", getpid(), createProcessUniqueId());
+
+ ST_LOGV("SurfaceTexture::SurfaceTexture");
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
mGraphicBufferAlloc = composer->createGraphicBufferAlloc();
mNextCrop.makeInvalid();
- memcpy(mCurrentTransformMatrix, mtxIdentity, sizeof(mCurrentTransformMatrix));
+ memcpy(mCurrentTransformMatrix, mtxIdentity,
+ sizeof(mCurrentTransformMatrix));
}
SurfaceTexture::~SurfaceTexture() {
- LOGV("SurfaceTexture::~SurfaceTexture");
+ ST_LOGV("SurfaceTexture::~SurfaceTexture");
freeAllBuffersLocked();
}
@@ -151,22 +169,22 @@
}
status_t SurfaceTexture::setBufferCount(int bufferCount) {
- LOGV("SurfaceTexture::setBufferCount");
+ ST_LOGV("SurfaceTexture::setBufferCount");
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("setBufferCount: SurfaceTexture has been abandoned!");
+ ST_LOGE("setBufferCount: SurfaceTexture has been abandoned!");
return NO_INIT;
}
if (bufferCount > NUM_BUFFER_SLOTS) {
- LOGE("setBufferCount: bufferCount larger than slots available");
+ ST_LOGE("setBufferCount: bufferCount larger than slots available");
return BAD_VALUE;
}
// Error out if the user has dequeued buffers
for (int i=0 ; i<mBufferCount ; i++) {
if (mSlots[i].mBufferState == BufferSlot::DEQUEUED) {
- LOGE("setBufferCount: client owns some buffers");
+ ST_LOGE("setBufferCount: client owns some buffers");
return -EINVAL;
}
}
@@ -181,7 +199,7 @@
}
if (bufferCount < minBufferSlots) {
- LOGE("setBufferCount: requested buffer count (%d) is less than "
+ ST_LOGE("setBufferCount: requested buffer count (%d) is less than "
"minimum (%d)", bufferCount, minBufferSlots);
return BAD_VALUE;
}
@@ -200,7 +218,8 @@
status_t SurfaceTexture::setDefaultBufferSize(uint32_t w, uint32_t h)
{
if (!w || !h) {
- LOGE("setDefaultBufferSize: dimensions cannot be 0 (w=%d, h=%d)", w, h);
+ ST_LOGE("setDefaultBufferSize: dimensions cannot be 0 (w=%d, h=%d)",
+ w, h);
return BAD_VALUE;
}
@@ -211,14 +230,14 @@
}
status_t SurfaceTexture::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
- LOGV("SurfaceTexture::requestBuffer");
+ ST_LOGV("SurfaceTexture::requestBuffer");
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("requestBuffer: SurfaceTexture has been abandoned!");
+ ST_LOGE("requestBuffer: SurfaceTexture has been abandoned!");
return NO_INIT;
}
if (slot < 0 || mBufferCount <= slot) {
- LOGE("requestBuffer: slot index out of range [0, %d]: %d",
+ ST_LOGE("requestBuffer: slot index out of range [0, %d]: %d",
mBufferCount, slot);
return BAD_VALUE;
}
@@ -229,10 +248,10 @@
status_t SurfaceTexture::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
uint32_t format, uint32_t usage) {
- LOGV("SurfaceTexture::dequeueBuffer");
+ ST_LOGV("SurfaceTexture::dequeueBuffer");
if ((w && !h) || (!w && h)) {
- LOGE("dequeueBuffer: invalid size: w=%u, h=%u", w, h);
+ ST_LOGE("dequeueBuffer: invalid size: w=%u, h=%u", w, h);
return BAD_VALUE;
}
@@ -245,7 +264,7 @@
bool tryAgain = true;
while (tryAgain) {
if (mAbandoned) {
- LOGE("dequeueBuffer: SurfaceTexture has been abandoned!");
+ ST_LOGE("dequeueBuffer: SurfaceTexture has been abandoned!");
return NO_INIT;
}
@@ -334,7 +353,8 @@
// than allowed.
const int avail = mBufferCount - (dequeuedCount+1);
if (avail < (MIN_UNDEQUEUED_BUFFERS-int(mSynchronousMode))) {
- LOGE("dequeueBuffer: MIN_UNDEQUEUED_BUFFERS=%d exceeded (dequeued=%d)",
+ ST_LOGE("dequeueBuffer: MIN_UNDEQUEUED_BUFFERS=%d exceeded "
+ "(dequeued=%d)",
MIN_UNDEQUEUED_BUFFERS-int(mSynchronousMode),
dequeuedCount);
return -EBUSY;
@@ -391,7 +411,8 @@
mGraphicBufferAlloc->createGraphicBuffer(
w, h, format, usage, &error));
if (graphicBuffer == 0) {
- LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer failed");
+ ST_LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer "
+ "failed");
return error;
}
if (updateFormat) {
@@ -413,7 +434,7 @@
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("setSynchronousMode: SurfaceTexture has been abandoned!");
+ ST_LOGE("setSynchronousMode: SurfaceTexture has been abandoned!");
return NO_INIT;
}
@@ -441,29 +462,29 @@
status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp,
uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
- LOGV("SurfaceTexture::queueBuffer");
+ ST_LOGV("SurfaceTexture::queueBuffer");
sp<FrameAvailableListener> listener;
{ // scope for the lock
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("queueBuffer: SurfaceTexture has been abandoned!");
+ ST_LOGE("queueBuffer: SurfaceTexture has been abandoned!");
return NO_INIT;
}
if (buf < 0 || buf >= mBufferCount) {
- LOGE("queueBuffer: slot index out of range [0, %d]: %d",
+ ST_LOGE("queueBuffer: slot index out of range [0, %d]: %d",
mBufferCount, buf);
return -EINVAL;
} else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
- LOGE("queueBuffer: slot %d is not owned by the client (state=%d)",
- buf, mSlots[buf].mBufferState);
+ ST_LOGE("queueBuffer: slot %d is not owned by the client "
+ "(state=%d)", buf, mSlots[buf].mBufferState);
return -EINVAL;
} else if (buf == mCurrentTexture) {
- LOGE("queueBuffer: slot %d is current!", buf);
+ ST_LOGE("queueBuffer: slot %d is current!", buf);
return -EINVAL;
} else if (!mSlots[buf].mRequestBufferCalled) {
- LOGE("queueBuffer: slot %d was enqueued without requesting a "
+ ST_LOGE("queueBuffer: slot %d was enqueued without requesting a "
"buffer", buf);
return -EINVAL;
}
@@ -513,20 +534,20 @@
}
void SurfaceTexture::cancelBuffer(int buf) {
- LOGV("SurfaceTexture::cancelBuffer");
+ ST_LOGV("SurfaceTexture::cancelBuffer");
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGW("cancelBuffer: SurfaceTexture has been abandoned!");
+ ST_LOGW("cancelBuffer: SurfaceTexture has been abandoned!");
return;
}
if (buf < 0 || buf >= mBufferCount) {
- LOGE("cancelBuffer: slot index out of range [0, %d]: %d",
+ ST_LOGE("cancelBuffer: slot index out of range [0, %d]: %d",
mBufferCount, buf);
return;
} else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
- LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
+ ST_LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
buf, mSlots[buf].mBufferState);
return;
}
@@ -535,10 +556,10 @@
}
status_t SurfaceTexture::setCrop(const Rect& crop) {
- LOGV("SurfaceTexture::setCrop");
+ ST_LOGV("SurfaceTexture::setCrop");
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("setCrop: SurfaceTexture has been abandoned!");
+ ST_LOGE("setCrop: SurfaceTexture has been abandoned!");
return NO_INIT;
}
mNextCrop = crop;
@@ -546,10 +567,10 @@
}
status_t SurfaceTexture::setTransform(uint32_t transform) {
- LOGV("SurfaceTexture::setTransform");
+ ST_LOGV("SurfaceTexture::setTransform");
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("setTransform: SurfaceTexture has been abandoned!");
+ ST_LOGE("setTransform: SurfaceTexture has been abandoned!");
return NO_INIT;
}
mNextTransform = transform;
@@ -558,11 +579,11 @@
status_t SurfaceTexture::connect(int api,
uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
- LOGV("SurfaceTexture::connect(this=%p, %d)", this, api);
+ ST_LOGV("SurfaceTexture::connect(this=%p, %d)", this, api);
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("connect: SurfaceTexture has been abandoned!");
+ ST_LOGE("connect: SurfaceTexture has been abandoned!");
return NO_INIT;
}
@@ -573,7 +594,7 @@
case NATIVE_WINDOW_API_MEDIA:
case NATIVE_WINDOW_API_CAMERA:
if (mConnectedApi != NO_CONNECTED_API) {
- LOGE("connect: already connected (cur=%d, req=%d)",
+ ST_LOGE("connect: already connected (cur=%d, req=%d)",
mConnectedApi, api);
err = -EINVAL;
} else {
@@ -591,11 +612,11 @@
}
status_t SurfaceTexture::disconnect(int api) {
- LOGV("SurfaceTexture::disconnect(this=%p, %d)", this, api);
+ ST_LOGV("SurfaceTexture::disconnect(this=%p, %d)", this, api);
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("connect: SurfaceTexture has been abandoned!");
+ ST_LOGE("disconnect: SurfaceTexture has been abandoned!");
return NO_INIT;
}
@@ -613,7 +634,7 @@
mNextTransform = 0;
mDequeueCondition.signal();
} else {
- LOGE("disconnect: connected to another api (cur=%d, req=%d)",
+ ST_LOGE("disconnect: connected to another api (cur=%d, req=%d)",
mConnectedApi, api);
err = -EINVAL;
}
@@ -626,7 +647,7 @@
}
status_t SurfaceTexture::setScalingMode(int mode) {
- LOGV("SurfaceTexture::setScalingMode(%d)", mode);
+ ST_LOGV("SurfaceTexture::setScalingMode(%d)", mode);
switch (mode) {
case NATIVE_WINDOW_SCALING_MODE_FREEZE:
@@ -642,11 +663,11 @@
}
status_t SurfaceTexture::updateTexImage() {
- LOGV("SurfaceTexture::updateTexImage");
+ ST_LOGV("SurfaceTexture::updateTexImage");
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("calling updateTexImage() on an abandoned SurfaceTexture");
+ ST_LOGE("calling updateTexImage() on an abandoned SurfaceTexture");
return NO_INIT;
}
@@ -661,7 +682,7 @@
if (image == EGL_NO_IMAGE_KHR) {
EGLDisplay dpy = eglGetCurrentDisplay();
if (mSlots[buf].mGraphicBuffer == 0) {
- LOGE("buffer at slot %d is null", buf);
+ ST_LOGE("buffer at slot %d is null", buf);
return BAD_VALUE;
}
image = createImage(dpy, mSlots[buf].mGraphicBuffer);
@@ -676,15 +697,15 @@
GLint error;
while ((error = glGetError()) != GL_NO_ERROR) {
- LOGW("updateTexImage: clearing GL error: %#04x", error);
+ ST_LOGW("updateTexImage: clearing GL error: %#04x", error);
}
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexName);
- glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, (GLeglImageOES)image);
+ glBindTexture(mTexTarget, mTexName);
+ glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image);
bool failed = false;
while ((error = glGetError()) != GL_NO_ERROR) {
- LOGE("error binding external texture image %p (slot %d): %#04x",
+ ST_LOGE("error binding external texture image %p (slot %d): %#04x",
image, buf, error);
failed = true;
}
@@ -715,7 +736,7 @@
mDequeueCondition.signal();
} else {
// We always bind the texture even if we don't update its contents.
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexName);
+ glBindTexture(mTexTarget, mTexName);
}
return OK;
@@ -741,7 +762,7 @@
}
GLenum SurfaceTexture::getCurrentTextureTarget() const {
- return GL_TEXTURE_EXTERNAL_OES;
+ return mTexTarget;
}
void SurfaceTexture::getTransformMatrix(float mtx[16]) {
@@ -750,7 +771,7 @@
}
void SurfaceTexture::computeCurrentTransformMatrix() {
- LOGV("SurfaceTexture::computeCurrentTransformMatrix");
+ ST_LOGV("SurfaceTexture::computeCurrentTransformMatrix");
float xform[16];
for (int i = 0; i < 16; i++) {
@@ -841,14 +862,14 @@
}
nsecs_t SurfaceTexture::getTimestamp() {
- LOGV("SurfaceTexture::getTimestamp");
+ ST_LOGV("SurfaceTexture::getTimestamp");
Mutex::Autolock lock(mMutex);
return mCurrentTimestamp;
}
void SurfaceTexture::setFrameAvailableListener(
const sp<FrameAvailableListener>& listener) {
- LOGV("SurfaceTexture::setFrameAvailableListener");
+ ST_LOGV("SurfaceTexture::setFrameAvailableListener");
Mutex::Autolock lock(mMutex);
mFrameAvailableListener = listener;
}
@@ -892,11 +913,11 @@
while (mSynchronousMode && !mQueue.isEmpty()) {
mDequeueCondition.wait(mMutex);
if (mAbandoned) {
- LOGE("drainQueueLocked: SurfaceTexture has been abandoned!");
+ ST_LOGE("drainQueueLocked: SurfaceTexture has been abandoned!");
return NO_INIT;
}
if (mConnectedApi == NO_CONNECTED_API) {
- LOGE("drainQueueLocked: SurfaceTexture is not connected!");
+ ST_LOGE("drainQueueLocked: SurfaceTexture is not connected!");
return NO_INIT;
}
}
@@ -926,7 +947,7 @@
EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs);
if (image == EGL_NO_IMAGE_KHR) {
EGLint error = eglGetError();
- LOGE("error creating EGLImage: %#x", error);
+ ST_LOGE("error creating EGLImage: %#x", error);
}
return image;
}
@@ -956,7 +977,7 @@
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
- LOGE("query: SurfaceTexture has been abandoned!");
+ ST_LOGE("query: SurfaceTexture has been abandoned!");
return NO_INIT;
}
@@ -991,6 +1012,10 @@
mDequeueCondition.signal();
}
+void SurfaceTexture::setName(const String8& name) {
+ mName = name;
+}
+
void SurfaceTexture::dump(String8& result) const
{
char buffer[1024];
@@ -1004,8 +1029,8 @@
snprintf(buffer, SIZE,
"%smBufferCount=%d, mSynchronousMode=%d, default-size=[%dx%d], "
"mPixelFormat=%d, mTexName=%d\n",
- prefix, mBufferCount, mSynchronousMode, mDefaultWidth, mDefaultHeight,
- mPixelFormat, mTexName);
+ prefix, mBufferCount, mSynchronousMode, mDefaultWidth,
+ mDefaultHeight, mPixelFormat, mTexName);
result.append(buffer);
String8 fifo;
@@ -1024,8 +1049,8 @@
prefix, mCurrentCrop.left,
mCurrentCrop.top, mCurrentCrop.right, mCurrentCrop.bottom,
mCurrentTransform, mCurrentTexture,
- prefix, mNextCrop.left, mNextCrop.top, mNextCrop.right, mNextCrop.bottom,
- mNextTransform, fifoSize, fifo.string()
+ prefix, mNextCrop.left, mNextCrop.top, mNextCrop.right,
+ mNextCrop.bottom, mNextTransform, fifoSize, fifo.string()
);
result.append(buffer);
@@ -1048,8 +1073,8 @@
"transform=0x%02x, timestamp=%lld",
prefix, (i==mCurrentTexture)?">":" ", i,
stateName(slot.mBufferState),
- slot.mCrop.left, slot.mCrop.top, slot.mCrop.right, slot.mCrop.bottom,
- slot.mTransform, slot.mTimestamp
+ slot.mCrop.left, slot.mCrop.top, slot.mCrop.right,
+ slot.mCrop.bottom, slot.mTransform, slot.mTimestamp
);
result.append(buffer);
@@ -1057,7 +1082,8 @@
if (buf != NULL) {
snprintf(buffer, SIZE,
", %p [%4ux%4u:%4u,%3X]",
- buf->handle, buf->width, buf->height, buf->stride, buf->format);
+ buf->handle, buf->width, buf->height, buf->stride,
+ buf->format);
result.append(buffer);
}
result.append("\n");
diff --git a/libs/utils/Android.mk b/libs/utils/Android.mk
index e4eadbd..638f72f 100644
--- a/libs/utils/Android.mk
+++ b/libs/utils/Android.mk
@@ -100,12 +100,8 @@
LOCAL_SHARED_LIBRARIES := \
libz \
liblog \
- libcutils
-
-ifeq ($(TARGET_OS)-$(TARGET_ARCH),linux-x86)
-# This is needed on x86 to bring in dl_iterate_phdr for CallStack.cpp
-LOCAL_SHARED_LIBRARIES += libdl
-endif # linux-x86
+ libcutils \
+ libdl
LOCAL_MODULE:= libutils
include $(BUILD_SHARED_LIBRARY)
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index 02c380b..5dbcb75 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -368,6 +368,14 @@
return rc;
}
+int androidGetThreadPriority(pid_t tid) {
+#if defined(HAVE_PTHREADS)
+ return getpriority(PRIO_PROCESS, tid);
+#else
+ return ANDROID_PRIORITY_NORMAL;
+#endif
+}
+
int androidGetThreadSchedulingGroup(pid_t tid)
{
int ret = ANDROID_TGROUP_DEFAULT;
diff --git a/libs/utils/Unicode.cpp b/libs/utils/Unicode.cpp
index 78c61b4..41cbf03 100644
--- a/libs/utils/Unicode.cpp
+++ b/libs/utils/Unicode.cpp
@@ -542,11 +542,7 @@
return u16measuredLen;
}
-/**
- * Convert a UTF-8 string to UTF-16. The destination UTF-16 buffer must have
- * space for NULL at the end.
- */
-void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str)
+char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* u8str, size_t u8len, char16_t* u16str)
{
const uint8_t* const u8end = u8str + u8len;
const uint8_t* u8cur = u8str;
@@ -569,7 +565,12 @@
u8cur += u8len;
}
- *u16cur = 0;
+ return u16cur;
+}
+
+void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) {
+ char16_t* end = utf8_to_utf16_no_null_terminator(u8str, u8len, u16str);
+ *end = 0;
}
}
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 23f67d5..1f9ce68 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -1480,7 +1480,7 @@
}
}
- return setError(EGL_BAD_DISPLAY, 0);;
+ return setErrorQuiet(EGL_BAD_DISPLAY, 0);
}
EGLuint64NV eglGetSystemTimeNV()
@@ -1500,5 +1500,5 @@
}
}
- return setError(EGL_BAD_DISPLAY, 0);;
+ return setErrorQuiet(EGL_BAD_DISPLAY, 0);
}
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index d2b7378..46f7139 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -130,7 +130,7 @@
if (window != NULL) {
native_window_set_buffers_format(window, 0);
if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) {
- LOGE("EGLNativeWindowType %p disconnected failed", window);
+ LOGW("EGLNativeWindowType %p disconnect failed", window);
}
}
}
diff --git a/opengl/libs/EGL/egl_tls.cpp b/opengl/libs/EGL/egl_tls.cpp
index f3c8d2c..b341ddb 100644
--- a/opengl/libs/EGL/egl_tls.cpp
+++ b/opengl/libs/EGL/egl_tls.cpp
@@ -67,19 +67,23 @@
}
}
-void egl_tls_t::setErrorEtcImpl(const char* caller, int line, EGLint error) {
+void egl_tls_t::setErrorEtcImpl(
+ const char* caller, int line, EGLint error, bool quiet) {
validateTLSKey();
egl_tls_t* tls = getTLS();
if (tls->error != error) {
- LOGE("%s:%d error %x (%s)", caller, line, error, egl_strerror(error));
- tls->error = error;
- char value[PROPERTY_VALUE_MAX];
- property_get("debug.egl.callstack", value, "0");
- if (atoi(value)) {
- CallStack stack;
- stack.update();
- stack.dump();
+ if (!quiet) {
+ LOGE("%s:%d error %x (%s)",
+ caller, line, error, egl_strerror(error));
+ char value[PROPERTY_VALUE_MAX];
+ property_get("debug.egl.callstack", value, "0");
+ if (atoi(value)) {
+ CallStack stack;
+ stack.update();
+ stack.dump();
+ }
}
+ tls->error = error;
}
}
diff --git a/opengl/libs/EGL/egl_tls.h b/opengl/libs/EGL/egl_tls.h
index a7989ef..78b0b2f 100644
--- a/opengl/libs/EGL/egl_tls.h
+++ b/opengl/libs/EGL/egl_tls.h
@@ -41,7 +41,8 @@
egl_tls_t();
static void validateTLSKey();
- static void setErrorEtcImpl(const char* caller, int line, EGLint error);
+ static void setErrorEtcImpl(
+ const char* caller, int line, EGLint error, bool quiet);
public:
static egl_tls_t* getTLS();
@@ -55,13 +56,17 @@
template<typename T>
static T setErrorEtc(const char* caller,
- int line, EGLint error, T returnValue) {
- setErrorEtcImpl(caller, line, error);
+ int line, EGLint error, T returnValue, bool quiet = false) {
+ setErrorEtcImpl(caller, line, error, quiet);
return returnValue;
}
};
-#define setError(_e, _r) egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
+#define setError(_e, _r) \
+ egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
+
+#define setErrorQuiet(_e, _r) \
+ egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r, true)
// ----------------------------------------------------------------------------
diff --git a/opengl/libs/GLES2_dbg/Android.mk b/opengl/libs/GLES2_dbg/Android.mk
index c2b1142..70853d8 100644
--- a/opengl/libs/GLES2_dbg/Android.mk
+++ b/opengl/libs/GLES2_dbg/Android.mk
@@ -31,6 +31,9 @@
LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
endif
+LOCAL_CFLAGS += -DLOG_TAG=\"libGLES2_dbg\"
+
+
# we need to access the private Bionic header <bionic_tls.h>
# on ARM platforms, we need to mirror the ARCH_ARM_HAVE_TLS_REGISTER
# behavior from the bionic Android.mk file
diff --git a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
index 9e77665..41061e1 100644
--- a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
+++ b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
@@ -30,13 +30,11 @@
}
DbgContext::DbgContext(const unsigned version, const gl_hooks_t * const hooks,
- const unsigned MAX_VERTEX_ATTRIBS, const GLenum readFormat,
- const GLenum readType)
+ const unsigned MAX_VERTEX_ATTRIBS)
: lzf_buf(NULL), lzf_readIndex(0), lzf_refSize(0), lzf_refBufSize(0)
, version(version), hooks(hooks)
, MAX_VERTEX_ATTRIBS(MAX_VERTEX_ATTRIBS)
- , readFormat(readFormat), readType(readType)
- , readBytesPerPixel(GetBytesPerPixel(readFormat, readType))
+ , readBytesPerPixel(4)
, captureSwap(0), captureDraw(0)
, vertexAttribs(new VertexAttrib[MAX_VERTEX_ATTRIBS])
, hasNonVBOAttribs(false), indexBuffers(NULL), indexBuffer(NULL)
@@ -67,11 +65,7 @@
assert(GL_NO_ERROR == hooks->gl.glGetError());
GLint MAX_VERTEX_ATTRIBS = 0;
hooks->gl.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &MAX_VERTEX_ATTRIBS);
- GLint readFormat, readType;
- hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
- hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
- DbgContext* dbg = new DbgContext(version, hooks, MAX_VERTEX_ATTRIBS, readFormat, readType);
-
+ DbgContext* dbg = new DbgContext(version, hooks, MAX_VERTEX_ATTRIBS);
glesv2debugger::Message msg, cmd;
msg.set_context_id(reinterpret_cast<int>(dbg));
msg.set_expect_response(false);
@@ -100,33 +94,31 @@
{
switch (type) {
case GL_UNSIGNED_SHORT_5_6_5:
- return 2;
case GL_UNSIGNED_SHORT_4_4_4_4:
- return 2;
case GL_UNSIGNED_SHORT_5_5_5_1:
return 2;
case GL_UNSIGNED_BYTE:
break;
default:
- assert(0);
+ LOGE("GetBytesPerPixel: unknown type %x", type);
}
switch (format) {
case GL_ALPHA:
- return 1;
case GL_LUMINANCE:
return 1;
- break;
case GL_LUMINANCE_ALPHA:
return 2;
case GL_RGB:
return 3;
case GL_RGBA:
+ case 0x80E1: // GL_BGRA_EXT
return 4;
default:
- assert(0);
- return 0;
+ LOGE("GetBytesPerPixel: unknown format %x", format);
}
+
+ return 1; // in doubt...
}
void DbgContext::Fetch(const unsigned index, std::string * const data) const
diff --git a/opengl/libs/GLES2_dbg/src/egl.cpp b/opengl/libs/GLES2_dbg/src/egl.cpp
index eb28d06..bbea3bd 100644
--- a/opengl/libs/GLES2_dbg/src/egl.cpp
+++ b/opengl/libs/GLES2_dbg/src/egl.cpp
@@ -41,11 +41,11 @@
void * pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] *
dbg->readBytesPerPixel);
dbg->hooks->gl.glReadPixels(viewport[0], viewport[1], viewport[2],
- viewport[3], dbg->readFormat, dbg->readType, pixels);
+ viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, pixels);
dbg->CompressReadPixelBuffer(msg.mutable_data());
msg.set_data_type(msg.ReferencedImage);
- msg.set_pixel_format(dbg->readFormat);
- msg.set_pixel_type(dbg->readType);
+ msg.set_pixel_format(GL_RGBA);
+ msg.set_pixel_type(GL_UNSIGNED_BYTE);
msg.set_image_width(viewport[2]);
msg.set_image_height(viewport[3]);
}
diff --git a/opengl/libs/GLES2_dbg/src/header.h b/opengl/libs/GLES2_dbg/src/header.h
index f2b1fa6..49f3847 100644
--- a/opengl/libs/GLES2_dbg/src/header.h
+++ b/opengl/libs/GLES2_dbg/src/header.h
@@ -87,7 +87,6 @@
const unsigned int version; // 0 is GLES1, 1 is GLES2
const gl_hooks_t * const hooks;
const unsigned int MAX_VERTEX_ATTRIBS;
- const GLenum readFormat, readType; // implementation supported glReadPixels
const unsigned int readBytesPerPixel;
unsigned int captureSwap; // number of eglSwapBuffers to glReadPixels
@@ -124,8 +123,7 @@
unsigned maxAttrib; // number of slots used by program
DbgContext(const unsigned version, const gl_hooks_t * const hooks,
- const unsigned MAX_VERTEX_ATTRIBS, const GLenum readFormat,
- const GLenum readType);
+ const unsigned MAX_VERTEX_ATTRIBS);
~DbgContext();
void Fetch(const unsigned index, std::string * const data) const;
diff --git a/opengl/libs/GLES2_dbg/src/vertex.cpp b/opengl/libs/GLES2_dbg/src/vertex.cpp
index 029ee3b..28a2420 100644
--- a/opengl/libs/GLES2_dbg/src/vertex.cpp
+++ b/opengl/libs/GLES2_dbg/src/vertex.cpp
@@ -77,7 +77,7 @@
pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] *
dbg->readBytesPerPixel);
Debug_glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
- dbg->readFormat, dbg->readType, pixels);
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
break;
case glesv2debugger::Message_Function_SKIP:
@@ -134,19 +134,22 @@
msg.set_arg7(dbg->maxAttrib); // indicate capturing vertex data
std::string * const data = msg.mutable_data();
if (GL_UNSIGNED_BYTE == type) {
- if (dbg->indexBuffer)
+ if (dbg->indexBuffer) {
FetchIndexed(count, (unsigned char *)dbg->indexBuffer->data +
(unsigned long)indices, data, dbg);
- else
+ } else {
FetchIndexed(count, (unsigned char *)indices, data, dbg);
+ }
} else if (GL_UNSIGNED_SHORT == type) {
- if (dbg->indexBuffer)
+ if (dbg->indexBuffer) {
FetchIndexed(count, (unsigned short *)((char *)dbg->indexBuffer->data +
(unsigned long)indices), data, dbg);
- else
+ } else {
FetchIndexed(count, (unsigned short *)indices, data, dbg);
- } else
+ }
+ } else {
assert(0);
+ }
void * pixels = NULL;
int viewport[4] = {};
@@ -174,7 +177,7 @@
Send(msg, cmd);
expectResponse = cmd.expect_response();
// TODO: pack glReadPixels data with vertex data instead of
- // relying on sperate call for transport, this would allow
+ // relying on separate call for transport, this would allow
// auto generated message loop using EXTEND_Debug macro
if (dbg->captureDraw > 0) {
dbg->captureDraw--;
@@ -182,7 +185,7 @@
pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] *
dbg->readBytesPerPixel);
Debug_glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
- dbg->readFormat, dbg->readType, pixels);
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
break;
case glesv2debugger::Message_Function_SKIP:
diff --git a/opengl/libs/GLES2_dbg/test/test_main.cpp b/opengl/libs/GLES2_dbg/test/test_main.cpp
index 058bea4..183bf8e 100644
--- a/opengl/libs/GLES2_dbg/test/test_main.cpp
+++ b/opengl/libs/GLES2_dbg/test/test_main.cpp
@@ -29,7 +29,7 @@
gl_hooks_t hooks;
DbgContextTest()
- : dbg(1, &hooks, 32, GL_RGBA, GL_UNSIGNED_BYTE) {
+ : dbg(1, &hooks, 32) {
// You can do set-up work for each test here.
hooks.gl.glGetError = GetError;
}
diff --git a/opengl/libs/GLES2_dbg/test/test_server.cpp b/opengl/libs/GLES2_dbg/test/test_server.cpp
index bbbe913..0ab87b0 100644
--- a/opengl/libs/GLES2_dbg/test/test_server.cpp
+++ b/opengl/libs/GLES2_dbg/test/test_server.cpp
@@ -151,7 +151,7 @@
virtual void SetUp() {
ServerFileTest::SetUp();
- dbg = new DbgContext(1, &hooks, 32, GL_RGBA, GL_UNSIGNED_BYTE);
+ dbg = new DbgContext(1, &hooks, 32);
ASSERT_NE((void *)NULL, dbg);
for (unsigned int i = 0; i < sizeof(hooks) / sizeof(void *); i++)
((void **)&hooks)[i] = reinterpret_cast<void *>(glNoop);
diff --git a/opengl/libs/GLES2_dbg/test/test_socket.cpp b/opengl/libs/GLES2_dbg/test/test_socket.cpp
index b2148ac..9f815e2 100644
--- a/opengl/libs/GLES2_dbg/test/test_socket.cpp
+++ b/opengl/libs/GLES2_dbg/test/test_socket.cpp
@@ -44,7 +44,7 @@
}
virtual void SetUp() {
- dbg = new DbgContext(1, &hooks, 32, GL_RGBA, GL_UNSIGNED_BYTE);
+ dbg = new DbgContext(1, &hooks, 32);
ASSERT_TRUE(dbg != NULL);
for (unsigned int i = 0; i < sizeof(hooks) / sizeof(void *); i++)
((void **)&hooks)[i] = (void *)glNoop;
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 51eb0a3..dab0705 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -22,6 +22,9 @@
ifeq ($(TARGET_BOARD_PLATFORM), omap3)
LOCAL_CFLAGS += -DNO_RGBX_8888
endif
+ifeq ($(TARGET_BOARD_PLATFORM), omap4)
+ LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
+endif
ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY -DNEVER_DEFAULT_TO_ASYNC_MODE
endif
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
index 59b7e5a..3b7c09e 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
@@ -122,7 +122,7 @@
DisplayHardwareBase::DisplayHardwareBase(const sp<SurfaceFlinger>& flinger,
uint32_t displayIndex)
- : mCanDraw(true), mScreenAcquired(true)
+ : mScreenAcquired(true)
{
mDisplayEventThread = new DisplayEventThread(flinger);
}
@@ -133,14 +133,9 @@
mDisplayEventThread->requestExitAndWait();
}
-void DisplayHardwareBase::setCanDraw(bool canDraw)
-{
- mCanDraw = canDraw;
-}
-
bool DisplayHardwareBase::canDraw() const
{
- return mCanDraw && mScreenAcquired;
+ return mScreenAcquired;
}
void DisplayHardwareBase::releaseScreen() const
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h
index 3ebc7b6..ef2df43 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h
@@ -43,7 +43,6 @@
bool isScreenAcquired() const;
bool canDraw() const;
- void setCanDraw(bool canDraw);
private:
@@ -74,7 +73,6 @@
};
sp<DisplayEventThreadBase> mDisplayEventThread;
- mutable int mCanDraw;
mutable int mScreenAcquired;
};
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 879e858..be9b226 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -75,7 +75,7 @@
}
void HWComposer::invalidate() {
- mFlinger->signalEvent();
+ mFlinger->repaintEverything();
}
void HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) {
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 1361fd6..feb2c52 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -112,6 +112,11 @@
mSurfaceTexture->abandon();
}
+void Layer::setName(const String8& name) {
+ LayerBase::setName(name);
+ mSurfaceTexture->setName(name);
+}
+
sp<ISurface> Layer::createSurface()
{
class BSurface : public BnSurface, public LayerCleaner {
@@ -275,20 +280,29 @@
return;
}
- const GLenum target = GL_TEXTURE_EXTERNAL_OES;
- glBindTexture(target, mTextureName);
- if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) {
- // TODO: we could be more subtle with isFixedSize()
- glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ GLenum target = GL_TEXTURE_EXTERNAL_OES;
+ if (!isProtected()) {
+ glBindTexture(target, mTextureName);
+ if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) {
+ // TODO: we could be more subtle with isFixedSize()
+ glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ } else {
+ glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ }
+ glEnable(target);
+ glMatrixMode(GL_TEXTURE);
+ glLoadMatrixf(mTextureMatrix);
+ glMatrixMode(GL_MODELVIEW);
} else {
- glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ target = GL_TEXTURE_2D;
+ glBindTexture(target, mFlinger->getProtectedTexName());
+ glEnable(target);
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
}
- glEnable(target);
- glMatrixMode(GL_TEXTURE);
- glLoadMatrixf(mTextureMatrix);
- glMatrixMode(GL_MODELVIEW);
drawWithOpenGL(clip);
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index ff389ae..82e3521 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -74,6 +74,7 @@
virtual bool isProtected() const;
virtual void onRemoved();
virtual sp<Layer> getLayer() const { return const_cast<Layer*>(this); }
+ virtual void setName(const String8& name);
// LayerBaseClient interface
virtual wp<IBinder> getSurfaceTextureBinder() const;
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 268ba2d..7f62145 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -81,7 +81,7 @@
Region transparentRegion;
};
- void setName(const String8& name);
+ virtual void setName(const String8& name);
String8 getName() const;
// modify current state
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2be6d18..195ad2e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -84,7 +84,6 @@
mBootTime(systemTime()),
mVisibleRegionsDirty(false),
mHwWorkListDirty(false),
- mDeferReleaseConsole(false),
mFreezeDisplay(false),
mElectronBeamAnimationMode(0),
mFreezeCount(0),
@@ -275,7 +274,7 @@
const uint16_t g0 = pack565(0x0F,0x1F,0x0F);
const uint16_t g1 = pack565(0x17,0x2f,0x17);
- const uint16_t textureData[4] = { g0, g1, g1, g0 };
+ const uint16_t wormholeTexData[4] = { g0, g1, g1, g0 };
glGenTextures(1, &mWormholeTexName);
glBindTexture(GL_TEXTURE_2D, mWormholeTexName);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -283,7 +282,17 @@
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0,
- GL_RGB, GL_UNSIGNED_SHORT_5_6_5, textureData);
+ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, wormholeTexData);
+
+ const uint16_t protTexData[] = { pack565(0x03, 0x03, 0x03) };
+ glGenTextures(1, &mProtectedTexName);
+ glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0,
+ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
@@ -493,17 +502,9 @@
SurfaceFlinger::turnElectronBeamOn(mElectronBeamAnimationMode);
}
- if (mDeferReleaseConsole && hw.isScreenAcquired()) {
- // We got the release signal before the acquire signal
- mDeferReleaseConsole = false;
- hw.releaseScreen();
- }
-
if (what & eConsoleReleased) {
if (hw.isScreenAcquired()) {
hw.releaseScreen();
- } else {
- mDeferReleaseConsole = true;
}
}
@@ -566,7 +567,7 @@
const int dpy = 0;
const int orientation = mCurrentState.orientation;
- const uint32_t type = mCurrentState.orientationType;
+ // Currently unused: const uint32_t flags = mCurrentState.orientationFlags;
GraphicPlane& plane(graphicPlane(dpy));
plane.setOrientation(orientation);
@@ -1300,7 +1301,7 @@
Mutex::Autolock _l(mStateLock);
if (mCurrentState.orientation != orientation) {
if (uint32_t(orientation)<=eOrientation270 || orientation==42) {
- mCurrentState.orientationType = flags;
+ mCurrentState.orientationFlags = flags;
mCurrentState.orientation = orientation;
setTransactionFlags(eTransactionNeeded);
mTransactionCV.wait(mStateLock);
@@ -1804,6 +1805,8 @@
// redraw the screen entirely...
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ);
const size_t count = layers.size();
for (size_t i=0 ; i<count ; ++i) {
@@ -1835,7 +1838,7 @@
const DisplayHardware& hw(graphicPlane(0).displayHardware());
const uint32_t hw_w = hw.getWidth();
const uint32_t hw_h = hw.getHeight();
- const Region screenBounds(hw.bounds());
+ const Region screenBounds(hw.getBounds());
GLfloat u, v;
GLuint tname;
@@ -1845,7 +1848,7 @@
}
GLfloat vtx[8];
- const GLfloat texCoords[4][2] = { {0,1}, {0,1-v}, {u,1-v}, {u,1} };
+ const GLfloat texCoords[4][2] = { {0,0}, {0,v}, {u,v}, {u,0} };
glBindTexture(GL_TEXTURE_2D, tname);
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -1931,6 +1934,12 @@
s_curve_interpolator itb(nbFrames, 8.5f);
v_stretch vverts(hw_w, hw_h);
+
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
for (int i=0 ; i<nbFrames ; i++) {
@@ -2159,7 +2168,6 @@
glEnable(GL_SCISSOR_TEST);
hw.flip( Region(hw.bounds()) );
- hw.setCanDraw(false);
return NO_ERROR;
}
@@ -2208,7 +2216,6 @@
if (mode & ISurfaceComposer::eElectronBeamAnimationOn) {
electronBeamOnAnimationImplLocked();
}
- hw.setCanDraw(true);
// make sure to redraw the whole screen when the animation is done
mDirtyRegion.set(hw.bounds());
@@ -2255,22 +2262,6 @@
if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
return BAD_VALUE;
- // make sure none of the layers are protected
- const LayerVector& layers(mDrawingState.layersSortedByZ);
- const size_t count = layers.size();
- for (size_t i=0 ; i<count ; ++i) {
- const sp<LayerBase>& layer(layers[i]);
- const uint32_t flags = layer->drawingState().flags;
- if (!(flags & ISurfaceComposer::eLayerHidden)) {
- const uint32_t z = layer->drawingState().z;
- if (z >= minLayerZ && z <= maxLayerZ) {
- if (layer->isProtected()) {
- return INVALID_OPERATION;
- }
- }
- }
- }
-
if (!GLExtensions::getInstance().haveFramebufferObject())
return INVALID_OPERATION;
@@ -2320,6 +2311,8 @@
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
+ const LayerVector& layers(mDrawingState.layersSortedByZ);
+ const size_t count = layers.size();
for (size_t i=0 ; i<count ; ++i) {
const sp<LayerBase>& layer(layers[i]);
const uint32_t flags = layer->drawingState().flags;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index d7f005f..1cb9be2 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -192,6 +192,8 @@
sp<Layer> getLayer(const sp<ISurface>& sur) const;
+ GLuint getProtectedTexName() const { return mProtectedTexName; }
+
private:
// DeathRecipient interface
virtual void binderDied(const wp<IBinder>& who);
@@ -245,7 +247,7 @@
}
LayerVector layersSortedByZ;
uint8_t orientation;
- uint8_t orientationType;
+ uint8_t orientationFlags;
uint8_t freezeDisplay;
};
@@ -256,12 +258,11 @@
public: // hack to work around gcc 4.0.3 bug
const GraphicPlane& graphicPlane(int dpy) const;
GraphicPlane& graphicPlane(int dpy);
-private:
+ void signalEvent();
+ void repaintEverything();
- void waitForEvent();
-public: // hack to work around gcc 4.0.3 bug
- void signalEvent();
private:
+ void waitForEvent();
void handleConsoleEvents();
void handleTransaction(uint32_t transactionFlags);
void handleTransactionLocked(uint32_t transactionFlags);
@@ -279,7 +280,6 @@
void postFramebuffer();
void setupHardwareComposer(Region& dirtyInOut);
void composeSurfaces(const Region& dirty);
- void repaintEverything();
ssize_t addClientLayer(const sp<Client>& client,
@@ -351,6 +351,7 @@
sp<IMemoryHeap> mServerHeap;
surface_flinger_cblk_t* mServerCblk;
GLuint mWormholeTexName;
+ GLuint mProtectedTexName;
nsecs_t mBootTime;
// Can only accessed from the main thread, these members
@@ -362,7 +363,6 @@
Region mWormholeRegion;
bool mVisibleRegionsDirty;
bool mHwWorkListDirty;
- bool mDeferReleaseConsole;
bool mFreezeDisplay;
int32_t mElectronBeamAnimationMode;
int32_t mFreezeCount;