31 , fDrawableHandle(nil) {
39 fDevice.reset(MTLCreateSystemDefaultDevice());
43 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
60 fDisplayParams.fGraphiteContextOptions.fOptions.fDisableCachedGlyphUploads =
true;
62 fDisplayParams.fGraphiteContextOptions.fPriv.fStoreContextRefInRecorder =
true;
65 fGraphiteRecorder = fGraphiteContext->makeRecorder(ToolUtils::CreateTestingRecorderOptions());
75 if (fGraphiteContext) {
76 fGraphiteRecorder.reset();
77 fGraphiteContext.reset();
91 id<CAMetalDrawable> currentDrawable = [
fMetalLayer nextDrawable];
92 if (currentDrawable == nil) {
97 (CFTypeRef)currentDrawable.texture);
110 this->snapRecordingAndSubmit();
112 id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)
fDrawableHandle;
114 id<MTLCommandBuffer> commandBuffer([*
fQueue commandBuffer]);
115 commandBuffer.label =
@"Present";
117 [commandBuffer presentDrawable:currentDrawable];
118 [commandBuffer commit];
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
static uint32_t GrNextPow2(uint32_t n)
sk_sp< GrDirectContext > fContext
DisplayParams fDisplayParams
SkISize dimensions() const
sk_sp< SkSurface > getBackbufferSurface() override
GraphiteMetalWindowContext(const DisplayParams &)
CFTypeRef fDrawableHandle
void onSwapBuffers() override
virtual bool onInitializeContext()=0
void setDisplayParams(const DisplayParams ¶ms) override
virtual void onDestroyContext()=0
sk_cfp< id< MTLCommandQueue > > fQueue
sk_cfp< id< MTLDevice > > fDevice
void activate(bool isActive) override
CAMetalLayer * fMetalLayer
const EmbeddedViewParams * params
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API std::unique_ptr< Context > MakeMetal(const MtlBackendContext &, const ContextOptions &)
sk_cfp< CFTypeRef > fDevice
sk_cfp< CFTypeRef > fQueue
SkSurfaceProps fSurfaceProps
sk_sp< SkColorSpace > fColorSpace