Flutter Engine
The Flutter Engine
SurfaceAndroid.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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
8#ifndef SurfaceAndroid_DEFINED
9#define SurfaceAndroid_DEFINED
10
12
13struct AHardwareBuffer;
14class SkColorSpace;
15class SkSurface;
16class SkSurfaceProps;
17
18namespace skgpu::graphite {
19 class Recorder;
20}
21
22namespace SkSurfaces {
23
24using ReleaseContext = void*;
26
27/** Private; only to be used by Android Framework.
28 Creates an SkSurface from an Android hardware buffer.
29
30 Upon success bufferReleaseProc is called when it is safe to delete the buffer in the
31 backend API (accounting only for use of the buffer by this surface). If SkSurface creation
32 fails bufferReleaseProc is called before this function returns.
33
34 Currently this is only supported for buffers that can be textured as well as rendered to.
35 In other words the buffer must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and
36 AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
37
38 @param recorder the applicable Graphite recorder
39 @param hardwareBuffer an Android hardware buffer
40 @param colorSpace range of colors; may be nullptr
41 @param surfaceProps LCD striping orientation and setting for device independent
42 fonts; may be nullptr
43 @param bufferReleaseProc function called when the buffer can be released
44 @param ReleaseContext state passed to bufferReleaseProc
45 @param fromWindow Whether or not the AHardwareBuffer is part of an Android Window.
46 Currently only used with Vulkan backend.
47 @return created SkSurface, or nullptr
48*/
50 AHardwareBuffer* hardwareBuffer,
51 sk_sp<SkColorSpace> colorSpace,
52 const SkSurfaceProps* surfaceProps,
53 BufferReleaseProc = nullptr,
54 ReleaseContext = nullptr,
55 bool fromWindow = false);
56
57} // namespace SkSurfaces
58
59#endif // SurfaceAndroid_DEFINED
struct AHardwareBuffer AHardwareBuffer
#define SK_API
Definition: SkAPI.h:35
SK_API sk_sp< SkSurface > WrapAndroidHardwareBuffer(skgpu::graphite::Recorder *recorder, AHardwareBuffer *hardwareBuffer, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, BufferReleaseProc=nullptr, ReleaseContext=nullptr, bool fromWindow=false)
void * ReleaseContext
void(*)(ReleaseContext) BufferReleaseProc