33 , fDrawableHandle(nil) {
40 fDevice.reset(MTLCreateSystemDefaultDevice());
44 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
97 id<CAMetalDrawable> currentDrawable = [
fMetalLayer nextDrawable];
98 if (currentDrawable == nil) {
102 GrMtlTextureInfo fbInfo;
103 fbInfo.fTexture.retain(currentDrawable.texture);
123 id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)
fDrawableHandle;
125 id<MTLCommandBuffer> commandBuffer([*
fQueue commandBuffer]);
126 commandBuffer.label =
@"Present";
128 [commandBuffer presentDrawable:currentDrawable];
129 [commandBuffer commit];
@ kTopLeft_GrSurfaceOrigin
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
static uint32_t GrNextPow2(uint32_t n)
void abandonContext() override
void reset(T *ptr=nullptr)
sk_sp< GrDirectContext > fContext
DisplayParams fDisplayParams
virtual bool onInitializeContext()=0
CAMetalLayer * fMetalLayer
void setDisplayParams(const DisplayParams ¶ms) override
virtual void onDestroyContext()=0
MetalWindowContext(const DisplayParams &)
sk_cfp< id< MTLDevice > > fDevice
sk_cfp< id< MTLCommandQueue > > fQueue
GrMTLHandle fDrawableHandle
void onSwapBuffers() override
sk_sp< SkSurface > getBackbufferSurface() override
const EmbeddedViewParams * params
SK_API GrBackendRenderTarget MakeMtl(int width, int height, const GrMtlTextureInfo &mtlInfo)
SK_API sk_sp< GrDirectContext > MakeMetal(const GrMtlBackendContext &, const GrContextOptions &)
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 > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
sk_cfp< GrMTLHandle > fDevice
sk_cfp< GrMTLHandle > fQueue
bool fDelayDrawableAcquisition
SkSurfaceProps fSurfaceProps
GrContextOptions fGrContextOptions
sk_sp< SkColorSpace > fColorSpace