• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <gtest/gtest.h>
16 #include <iservice_registry.h>
17 #include <native_image.h>
18 #include <EGL/egl.h>
19 #include <EGL/eglext.h>
20 #include <sys/time.h>
21 #include <securec.h>
22 #include "graphic_common_c.h"
23 #include "surface_type.h"
24 #include "window.h"
25 #include "GLES/gl.h"
26 #include "buffer_log.h"
27 #include "surface.h"
28 #include "surface_image.h"
29 
30 using namespace testing;
31 using namespace testing::ext;
32 using namespace std;
33 
34 namespace OHOS::Rosen {
35 using GetPlatformDisplayExt = PFNEGLGETPLATFORMDISPLAYEXTPROC;
36 constexpr const char* EGL_EXT_PLATFORM_WAYLAND = "EGL_EXT_platform_wayland";
37 constexpr const char* EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland";
38 constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2;
39 constexpr char CHARACTER_WHITESPACE = ' ';
40 constexpr const char* CHARACTER_STRING_WHITESPACE = " ";
41 constexpr const char* EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT";
42 constexpr int32_t MATRIX_SIZE = 16;
43 struct TEST_IMAGE {
44     int a;
45     bool b;
46 };
47 
48 typedef struct OH_NativeImage_Tmp {
49     OHOS::sptr<OHOS::SurfaceImage> consumer;
50     OHOS::sptr<OHOS::IBufferProducer> producer;
51     OHOS::sptr<OHOS::Surface> pSurface = nullptr;
52     struct NativeWindow* nativeWindow = nullptr;
53 } OH_NativeImage_Tmp;
54 
CheckEglExtension(const char * extensions,const char * extension)55 static bool CheckEglExtension(const char* extensions, const char* extension)
56 {
57     size_t extlen = strlen(extension);
58     const char* end = extensions + strlen(extensions);
59 
60     while (extensions < end) {
61         size_t n = 0;
62         /* Skip whitespaces, if any */
63         if (*extensions == CHARACTER_WHITESPACE) {
64             extensions++;
65             continue;
66         }
67         n = strcspn(extensions, CHARACTER_STRING_WHITESPACE);
68         /* Compare strings */
69         if (n == extlen && strncmp(extension, extensions, n) == 0) {
70             return true; /* Found */
71         }
72         extensions += n;
73     }
74     /* Not found */
75     return false;
76 }
77 
GetPlatformEglDisplay(EGLenum platform,void * nativeDisplay,const EGLint * attribList)78 static EGLDisplay GetPlatformEglDisplay(EGLenum platform, void* nativeDisplay, const EGLint* attribList)
79 {
80     static GetPlatformDisplayExt eglGetPlatformDisplayExt = NULL;
81 
82     if (!eglGetPlatformDisplayExt) {
83         const char* extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
84         if (extensions &&
85             (CheckEglExtension(extensions, EGL_EXT_PLATFORM_WAYLAND) ||
86                 CheckEglExtension(extensions, EGL_KHR_PLATFORM_WAYLAND))) {
87             eglGetPlatformDisplayExt = (GetPlatformDisplayExt)eglGetProcAddress(EGL_GET_PLATFORM_DISPLAY_EXT);
88         }
89     }
90 
91     if (eglGetPlatformDisplayExt) {
92         return eglGetPlatformDisplayExt(platform, nativeDisplay, attribList);
93     }
94 
95     return eglGetDisplay((EGLNativeDisplayType)nativeDisplay);
96 }
97 
98 class NativeImageSystemOpenGLTest : public testing::Test {
99 public:
100     static void SetUpTestCase();
101     static void TearDownTestCase();
102     static void InitEglContext();
103     static void Deinit();
104     static inline OH_NativeImage* image = nullptr;
105     static inline OHNativeWindow* nativeWindow = nullptr;
106     static inline GLuint textureId = 0;
107     static inline GLuint textureId2 = 0;
108     static inline EGLDisplay eglDisplay_ = EGL_NO_DISPLAY;
109     static inline EGLContext eglContext_ = EGL_NO_CONTEXT;
110     static inline EGLConfig config_;
111     static void OnFrameAvailable(void *context);
112     static inline bool isOnFrameAvailabled_ = false;
113 };
114 
OnFrameAvailable(void * context)115 void NativeImageSystemOpenGLTest::OnFrameAvailable(void *context)
116 {
117     (void) context;
118     isOnFrameAvailabled_ = true;
119 }
120 
SetUpTestCase()121 void NativeImageSystemOpenGLTest::SetUpTestCase()
122 {
123     glGenTextures(1, &textureId);
124     glGenTextures(1, &textureId2);
125     InitEglContext();
126 }
127 
TearDownTestCase()128 void NativeImageSystemOpenGLTest::TearDownTestCase()
129 {
130     Deinit();
131 }
132 
InitEglContext()133 void NativeImageSystemOpenGLTest::InitEglContext()
134 {
135     if (eglContext_ != EGL_NO_DISPLAY) {
136         return;
137     }
138 
139     BLOGI("Creating EGLContext!!!");
140     eglDisplay_ = GetPlatformEglDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, NULL);
141     if (eglDisplay_ == EGL_NO_DISPLAY) {
142         BLOGW("Failed to create EGLDisplay gl errno : %{public}x", eglGetError());
143         return;
144     }
145 
146     EGLint major = 0;
147     EGLint minor = 0;
148     if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) {
149         BLOGE("Failed to initialize EGLDisplay");
150         return;
151     }
152 
153     if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
154         BLOGE("Failed to bind OpenGL ES API");
155         return;
156     }
157 
158     unsigned int ret;
159     EGLint count;
160     EGLint config_attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
161         EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE };
162 
163     ret = eglChooseConfig(eglDisplay_, config_attribs, &config_, 1, &count);
164     if (!(ret && static_cast<unsigned int>(count) >= 1)) {
165         BLOGE("Failed to eglChooseConfig");
166         return;
167     }
168 
169     static const EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE };
170 
171     eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, context_attribs);
172     if (eglContext_ == EGL_NO_CONTEXT) {
173         BLOGE("Failed to create egl context %{public}x", eglGetError());
174         return;
175     }
176 
177     eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_);
178 
179     BLOGW("Create EGL context successfully, version %{public}d.%{public}d", major, minor);
180 }
181 
Deinit()182 void NativeImageSystemOpenGLTest::Deinit()
183 {
184     if (eglDisplay_ == EGL_NO_DISPLAY) {
185         return;
186     }
187     eglDestroyContext(eglDisplay_, eglContext_);
188     eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
189     eglTerminate(eglDisplay_);
190     eglReleaseThread();
191 
192     eglDisplay_ = EGL_NO_DISPLAY;
193     eglContext_ = EGL_NO_CONTEXT;
194 }
195 
ProducerThreadOpenGL(OHNativeWindow * nativeWindow)196 void ProducerThreadOpenGL(OHNativeWindow* nativeWindow)
197 {
198     if (nativeWindow == nullptr) {
199         return;
200     }
201     int32_t code = SET_BUFFER_GEOMETRY;
202     int32_t width = 0x100;
203     int32_t height = 0x100;
204     auto ret = NativeWindowHandleOpt(nativeWindow, code, width, height);
205 
206     NativeWindowBuffer* nativeWindowBuffer = nullptr;
207     int fenceFd = -1;
208     struct Region *region = new Region();
209     struct Region::Rect *rect = new Region::Rect();
210     rect->x = 0x100;
211     rect->y = 0x100;
212     rect->w = 0x100;
213     rect->h = 0x100;
214     region->rects = rect;
215     ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer, &fenceFd);
216     if (ret != GSERROR_OK) {
217         return;
218     }
219     ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nativeWindowBuffer, fenceFd, *region);
220     delete rect;
221     delete region;
222     return;
223 }
224 
225 /*
226 * Function: OHNativeImageUpdateImage
227 * Type: Function
228 * Rank: Important(1)
229 * EnvConditions: N/A
230 * CaseDescription: 1. run OHNativeImageUpdateImage and check ret
231 * @tc.require: issueI5KG61
232 */
233 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageUpdateImage, Function | MediumTest | Level1)
234 {
235     OH_NativeImage* newImage = OH_NativeImage_Create(textureId, GL_TEXTURE_2D);
236     ASSERT_NE(newImage, nullptr);
237     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
238     std::thread producerThread(ProducerThreadOpenGL, nativeWindow);
239     producerThread.join();
240 
241     auto ret = OH_NativeImage_UpdateSurfaceImage(newImage);
242     ASSERT_EQ(ret, SURFACE_ERROR_OK);
243 
244     OH_NativeImage_Destroy(&newImage);
245 }
246 
247 /*
248 * Function: OHNativeImageUpdateImageWithListener
249 * Type: Function
250 * Rank: Important(1)
251 * EnvConditions: N/A
252 * CaseDescription: 1. run OHNativeImageUpdateImageWithListener
253 *                  2. check ret
254 * @tc.require: issueI5KG61
255 */
256 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageUpdateImageWithListener, Function | MediumTest | Level1)
257 {
258     OH_NativeImage* newImage = OH_NativeImage_Create(textureId, GL_TEXTURE_2D);
259     ASSERT_NE(newImage, nullptr);
260     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
261     OH_OnFrameAvailableListener listener;
262     listener.context = this;
263     listener.onFrameAvailable = NativeImageSystemOpenGLTest::OnFrameAvailable;
264     auto ret = OH_NativeImage_SetOnFrameAvailableListener(newImage, listener);
265     ASSERT_EQ(ret, GSERROR_OK);
266 
267 
268     isOnFrameAvailabled_ = false;
269     std::thread producerThread(ProducerThreadOpenGL, nativeWindow);
270     producerThread.join();
271     EXPECT_TRUE(isOnFrameAvailabled_);
272     ret = OH_NativeImage_UpdateSurfaceImage(newImage);
273     ASSERT_EQ(ret, SURFACE_ERROR_OK);
274 
275     OH_NativeImage_Destroy(&newImage);
276 }
277 
278 /*
279 * Function: OHNativeImageUpdateImageWithAttachContext
280 * Type: Function
281 * Rank: Important(1)
282 * EnvConditions: N/A
283 * CaseDescription: 1. run OHNativeImageUpdateImageWithAttachContext
284 *                  2. check ret
285 * @tc.require: issueI5KG61
286 */
287 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageUpdateImageWithAttachContext, Function | MediumTest | Level1)
288 {
289     OH_NativeImage* newImage = OH_NativeImage_Create(0, GL_TEXTURE_2D);
290     ASSERT_NE(newImage, nullptr);
291     int32_t ret = OH_NativeImage_AttachContext(newImage, textureId);
292     ASSERT_EQ(ret, GSERROR_OK);
293     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
294 
295     std::thread producerThread(ProducerThreadOpenGL, nativeWindow);
296     producerThread.join();
297     ret = OH_NativeImage_UpdateSurfaceImage(newImage);
298     ASSERT_EQ(ret, SURFACE_ERROR_OK);
299 
300     OH_NativeImage_Destroy(&newImage);
301 }
302 
303 /*
304 * Function: OHNativeImageUpdateImageWithDetachContext
305 * Type: Function
306 * Rank: Important(1)
307 * EnvConditions: N/A
308 * CaseDescription: 1. run OHNativeImageUpdateImageWithDetachContext
309 *                  2. check ret
310 * @tc.require: issueI5KG61
311 */
312 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageUpdateImageWithDetachContext, Function | MediumTest | Level1)
313 {
314     OH_NativeImage* newImage = OH_NativeImage_Create(textureId, GL_TEXTURE_2D);
315     ASSERT_NE(newImage, nullptr);
316     int32_t ret;
317     ret = OH_NativeImage_DetachContext(newImage);
318     ASSERT_EQ(ret, GSERROR_OK);
319 
320     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
321     std::thread producerThread(ProducerThreadOpenGL, nativeWindow);
322     producerThread.join();
323 
324     ret = OH_NativeImage_UpdateSurfaceImage(newImage);
325     ASSERT_EQ(ret, SURFACE_ERROR_OK);
326 
327     OH_NativeImage_Destroy(&newImage);
328 }
329 
330 /*
331 * Function: OHNativeImageUpdateImageWithGetTimeStamp
332 * Type: Function
333 * Rank: Important(1)
334 * EnvConditions: N/A
335 * CaseDescription: 1. run OHNativeImageUpdateImageWithGetTimeStamp
336 *                  2. check ret
337 * @tc.require: issueI5KG61
338 */
339 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageUpdateImageWithGetTimeStamp, Function | MediumTest | Level1)
340 {
341     OH_NativeImage* newImage = OH_NativeImage_Create(textureId, GL_TEXTURE_2D);
342     ASSERT_NE(newImage, nullptr);
343 
344     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
345     std::thread producerThread(ProducerThreadOpenGL, nativeWindow);
346     producerThread.join();
347     int64_t timeStamp = OH_NativeImage_GetTimestamp(newImage);
348     ASSERT_NE(timeStamp, SURFACE_ERROR_ERROR);
349     auto ret = OH_NativeImage_UpdateSurfaceImage(newImage);
350     ASSERT_EQ(ret, SURFACE_ERROR_OK);
351 
352     OH_NativeImage_Destroy(&newImage);
353 }
354 
355 int32_t testType[] = {
356     GraphicTransformType::GRAPHIC_ROTATE_NONE, GraphicTransformType::GRAPHIC_ROTATE_90,
357     GraphicTransformType::GRAPHIC_ROTATE_180, GraphicTransformType::GRAPHIC_ROTATE_270,
358     GraphicTransformType::GRAPHIC_FLIP_H, GraphicTransformType::GRAPHIC_FLIP_V,
359     GraphicTransformType::GRAPHIC_FLIP_H_ROT90, GraphicTransformType::GRAPHIC_FLIP_V_ROT90,
360     GraphicTransformType::GRAPHIC_FLIP_H_ROT180, GraphicTransformType::GRAPHIC_FLIP_V_ROT180,
361     GraphicTransformType::GRAPHIC_FLIP_H_ROT270, GraphicTransformType::GRAPHIC_FLIP_V_ROT270,
362 };
363 float matrixArr[][MATRIX_SIZE] = {
364     {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
365     {0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
366     {-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
367     {0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
368     {-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
369     {1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
370     {0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
371     {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
372     {1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
373     {-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
374     {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
375     {0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
376 };
377 float matrixArrV2[][MATRIX_SIZE] = {
378     {1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1},   // 单位矩阵
379     {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},    // 90度矩阵
380     {-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1},   // 180度矩阵
381     {0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1},  // 270度矩阵
382     {-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1},  // 水平翻转
383     {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},    // 垂直翻转
384     {0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1},   // 水平*90
385     {0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1},   // 垂直*90
386     {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},    // 水平*180
387     {-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1},  // 垂直*180
388     {0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1},   // 水平*270
389     {0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1},   // 垂直*270
390 };
391 
CheckMatricIsSame(float matrixOld[MATRIX_SIZE],float matrixNew[MATRIX_SIZE])392 bool CheckMatricIsSame(float matrixOld[MATRIX_SIZE], float matrixNew[MATRIX_SIZE])
393 {
394     for (int32_t i = 0; i < MATRIX_SIZE; i++) {
395         if (fabs(matrixOld[i] - matrixNew[i]) > 1e-6) {
396             return false;
397         }
398     }
399     return true;
400 }
401 
ProducerThreadWithMatrix(OHNativeWindow * nativeWindow,int32_t matrixIndex)402 void ProducerThreadWithMatrix(OHNativeWindow* nativeWindow, int32_t matrixIndex)
403 {
404     if (nativeWindow == nullptr) {
405         return;
406     }
407     int32_t code = SET_BUFFER_GEOMETRY;
408     int32_t width = 0x100;
409     int32_t height = 0x100;
410     auto ret = NativeWindowHandleOpt(nativeWindow, code, width, height);
411 
412     code = SET_TRANSFORM;
413     ret = NativeWindowHandleOpt(nativeWindow, code, testType[matrixIndex]);
414     NativeWindowBuffer* nativeWindowBuffer = nullptr;
415     int fenceFd = -1;
416     struct Region *region = new Region();
417     struct Region::Rect *rect = new Region::Rect();
418     rect->x = 0x100;
419     rect->y = 0x100;
420     rect->w = 0x100;
421     rect->h = 0x100;
422     region->rects = rect;
423     ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer, &fenceFd);
424     if (ret != GSERROR_OK) {
425         return;
426     }
427     ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nativeWindowBuffer, fenceFd, *region);
428     delete rect;
429     delete region;
430     return;
431 }
432 
433 /*
434 * Function: OHNativeImageSTWithMatrix
435 * Type: Function
436 * Rank: Important(1)
437 * EnvConditions: N/A
438 * CaseDescription: 1. run OHNativeImageSTWithMatrix
439 *                  2. check ret
440 * @tc.require: issueI5KG61
441 */
442 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageSTWithMatrix, Function | MediumTest | Level1)
443 {
444     OH_NativeImage* newImage = OH_NativeImage_Create(textureId, GL_TEXTURE_2D);
445     ASSERT_NE(newImage, nullptr);
446     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
447 
448     uint32_t ret;
449 
450     for (int32_t i = 0; i < sizeof(testType) / sizeof(int32_t); i++) {
451         std::thread producerThread(ProducerThreadWithMatrix, nativeWindow, i);
452         producerThread.join();
453         ret = OH_NativeImage_UpdateSurfaceImage(newImage);
454         ASSERT_EQ(ret, SURFACE_ERROR_OK);
455         float matrix[16];
456         int32_t ret = OH_NativeImage_GetTransformMatrix(newImage, matrix);
457         ASSERT_EQ(ret, SURFACE_ERROR_OK);
458 
459         bool bRet = CheckMatricIsSame(matrix, matrixArr[i]);
460         ASSERT_EQ(bRet, true);
461     }
462     OH_NativeImage_Destroy(&newImage);
463 }
464 
465 /*
466 * Function: OHNativeImageSTWithMatrixV2
467 * Type: Function
468 * Rank: Important(1)
469 * EnvConditions: N/A
470 * CaseDescription: 1. run OHNativeImageSTWithMatrixV2
471 *                  2. check ret
472 * @tc.require: issueI5KG61
473 */
474 HWTEST_F(NativeImageSystemOpenGLTest, OHNativeImageSTWithMatrixV2, Function | MediumTest | Level1)
475 {
476     OH_NativeImage* newImage = OH_NativeImage_Create(textureId, GL_TEXTURE_2D);
477     ASSERT_NE(newImage, nullptr);
478     OHNativeWindow* nativeWindow = OH_NativeImage_AcquireNativeWindow(newImage);
479 
480     uint32_t ret;
481 
482     for (int32_t i = 0; i < sizeof(testType) / sizeof(int32_t); i++) {
483         std::thread producerThread(ProducerThreadWithMatrix, nativeWindow, i);
484         producerThread.join();
485         ret = OH_NativeImage_UpdateSurfaceImage(newImage);
486         ASSERT_EQ(ret, SURFACE_ERROR_OK);
487         float matrix[16];
488         int32_t ret = OH_NativeImage_GetTransformMatrixV2(newImage, matrix);
489         ASSERT_EQ(ret, SURFACE_ERROR_OK);
490 
491         bool bRet = CheckMatricIsSame(matrix, matrixArrV2[i]);
492         ASSERT_EQ(bRet, true);
493     }
494     OH_NativeImage_Destroy(&newImage);
495 }
496 }