Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkMetalViewBridge.h File Reference
#include "tools/skottie_ios_app/GrContextHolder.h"
import <MetalKit/MetalKit.h>
#include <memory>

Go to the source code of this file.

Functions

sk_sp< SkSurfaceSkMtkViewToSurface (MTKView *, GrRecordingContext *)
 
GrContextHolder SkMetalDeviceToGrContext (id< MTLDevice >, id< MTLCommandQueue >)
 
void SkMtkViewConfigForSkia (MTKView *)
 

Function Documentation

◆ SkMetalDeviceToGrContext()

GrContextHolder SkMetalDeviceToGrContext ( id< MTLDevice >  device,
id< MTLCommandQueue >  queue 
)

Definition at line 42 of file SkMetalViewBridge.mm.

42 {
43 GrMtlBackendContext backendContext = {};
44 backendContext.fDevice.reset((__bridge void*)device);
45 backendContext.fQueue.reset((__bridge void*)queue);
46 GrContextOptions grContextOptions; // set different options here.
47 return GrContextHolder(GrDirectContexts::MakeMetal(backendContext, grContextOptions).release());
48}
std::unique_ptr< GrDirectContext, GrContextRelease > GrContextHolder
VkDevice device
Definition main.cc:53
SK_API sk_sp< GrDirectContext > MakeMetal(const GrMtlBackendContext &, const GrContextOptions &)
sk_cfp< GrMTLHandle > fDevice
sk_cfp< GrMTLHandle > fQueue

◆ SkMtkViewConfigForSkia()

void SkMtkViewConfigForSkia ( MTKView *  mtkView)

Definition at line 50 of file SkMetalViewBridge.mm.

50 {
51 [mtkView setDepthStencilPixelFormat:MTLPixelFormatDepth32Float_Stencil8];
52 [mtkView setColorPixelFormat:MTLPixelFormatBGRA8Unorm];
53 [mtkView setSampleCount:1];
54}

◆ SkMtkViewToSurface()

sk_sp< SkSurface > SkMtkViewToSurface ( MTKView *  mtkView,
GrRecordingContext rContext 
)

Definition at line 20 of file SkMetalViewBridge.mm.

20 {
21 if (!rContext ||
22 MTLPixelFormatDepth32Float_Stencil8 != [mtkView depthStencilPixelFormat] ||
23 MTLPixelFormatBGRA8Unorm != [mtkView colorPixelFormat]) {
24 return nullptr;
25 }
26
27 const SkColorType colorType = kBGRA_8888_SkColorType; // MTLPixelFormatBGRA8Unorm
28 sk_sp<SkColorSpace> colorSpace = nullptr; // MTLPixelFormatBGRA8Unorm
30 const SkSurfaceProps surfaceProps;
31 int sampleCount = (int)[mtkView sampleCount];
32
33 return SkSurfaces::WrapMTKView(rContext,
34 (__bridge GrMTLHandle)mtkView,
35 origin,
36 sampleCount,
38 colorSpace,
39 &surfaceProps);
40}
const void * GrMTLHandle
Definition GrMtlTypes.h:20
GrSurfaceOrigin
Definition GrTypes.h:147
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
SkColorType
Definition SkColorType.h:19
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
Type::kYUV Type::kRGBA() int(0.7 *637)
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)