ANativeWindow: add query for the concrete type.

This change adds a query to the ANativeWindow interface for getting the
concrete type of the ANativeWindow.

Bug: 4086509
Change-Id: I64aa86d72fbca3b52a98e1fc35608737781a3178
This commit is contained in:
Jamie Gennis 2011-03-14 15:00:06 -07:00
parent 827ebdbbff
commit 391bbe2246
6 changed files with 42 additions and 1 deletions

View File

@ -110,6 +110,14 @@ enum {
* conjunction with this query.
*/
NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
/* Get the concrete type of a ANativeWindow. See below for the list of
* possible return values.
*
* This query should not be used outside the Android framework and will
* likely be removed in the near future.
*/
NATIVE_WINDOW_CONCRETE_TYPE,
};
/* valid operations for the (*perform)() hook */
@ -142,6 +150,13 @@ enum {
NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
};
/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
enum {
NATIVE_WINDOW_FRAMEBUFFER, // FramebufferNativeWindow
NATIVE_WINDOW_SURFACE, // Surface
NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, // SurfaceTextureClient
};
struct ANativeWindow
{
#ifdef __cplusplus

View File

@ -160,6 +160,9 @@ int SurfaceTextureClient::query(int what, int* value) {
// SurfaceTextureClient currently never queues frames to SurfaceFlinger.
*value = 0;
return NO_ERROR;
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
return NO_ERROR;
}
return BAD_VALUE;
}

View File

@ -44,4 +44,12 @@ TEST_F(SurfaceTextureClientTest, QueuesToWindowCompositorIsFalse) {
EXPECT_EQ(0, result);
}
TEST_F(SurfaceTextureClientTest, ConcreteTypeIsSurfaceTextureClient) {
sp<ANativeWindow> anw(mSTC);
int result = -123;
int err = anw->query(anw.get(), NATIVE_WINDOW_CONCRETE_TYPE, &result);
EXPECT_EQ(NO_ERROR, err);
EXPECT_EQ(NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, result);
}
}

View File

@ -712,11 +712,15 @@ int Surface::query(int what, int* value)
case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
*value = MIN_UNDEQUEUED_BUFFERS;
return NO_ERROR;
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: {
sp<ISurfaceComposer> sf(ComposerService::getComposerService());
*value = sf->authenticateSurface(mSurface) ? 1 : 0;
return NO_ERROR;
}
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_SURFACE;
return NO_ERROR;
}
return BAD_VALUE;
}

View File

@ -130,4 +130,12 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersFail) {
ASSERT_TRUE(heap != NULL);
}
TEST_F(SurfaceTest, ConcreteTypeIsSurface) {
sp<ANativeWindow> anw(mSurface);
int result = -123;
int err = anw->query(anw.get(), NATIVE_WINDOW_CONCRETE_TYPE, &result);
EXPECT_EQ(NO_ERROR, err);
EXPECT_EQ(NATIVE_WINDOW_SURFACE, result);
}
}

View File

@ -286,6 +286,9 @@ int FramebufferNativeWindow::query(ANativeWindow* window,
case NATIVE_WINDOW_FORMAT:
*value = fb->format;
return NO_ERROR;
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_FRAMEBUFFER;
return NO_ERROR;
}
*value = 0;
return BAD_VALUE;