Merge "Improve camera face detection javadoc." into ics-mr1
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index e2d6179..d7dd4d6 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -79,7 +79,11 @@
// pointed to by the buf argument and a status of OK is returned. If no
// slot is available then a status of -EBUSY is returned and buf is
// unmodified.
- virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h,
+ // The width and height parameters must be no greater than the minimum of
+ // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
+ // An error due to invalid dimensions might not be reported until
+ // updateTexImage() is called.
+ virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height,
uint32_t format, uint32_t usage);
// queueBuffer returns a filled buffer to the SurfaceTexture. In addition, a
@@ -176,7 +180,11 @@
// requestBuffers when a with and height of zero is requested.
// A call to setDefaultBufferSize() may trigger requestBuffers() to
// be called from the client.
- status_t setDefaultBufferSize(uint32_t w, uint32_t h);
+ // The width and height parameters must be no greater than the minimum of
+ // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
+ // An error due to invalid dimensions might not be reported until
+ // updateTexImage() is called.
+ status_t setDefaultBufferSize(uint32_t width, uint32_t height);
// getCurrentBuffer returns the buffer associated with the current image.
sp<GraphicBuffer> getCurrentBuffer() const;
diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp
index 5daafd5..93ebfb9 100644
--- a/libs/gui/tests/SurfaceTexture_test.cpp
+++ b/libs/gui/tests/SurfaceTexture_test.cpp
@@ -1520,4 +1520,36 @@
EXPECT_EQ(1, buffers[2]->getStrongCount());
}
+TEST_F(SurfaceTextureGLTest, InvalidWidthOrHeightFails) {
+ int texHeight = 16;
+ ANativeWindowBuffer* anb;
+
+ GLint maxTextureSize;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
+
+ // make sure it works with small textures
+ mST->setDefaultBufferSize(16, texHeight);
+ EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+ EXPECT_EQ(16, anb->width);
+ EXPECT_EQ(texHeight, anb->height);
+ EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb));
+ EXPECT_EQ(NO_ERROR, mST->updateTexImage());
+
+ // make sure it works with GL_MAX_TEXTURE_SIZE
+ mST->setDefaultBufferSize(maxTextureSize, texHeight);
+ EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+ EXPECT_EQ(maxTextureSize, anb->width);
+ EXPECT_EQ(texHeight, anb->height);
+ EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb));
+ EXPECT_EQ(NO_ERROR, mST->updateTexImage());
+
+ // make sure it fails with GL_MAX_TEXTURE_SIZE+1
+ mST->setDefaultBufferSize(maxTextureSize+1, texHeight);
+ EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+ EXPECT_EQ(maxTextureSize+1, anb->width);
+ EXPECT_EQ(texHeight, anb->height);
+ EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb));
+ ASSERT_NE(NO_ERROR, mST->updateTexImage());
+}
+
} // namespace android
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
index 8e8e26c..c926670 100644
--- a/opengl/include/EGL/eglext.h
+++ b/opengl/include/EGL/eglext.h
@@ -261,14 +261,14 @@
*/
#ifndef EGL_ANDROID_blob_cache
#define EGL_ANDROID_blob_cache 1
-typedef khronos_ssize_t EGLsizei;
-typedef void (*EGLSetBlobFunc) (const void* key, EGLsizei keySize, const void* value, EGLsizei valueSize);
-typedef EGLsizei (*EGLGetBlobFunc) (const void* key, EGLsizei keySize, void* value, EGLsizei valueSize);
+typedef khronos_ssize_t EGLsizeiANDROID;
+typedef void (*EGLSetBlobFuncANDROID) (const void* key, EGLsizeiANDROID keySize, const void* value, EGLsizeiANDROID valueSize);
+typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void* key, EGLsizeiANDROID keySize, void* value, EGLsizeiANDROID valueSize);
#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncs(EGLDisplay dpy, EGLSetBlobFunc set, EGLGetBlobFunc get);
+EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSPROC) (EGLDisplay dpy,
- EGLSetBlobFunc set, EGLGetBlobFunc get);
+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy,
+ EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
#endif
#ifdef __cplusplus
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 60ac34b..63f02e4 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -860,7 +860,7 @@
// The EGL_ANDROID_blob_cache extension should not be exposed to
// applications. It is used internally by the Android EGL layer.
- if (!strcmp(procname, "eglSetBlobCacheFuncs")) {
+ if (!strcmp(procname, "eglSetBlobCacheFuncsANDROID")) {
return NULL;
}
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index 522421b..13a4929 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -46,13 +46,13 @@
//
// Callback functions passed to EGL.
//
-static void setBlob(const void* key, EGLsizei keySize, const void* value,
- EGLsizei valueSize) {
+static void setBlob(const void* key, EGLsizeiANDROID keySize,
+ const void* value, EGLsizeiANDROID valueSize) {
egl_cache_t::get()->setBlob(key, keySize, value, valueSize);
}
-static EGLsizei getBlob(const void* key, EGLsizei keySize, void* value,
- EGLsizei valueSize) {
+static EGLsizeiANDROID getBlob(const void* key, EGLsizeiANDROID keySize,
+ void* value, EGLsizeiANDROID valueSize) {
return egl_cache_t::get()->getBlob(key, keySize, value, valueSize);
}
@@ -87,22 +87,23 @@
!strcmp(" " BC_EXT_STR, exts + extsLen - (bcExtLen+1));
bool inMiddle = strstr(" " BC_EXT_STR " ", exts);
if (equal || atStart || atEnd || inMiddle) {
- PFNEGLSETBLOBCACHEFUNCSPROC eglSetBlobCacheFuncs;
- eglSetBlobCacheFuncs =
- reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSPROC>(
- cnx->egl.eglGetProcAddress("eglSetBlobCacheFuncs"));
- if (eglSetBlobCacheFuncs == NULL) {
+ PFNEGLSETBLOBCACHEFUNCSANDROIDPROC eglSetBlobCacheFuncsANDROID;
+ eglSetBlobCacheFuncsANDROID =
+ reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSANDROIDPROC>(
+ cnx->egl.eglGetProcAddress(
+ "eglSetBlobCacheFuncsANDROID"));
+ if (eglSetBlobCacheFuncsANDROID == NULL) {
LOGE("EGL_ANDROID_blob_cache advertised by display %d, "
- "but unable to get eglSetBlobCacheFuncs", i);
+ "but unable to get eglSetBlobCacheFuncsANDROID", i);
continue;
}
- eglSetBlobCacheFuncs(display->disp[i].dpy, android::setBlob,
- android::getBlob);
+ eglSetBlobCacheFuncsANDROID(display->disp[i].dpy,
+ android::setBlob, android::getBlob);
EGLint err = cnx->egl.eglGetError();
if (err != EGL_SUCCESS) {
- LOGE("eglSetBlobCacheFuncs resulted in an error: %#x",
- err);
+ LOGE("eglSetBlobCacheFuncsANDROID resulted in an error: "
+ "%#x", err);
}
}
}
@@ -119,8 +120,8 @@
mInitialized = false;
}
-void egl_cache_t::setBlob(const void* key, EGLsizei keySize, const void* value,
- EGLsizei valueSize) {
+void egl_cache_t::setBlob(const void* key, EGLsizeiANDROID keySize,
+ const void* value, EGLsizeiANDROID valueSize) {
Mutex::Autolock lock(mMutex);
if (keySize < 0 || valueSize < 0) {
@@ -158,8 +159,8 @@
}
}
-EGLsizei egl_cache_t::getBlob(const void* key, EGLsizei keySize, void* value,
- EGLsizei valueSize) {
+EGLsizeiANDROID egl_cache_t::getBlob(const void* key, EGLsizeiANDROID keySize,
+ void* value, EGLsizeiANDROID valueSize) {
Mutex::Autolock lock(mMutex);
if (keySize < 0 || valueSize < 0) {
@@ -323,7 +324,8 @@
return;
}
- status_t err = mBlobCache->unflatten(buf + headerSize, cacheSize, NULL, 0);
+ status_t err = mBlobCache->unflatten(buf + headerSize, cacheSize, NULL,
+ 0);
if (err != OK) {
LOGE("error reading cache contents: %s (%d)", strerror(-err),
-err);
diff --git a/opengl/libs/EGL/egl_cache.h b/opengl/libs/EGL/egl_cache.h
index 4389623..8760009 100644
--- a/opengl/libs/EGL/egl_cache.h
+++ b/opengl/libs/EGL/egl_cache.h
@@ -52,14 +52,14 @@
// setBlob attempts to insert a new key/value blob pair into the cache.
// This will be called by the hardware vendor's EGL implementation via the
// EGL_ANDROID_blob_cache extension.
- void setBlob(const void* key, EGLsizei keySize, const void* value,
- EGLsizei valueSize);
+ void setBlob(const void* key, EGLsizeiANDROID keySize, const void* value,
+ EGLsizeiANDROID valueSize);
// getBlob attempts to retrieve the value blob associated with a given key
// blob from cache. This will be called by the hardware vendor's EGL
// implementation via the EGL_ANDROID_blob_cache extension.
- EGLsizei getBlob(const void* key, EGLsizei keySize, void* value,
- EGLsizei valueSize);
+ EGLsizeiANDROID getBlob(const void* key, EGLsizeiANDROID keySize,
+ void* value, EGLsizeiANDROID valueSize);
// setCacheFilename sets the name of the file that should be used to store
// cache contents from one program invocation to another.
diff --git a/opengl/specs/EGL_ANDROID_blob_cache.txt b/opengl/specs/EGL_ANDROID_blob_cache.txt
index 55dc900..61f45d3 100644
--- a/opengl/specs/EGL_ANDROID_blob_cache.txt
+++ b/opengl/specs/EGL_ANDROID_blob_cache.txt
@@ -63,33 +63,33 @@
New Types
/*
- * EGLsizei is a signed integer type for representing the size of a memory
- * buffer.
+ * EGLsizeiANDROID is a signed integer type for representing the size of a
+ * memory buffer.
*/
#include <khrplatform.h>
- typedef khronos_ssize_t EGLsizei;
+ typedef khronos_ssize_t EGLsizeiANDROID;
/*
* EGLSetBlobFunc is a pointer to an application-provided function that a
* client API implementation may use to insert a key/value pair into the
* cache.
*/
- typedef void (*EGLSetBlobFunc) (const void* key, EGLsizei keySize,
- const void* value, EGLsizei valueSize)
+ typedef void (*EGLSetBlobFuncANDROID) (const void* key,
+ EGLsizeiANDROID keySize, const void* value, EGLsizeiANDROID valueSize)
/*
* EGLGetBlobFunc is a pointer to an application-provided function that a
* client API implementation may use to retrieve a cached value from the
* cache.
*/
- typedef EGLsizei (*EGLGetBlobFunc) (const void* key, EGLsizei keySize,
- void* value, EGLsizei valueSize)
+ typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void* key,
+ EGLsizeiANDROID keySize, void* value, EGLsizeiANDROID valueSize)
New Procedures and Functions
- void eglSetBlobCacheFuncs(EGLDisplay dpy,
- EGLSetBlobFunc set,
- EGLGetBlobFunc get);
+ void eglSetBlobCacheFuncsANDROID(EGLDisplay dpy,
+ EGLSetBlobFunc set,
+ EGLGetBlobFunc get);
New Tokens
@@ -107,8 +107,8 @@
function pointers through which the client APIs can request data be cached
and retrieved. The command
- void eglSetBlobCacheFuncs(EGLDisplay dpy,
- EGLSetBlobFunc set, EGLGetBlobFunc get);
+ void eglSetBlobCacheFuncsANDROID(EGLDisplay dpy,
+ EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
sets the callback function pointers that client APIs associated with
display <dpy> can use to interact with caching functionality provided by
@@ -120,17 +120,17 @@
Cache functions may only be specified once during the lifetime of an
EGLDisplay. The <set> and <get> functions may be called at any time and
- from any thread from the time at which eglSetBlobCacheFuncs is called until
- the time that the last resource associated with <dpy> is deleted and <dpy>
- itself is terminated. Concurrent calls to these functions from different
- threads is also allowed.
+ from any thread from the time at which eglSetBlobCacheFuncsANDROID is
+ called until the time that the last resource associated with <dpy> is
+ deleted and <dpy> itself is terminated. Concurrent calls to these
+ functions from different threads is also allowed.
- If eglSetBlobCacheFuncs generates an error then all client APIs must behave
- as though eglSetBlobCacheFuncs was not called for the display <dpy>. If
- <set> or <get> is NULL then an EGL_BAD_PARAMETER error is generated. If a
- successful eglSetBlobCacheFuncs call was already made for <dpy> and the
- display has not since been terminated then an EGL_BAD_PARAMETER error is
- generated.
+ If eglSetBlobCacheFuncsANDROID generates an error then all client APIs must
+ behave as though eglSetBlobCacheFuncsANDROID was not called for the display
+ <dpy>. If <set> or <get> is NULL then an EGL_BAD_PARAMETER error is
+ generated. If a successful eglSetBlobCacheFuncsANDROID call was already
+ made for <dpy> and the display has not since been terminated then an
+ EGL_BAD_PARAMETER error is generated.
3.9.1 Cache Operations
@@ -138,8 +138,8 @@
key, a client API implementation can call the application-provided callback
function
- void (*set) (const void* key, EGLsizei keySize, const void* value,
- EGLsizei valueSize)
+ void (*set) (const void* key, EGLsizeiANDROID keySize,
+ const void* value, EGLsizeiANDROID valueSize)
<key> and <value> are pointers to the beginning of the key and value,
respectively, that are to be inserted. <keySize> and <valueSize> specify
@@ -157,8 +157,8 @@
client API implementation can call the application-provided callback
function
- EGLsizei (*get) (const void* key, EGLsizei keySize, void* value,
- EGLsizei valueSize)
+ EGLsizeiANDROID (*get) (const void* key, EGLsizeiANDROID keySize,
+ void* value, EGLsizeiANDROID valueSize)
<key> is a pointer to the beginning of the key. <keySize> specifies the
size in bytes of the binary key pointed to by <key>. If the cache contains