Flutter Engine
flutter::IOSContextMetal Class Referencefinal

#include <ios_context_metal.h>

Inheritance diagram for flutter::IOSContextMetal:
flutter::IOSContext

Public Member Functions

 IOSContextMetal ()
 
 ~IOSContextMetal ()
 
fml::scoped_nsobject< FlutterDarwinContextMetalGetDarwinContext () const
 
sk_sp< GrDirectContext > GetMainContext () const override
 Accessor for the Skia context associated with IOSSurfaces and the raster thread. More...
 
sk_sp< GrDirectContext > GetResourceContext () const
 
- Public Member Functions inherited from flutter::IOSContext
virtual ~IOSContext ()
 Collects the context object. This must happen on the thread on which this object was created. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::IOSContext
static std::unique_ptr< IOSContextCreate (IOSRenderingAPI rendering_api)
 Create an iOS context object capable of creating the on-screen and off-screen GPU context for use by Skia. More...
 
- Protected Member Functions inherited from flutter::IOSContext
 IOSContext ()
 

Detailed Description

Definition at line 19 of file ios_context_metal.h.

Constructor & Destructor Documentation

◆ IOSContextMetal()

flutter::IOSContextMetal::IOSContextMetal ( )

Definition at line 15 of file ios_context_metal.mm.

References FlutterDarwinContextMetal::commandQueue, FlutterDarwinContextMetal::device, FML_DLOG, fml::scoped_nsprotocol< NST >::get(), fml::CFRef< T >::Reset(), fml::scoped_nsprotocol< NST >::reset(), and ~IOSContextMetal().

15  {
17  [[FlutterDarwinContextMetal alloc] initWithDefaultMTLDevice]};
18 
19  if (!darwin_context_metal_) {
20  return;
21  }
22 
23  main_command_queue_.reset([darwin_context_metal_.get().commandQueue retain]);
24 
25  CVMetalTextureCacheRef texture_cache_raw = NULL;
26  auto cv_return = CVMetalTextureCacheCreate(kCFAllocatorDefault, // allocator
27  NULL, // cache attributes (NULL default)
28  darwin_context_metal_.get().device, // metal device
29  NULL, // texture attributes (NULL default)
30  &texture_cache_raw // [out] cache
31  );
32  if (cv_return != kCVReturnSuccess) {
33  FML_DLOG(ERROR) << "Could not create Metal texture cache.";
34  return;
35  }
36  texture_cache_.Reset(texture_cache_raw);
37 }
id< MTLCommandQueue > commandQueue
void reset(NST object=nil)
void Reset(T instance=nullptr)
Definition: cf_utils.h:44
#define FML_DLOG(severity)
Definition: logging.h:85

◆ ~IOSContextMetal()

flutter::IOSContextMetal::~IOSContextMetal ( )
default

Referenced by IOSContextMetal().

Member Function Documentation

◆ GetDarwinContext()

fml::scoped_nsobject< FlutterDarwinContextMetal > flutter::IOSContextMetal::GetDarwinContext ( ) const

Definition at line 41 of file ios_context_metal.mm.

41  {
42  return darwin_context_metal_;
43 }

◆ GetMainContext()

sk_sp< GrDirectContext > flutter::IOSContextMetal::GetMainContext ( ) const
overridevirtual

Accessor for the Skia context associated with IOSSurfaces and the raster thread.

There can be any number of resource contexts but this is the one context that will be used by surfaces to draw to the screen from the raster thread.

Returns
nullptr on failure.
Attention
The software context doesn't have a Skia context, so this value will be nullptr.
See also
For contexts which are used for offscreen work like loading textures see IOSContext::CreateResourceContext.

Implements flutter::IOSContext.

Definition at line 45 of file ios_context_metal.mm.

References fml::scoped_nsprotocol< NST >::get(), and FlutterDarwinContextMetal::mainContext.

45  {
46  return darwin_context_metal_.get().mainContext;
47 }
sk_sp< GrDirectContext > mainContext

◆ GetResourceContext()

sk_sp< GrDirectContext > flutter::IOSContextMetal::GetResourceContext ( ) const

Definition at line 49 of file ios_context_metal.mm.

References fml::scoped_nsprotocol< NST >::get(), FlutterDarwinContextMetal::resourceContext, texture, and texture_id.

49  {
50  return darwin_context_metal_.get().resourceContext;
51 }
sk_sp< GrDirectContext > resourceContext

The documentation for this class was generated from the following files: