am cf1edb3f
: Merge "Fix libgui crop matrix test."
* commit 'cf1edb3f3ece597dcf9c3f4ae018374550e8b561': Fix libgui crop matrix test.
This commit is contained in:
commit
67ff12d952
@ -27,6 +27,9 @@
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Thread.h>
|
||||
|
||||
EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
|
||||
#define CROP_EXT_STR "EGL_ANDROID_image_crop"
|
||||
|
||||
namespace android {
|
||||
|
||||
class SurfaceTextureClientTest : public ::testing::Test {
|
||||
@ -615,6 +618,18 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffers)
|
||||
}
|
||||
|
||||
TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWithCrop) {
|
||||
// Query to see if the image crop extension exists
|
||||
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
const char* exts = eglQueryStringImplementationANDROID(dpy, EGL_EXTENSIONS);
|
||||
size_t cropExtLen = strlen(CROP_EXT_STR);
|
||||
size_t extsLen = strlen(exts);
|
||||
bool equal = !strcmp(CROP_EXT_STR, exts);
|
||||
bool atStart = !strncmp(CROP_EXT_STR " ", exts, cropExtLen+1);
|
||||
bool atEnd = (cropExtLen+1) < extsLen &&
|
||||
!strcmp(" " CROP_EXT_STR, exts + extsLen - (cropExtLen+1));
|
||||
bool inMiddle = strstr(exts, " " CROP_EXT_STR " ");
|
||||
bool hasEglAndroidImageCrop = equal || atStart || atEnd || inMiddle;
|
||||
|
||||
android_native_buffer_t* buf[3];
|
||||
float mtx[16] = {};
|
||||
android_native_rect_t crop;
|
||||
@ -633,15 +648,17 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi
|
||||
ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 6)); // frees buffers
|
||||
mST->getTransformMatrix(mtx);
|
||||
|
||||
// This accounts for the .5 texel shrink for each edge that's included in the
|
||||
// transform matrix to avoid texturing outside the crop region.
|
||||
EXPECT_EQ(0.5, mtx[0]);
|
||||
// If the egl image crop extension is not present, this accounts for the
|
||||
// .5 texel shrink for each edge that's included in the transform matrix
|
||||
// to avoid texturing outside the crop region. Otherwise the crop is not
|
||||
// included in the transform matrix.
|
||||
EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5, mtx[0]);
|
||||
EXPECT_EQ(0.f, mtx[1]);
|
||||
EXPECT_EQ(0.f, mtx[2]);
|
||||
EXPECT_EQ(0.f, mtx[3]);
|
||||
|
||||
EXPECT_EQ(0.f, mtx[4]);
|
||||
EXPECT_EQ(-0.5, mtx[5]);
|
||||
EXPECT_EQ(hasEglAndroidImageCrop ? -1 : -0.5, mtx[5]);
|
||||
EXPECT_EQ(0.f, mtx[6]);
|
||||
EXPECT_EQ(0.f, mtx[7]);
|
||||
|
||||
@ -650,8 +667,8 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi
|
||||
EXPECT_EQ(1.f, mtx[10]);
|
||||
EXPECT_EQ(0.f, mtx[11]);
|
||||
|
||||
EXPECT_EQ(0.0625f, mtx[12]);
|
||||
EXPECT_EQ(0.5625f, mtx[13]);
|
||||
EXPECT_EQ(hasEglAndroidImageCrop ? 0 : 0.0625f, mtx[12]);
|
||||
EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5625f, mtx[13]);
|
||||
EXPECT_EQ(0.f, mtx[14]);
|
||||
EXPECT_EQ(1.f, mtx[15]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user