• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_WINDOW_H_
17 #define NDK_INCLUDE_NATIVE_WINDOW_H_
18 
19 #include "external_window.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define MKMAGIC(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + ((d) << 0))
26 
27 enum NativeObjectMagic {
28     NATIVE_OBJECT_MAGIC_WINDOW = MKMAGIC('W', 'I', 'N', 'D'),
29     NATIVE_OBJECT_MAGIC_WINDOW_BUFFER = MKMAGIC('W', 'B', 'U', 'F'),
30 };
31 
32 // pSurface type is OHOS::sptr<OHOS::Surface>*
33 OHNativeWindow* CreateNativeWindowFromSurface(void* pSurface);
34 void DestoryNativeWindow(OHNativeWindow* window);
35 
36 // pSurfaceBuffer type is OHOS::sptr<OHOS::SurfaceBuffer>*
37 OHNativeWindowBuffer* CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer);
38 void DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer);
39 
40 int32_t NativeWindowRequestBuffer(OHNativeWindow *window, /* [out] */ OHNativeWindowBuffer **buffer,
41     /* [out] get release fence */ int *fenceFd);
42 int32_t NativeWindowFlushBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer,
43     int fenceFd, Region region);
44 int32_t NativeWindowCancelBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
45 
46 // The meaning and quantity of parameters vary according to the code type.
47 // For details, see the NativeWindowOperation comment.
48 int32_t NativeWindowHandleOpt(OHNativeWindow *window, int code, ...);
49 BufferHandle *GetBufferHandleFromNative(OHNativeWindowBuffer *buffer);
50 
51 // NativeObject: NativeWindow, NativeWindowBuffer
52 int32_t NativeObjectReference(void *obj);
53 int32_t NativeObjectUnreference(void *obj);
54 int32_t GetNativeObjectMagic(void *obj);
55 
56 int32_t NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence, OHScalingMode scalingMode);
57 int32_t NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size,
58                                 const OHHDRMetaData *metaData);
59 int32_t NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key,
60                                    int32_t size, const uint8_t *metaData);
61 int32_t NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif