Flutter Engine
The Flutter Engine
SkSurfaceMetal.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 SkSurfaceMetal_DEFINED
9#define SkSurfaceMetal_DEFINED
10
13#include "include/gpu/GrTypes.h"
16
17namespace SkSurfaces {
18/** Creates SkSurface from CAMetalLayer.
19 Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be
20 released when the SkSurface is destroyed.
21
22 Only available when Metal API is enabled.
23
24 Will grab the current drawable from the layer and use its texture as a backendRT to
25 create a renderable surface.
26
27 @param context GPU context
28 @param layer GrMTLHandle (expected to be a CAMetalLayer*)
29 @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
30 @param colorSpace range of colors; may be nullptr
31 @param surfaceProps LCD striping orientation and setting for device independent
32 fonts; may be nullptr
33 @param drawable Pointer to drawable to be filled in when this surface is
34 instantiated; may not be nullptr
35 @return created SkSurface, or nullptr
36 */
38 GrMTLHandle layer,
39 GrSurfaceOrigin origin,
40 int sampleCnt,
42 sk_sp<SkColorSpace> colorSpace,
43 const SkSurfaceProps* surfaceProps,
44 GrMTLHandle* drawable) SK_API_AVAILABLE_CA_METAL_LAYER;
45
46/** Creates SkSurface from MTKView.
47 Returned SkSurface takes a reference on the MTKView. The ref on the layer will be
48 released when the SkSurface is destroyed.
49
50 Only available when Metal API is enabled.
51
52 Will grab the current drawable from the layer and use its texture as a backendRT to
53 create a renderable surface.
54
55 @param context GPU context
56 @param layer GrMTLHandle (expected to be a MTKView*)
57 @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
58 @param colorSpace range of colors; may be nullptr
59 @param surfaceProps LCD striping orientation and setting for device independent
60 fonts; may be nullptr
61 @return created SkSurface, or nullptr
62 */
64 GrMTLHandle mtkView,
65 GrSurfaceOrigin origin,
66 int sampleCnt,
68 sk_sp<SkColorSpace> colorSpace,
69 const SkSurfaceProps* surfaceProps)
70 SK_API_AVAILABLE(macos(10.11), ios(9.0), tvos(9.0));
71} // namespace SkSurfaces
72
73#endif
const void * GrMTLHandle
Definition: GrMtlTypes.h:20
GrSurfaceOrigin
Definition: GrTypes.h:147
#define SK_API_AVAILABLE(...)
Definition: SkAPI.h:49
#define SK_API
Definition: SkAPI.h:35
SkColorType
Definition: SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
SK_API sk_sp< SkSurface > WrapCAMetalLayer(GrRecordingContext *context, GrMTLHandle layer, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, GrMTLHandle *drawable) SK_API_AVAILABLE_CA_METAL_LAYER
SK_API sk_sp< SkSurface > WrapMTKView(GrRecordingContext *context, GrMTLHandle mtkView, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps) SK_API_AVAILABLE(macos(10.11)
SK_API sk_sp< SkSurface > ios(9.0)
SK_API sk_sp< SkSurface > tvos(9.0))