am 00f47af8: Merge "SurfaceTexture: disallow unsupported uses." into honeycomb-mr1
* commit '00f47af85a98c6dc3b20d04d8ee6b9a327175ab6': SurfaceTexture: disallow unsupported uses.
This commit is contained in:
commit
0ce8f1b853
@ -14,8 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gui/SurfaceTextureClient.h>
|
#include <EGL/egl.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include <gui/SurfaceTextureClient.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
@ -57,4 +58,46 @@ TEST_F(SurfaceTextureClientTest, ConcreteTypeIsSurfaceTextureClient) {
|
|||||||
EXPECT_EQ(NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, result);
|
EXPECT_EQ(NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SurfaceTextureClientTest, ANativeWindowLockFails) {
|
||||||
|
sp<ANativeWindow> anw(mSTC);
|
||||||
|
ANativeWindow_Buffer buf;
|
||||||
|
ASSERT_EQ(BAD_VALUE, ANativeWindow_lock(anw.get(), &buf, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SurfaceTextureClientTest, EglCreateWindowSurfaceFails) {
|
||||||
|
sp<ANativeWindow> anw(mSTC);
|
||||||
|
|
||||||
|
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||||
|
ASSERT_NE(EGL_NO_DISPLAY, dpy);
|
||||||
|
|
||||||
|
EGLint majorVersion;
|
||||||
|
EGLint minorVersion;
|
||||||
|
EXPECT_TRUE(eglInitialize(dpy, &majorVersion, &minorVersion));
|
||||||
|
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||||
|
|
||||||
|
EGLConfig myConfig = {0};
|
||||||
|
EGLint numConfigs = 0;
|
||||||
|
EGLint configAttribs[] = {
|
||||||
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||||
|
EGL_RED_SIZE, 8,
|
||||||
|
EGL_GREEN_SIZE, 8,
|
||||||
|
EGL_BLUE_SIZE, 8,
|
||||||
|
EGL_ALPHA_SIZE, 8,
|
||||||
|
EGL_DEPTH_SIZE, 16,
|
||||||
|
EGL_STENCIL_SIZE, 8,
|
||||||
|
EGL_NONE };
|
||||||
|
EXPECT_TRUE(eglChooseConfig(dpy, configAttribs, &myConfig, 1,
|
||||||
|
&numConfigs));
|
||||||
|
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||||
|
|
||||||
|
EGLSurface eglSurface = eglCreateWindowSurface(dpy, myConfig, anw.get(),
|
||||||
|
NULL);
|
||||||
|
ASSERT_EQ(EGL_NO_SURFACE, eglSurface);
|
||||||
|
ASSERT_EQ(EGL_BAD_NATIVE_WINDOW, eglGetError());
|
||||||
|
|
||||||
|
eglTerminate(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1094,6 +1094,16 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
|
|||||||
EGLConfig iConfig = dp->configs[intptr_t(config)].config;
|
EGLConfig iConfig = dp->configs[intptr_t(config)].config;
|
||||||
EGLint format;
|
EGLint format;
|
||||||
|
|
||||||
|
// for now fail if the window is not a Surface.
|
||||||
|
int type = -1;
|
||||||
|
ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window);
|
||||||
|
if ((anw->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &type) != 0) ||
|
||||||
|
(type == NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT)) {
|
||||||
|
LOGE("native window is a SurfaceTextureClient (currently "
|
||||||
|
"unsupported)");
|
||||||
|
return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
|
||||||
|
}
|
||||||
|
|
||||||
// set the native window's buffers format to match this config
|
// set the native window's buffers format to match this config
|
||||||
if (cnx->egl.eglGetConfigAttrib(iDpy,
|
if (cnx->egl.eglGetConfigAttrib(iDpy,
|
||||||
iConfig, EGL_NATIVE_VISUAL_ID, &format)) {
|
iConfig, EGL_NATIVE_VISUAL_ID, &format)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user