• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #ifndef NDK_INCLUDE_NATIVE_IMAGE_H_
17 #define NDK_INCLUDE_NATIVE_IMAGE_H_
18 
19 /**
20  * @addtogroup OH_NativeImage
21  * @{
22  *
23  * @brief Provides the native image capability.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
26  * @since 9
27  * @version 1.0
28  */
29 
30 /**
31  * @file native_image.h
32  *
33  * @brief Defines the functions for obtaining and using a native image.
34  *
35  * @since 9
36  * @version 1.0
37  */
38 
39 #include <stdint.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 struct OH_NativeImage;
46 typedef struct OH_NativeImage OH_NativeImage;
47 typedef struct NativeWindow OHNativeWindow;
48 
49 /**
50  * @brief Create a <b>OH_NativeImage</b> related to an OPENGL ES texture and target. \n
51  *
52  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
53  * @param textureId Indicates the id of the OPENGL ES texture which the native image attached to.
54  * @param textureTarget Indicates the OPENGL ES target.
55  * @return Returns the pointer to the <b>OH_NativeImage</b> instance created if the operation is successful, \n
56  * returns <b>NULL</b> otherwise.
57  * @since 9
58  * @version 1.0
59  */
60 OH_NativeImage* OH_NativeImage_Create(uint32_t textureId, uint32_t textureTarget);
61 
62 /**
63  * @brief Acquire the OHNativeWindow for the OH_NativeImage. This OHNativeWindow should be released by \n
64  * OH_NativeWindow_DestroyNativeWindow when no longer needed.
65  *
66  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
67  * @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
68  * @return Returns the pointer to the OHNativeWindow if the operation is successful, returns <b>NULL</b> otherwise.
69  * @since 9
70  * @version 1.0
71  */
72 OHNativeWindow* OH_NativeImage_AcquireNativeWindow(OH_NativeImage* image);
73 
74 /**
75  * @brief Attach the OH_NativeImage to OPENGL ES context, and the OPENGL ES texture is bound to the \n
76  * GL_TEXTURE_EXTERNAL_OES, which will update by the OH_NativeImage.
77  *
78  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
79  * @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
80  * @param textureId Indicates the id of the OPENGL ES texture which the native image attached to.
81  * @return Returns an error code defined in <b>SurfaceError</b>.
82  * @since 9
83  * @version 1.0
84  */
85 int32_t OH_NativeImage_AttachContext(OH_NativeImage* image, uint32_t textureId);
86 
87 /**
88  * @brief Detach the OH_NativeImage from the OPENGL ES context.
89  *
90  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
91  * @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
92  * @return Returns an error code defined in <b>SurfaceError</b>.
93  * @since 9
94  * @version 1.0
95  */
96 
97 int32_t OH_NativeImage_DetachContext(OH_NativeImage* image);
98 
99 /**
100  * @brief Update the related OPENGL ES texture with the OH_NativeImage acquired buffer.
101  *
102  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
103  * @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
104  * @return Returns an error code defined in <b>SurfaceError</b>.
105  * @since 9
106  * @version 1.0
107  */
108 int32_t OH_NativeImage_UpdateSurfaceImage(OH_NativeImage* image);
109 
110 /**
111  * @brief Get the timestamp of the texture image set by the most recent call to OH_NativeImage_UpdateSurfaceImage.
112  *
113  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
114  * @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
115  * @return Returns the timestamp associated to the texture image.
116  * @since 9
117  * @version 1.0
118  */
119 int64_t OH_NativeImage_GetTimestamp(OH_NativeImage* image);
120 
121 /**
122  * @brief Return the transform matrix of the texture image set by the most recent call to \n
123  * OH_NativeImage_UpdateSurfaceImage.
124  *
125  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
126  * @param image Indicates the pointer to a <b>OH_NativeImage</b> instance.
127  * @param matrix Indicates the retrieved 4*4 transform matrix .
128  * @return Returns an error code defined in <b>SurfaceError</b>.
129  * @since 9
130  * @version 1.0
131  */
132 int32_t OH_NativeImage_GetTransformMatrix(OH_NativeImage* image, float matrix[16]);
133 
134 /**
135  * @brief Destroy the <b>OH_NativeImage</b> created by OH_NativeImage_Create, and the pointer to \n
136  * <b>OH_NativeImage</b> will be null after this operation.
137  *
138  * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
139  * @param image Indicates the pointer to a <b>OH_NativeImage</b> pointer.
140  * @since 9
141  * @version 1.0
142  */
143 void OH_NativeImage_Destroy(OH_NativeImage** image);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 /** @} */
150 #endif