Debian Codegraph @

include/android/GrAHardwareBufferUtils.h

raw
1 /*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #ifndef GrAHardwareBufferUtils_DEFINED
8 #define GrAHardwareBufferUtils_DEFINED
9
10 #include "include/core/SkTypes.h"
11
12 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
13
14 #include "include/gpu/ganesh/GrBackendSurface.h"
15 #include "include/gpu/ganesh/GrTypes.h"
16
17 class GrDirectContext;
18
19 extern "C" {
20 typedef struct AHardwareBuffer AHardwareBuffer;
21 }
22
23 namespace GrAHardwareBufferUtils {
24
25 #if !defined(SK_DISABLE_LEGACY_ANDROID_HW_UTILS)
26 GrBackendFormat GetBackendFormat(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
27 uint32_t bufferFormat, bool requireKnownFormat);
28 #endif
29
30 GrBackendFormat GetGLBackendFormat(GrDirectContext* dContext, uint32_t bufferFormat,
31 bool requireKnownFormat);
32 GrBackendFormat GetVulkanBackendFormat(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
33 uint32_t bufferFormat, bool requireKnownFormat);
34
35 typedef void* TexImageCtx;
36 typedef void (*DeleteImageProc)(TexImageCtx);
37 typedef void (*UpdateImageProc)(TexImageCtx, GrDirectContext*);
38
39 /**
40 * Create a GrBackendTexture from AHardwareBuffer
41 *
42 * @param context GPU context
43 * @param hardwareBuffer AHB
44 * @param width texture width
45 * @param height texture height
46 * @param deleteProc returns a function that deletes the texture and
47 * other GPU resources. Must be invoked on the same
48 * thread as MakeBackendTexture
49 * @param updateProc returns a function, that needs to be invoked, when
50 * AHB buffer content has changed. Must be invoked on
51 * the same thread as MakeBackendTexture
52 * @param imageCtx returns an opaque image context, that is passed as
53 * first argument to deleteProc and updateProc
54 * @param isProtectedContent if true, GL backend uses EXT_protected_content
55 * @param backendFormat backend format, usually created with helper
56 * function GetBackendFormat
57 * @param isRenderable true if GrBackendTexture can be used as a color
58 * attachment
59 * @return valid GrBackendTexture object on success
60 */
61 #if !defined(SK_DISABLE_LEGACY_ANDROID_HW_UTILS)
62 GrBackendTexture MakeBackendTexture(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
63 int width, int height,
64 DeleteImageProc* deleteProc,
65 UpdateImageProc* updateProc,
66 TexImageCtx* imageCtx,
67 bool isProtectedContent,
68 const GrBackendFormat& backendFormat,
69 bool isRenderable,
70 bool fromAndroidWindow = false);
71 #endif
72
73 GrBackendTexture MakeGLBackendTexture(GrDirectContext* dContext,
74 AHardwareBuffer* hardwareBuffer,
75 int width, int height,
76 DeleteImageProc* deleteProc,
77 UpdateImageProc* updateProc,
78 TexImageCtx* imageCtx,
79 bool isProtectedContent,
80 const GrBackendFormat& backendFormat,
81 bool isRenderable);
82
83 GrBackendTexture MakeVulkanBackendTexture(GrDirectContext* dContext,
84 AHardwareBuffer* hardwareBuffer,
85 int width, int height,
86 DeleteImageProc* deleteProc,
87 UpdateImageProc* updateProc,
88 TexImageCtx* imageCtx,
89 bool isProtectedContent,
90 const GrBackendFormat& backendFormat,
91 bool isRenderable,
92 bool fromAndroidWindow = false);
93
94 } // namespace GrAHardwareBufferUtils
95
96 #endif
97 #endif