Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
flutter::TestMetalSurfaceImpl Class Reference

#include <test_metal_surface_impl.h>

Inheritance diagram for flutter::TestMetalSurfaceImpl:
flutter::TestMetalSurface

Public Member Functions

 TestMetalSurfaceImpl (const TestMetalContext &test_metal_context, const SkISize &surface_size)
 
 TestMetalSurfaceImpl (const TestMetalContext &test_metal_context, int64_t texture_id, const SkISize &surface_size)
 
 ~TestMetalSurfaceImpl () override
 
- Public Member Functions inherited from flutter::TestMetalSurface
virtual ~TestMetalSurface ()
 

Private Member Functions

bool IsValid () const override
 
sk_sp< GrDirectContextGetGrContext () const override
 
sk_sp< SkSurfaceGetSurface () const override
 
sk_sp< SkImageGetRasterSurfaceSnapshot () override
 
TestMetalContext::TextureInfo GetTextureInfo () override
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::TestMetalSurface
static bool PlatformSupportsMetal ()
 
static std::unique_ptr< TestMetalSurfaceCreate (const TestMetalContext &test_metal_context, SkISize surface_size=SkISize::MakeEmpty())
 
static std::unique_ptr< TestMetalSurfaceCreate (const TestMetalContext &test_metal_context, int64_t texture_id, SkISize surface_size=SkISize::MakeEmpty())
 
- Protected Member Functions inherited from flutter::TestMetalSurface
 TestMetalSurface ()
 

Detailed Description

Definition at line 16 of file test_metal_surface_impl.h.

Constructor & Destructor Documentation

◆ TestMetalSurfaceImpl() [1/2]

flutter::TestMetalSurfaceImpl::TestMetalSurfaceImpl ( const TestMetalContext test_metal_context,
const SkISize surface_size 
)

Definition at line 58 of file test_metal_surface_impl.mm.

60 : test_metal_context_(test_metal_context) {
61 if (surface_size.isEmpty()) {
62 FML_LOG(ERROR) << "Size of test Metal surface was empty.";
63 return;
64 }
65 TestMetalContext::TextureInfo texture_info =
66 const_cast<TestMetalContext&>(test_metal_context_).CreateMetalTexture(surface_size);
67 Init(texture_info, surface_size);
68}
#define FML_LOG(severity)
Definition logging.h:82
void Init()
bool isEmpty() const
Definition SkSize.h:31
#define ERROR(message)

◆ TestMetalSurfaceImpl() [2/2]

flutter::TestMetalSurfaceImpl::TestMetalSurfaceImpl ( const TestMetalContext test_metal_context,
int64_t  texture_id,
const SkISize surface_size 
)

Definition at line 49 of file test_metal_surface_impl.mm.

52 : test_metal_context_(test_metal_context) {
53 TestMetalContext::TextureInfo texture_info =
54 const_cast<TestMetalContext&>(test_metal_context_).GetTextureInfo(texture_id);
55 Init(texture_info, surface_size);
56}
TestMetalContext::TextureInfo GetTextureInfo() override
int64_t texture_id

◆ ~TestMetalSurfaceImpl()

flutter::TestMetalSurfaceImpl::~TestMetalSurfaceImpl ( )
overridedefault

Member Function Documentation

◆ GetGrContext()

sk_sp< GrDirectContext > flutter::TestMetalSurfaceImpl::GetGrContext ( ) const
overrideprivatevirtual

Reimplemented from flutter::TestMetalSurface.

Definition at line 109 of file test_metal_surface_impl.mm.

109 {
110 return IsValid() ? test_metal_context_.GetSkiaContext() : nullptr;
111}
sk_sp< GrDirectContext > GetSkiaContext() const

◆ GetRasterSurfaceSnapshot()

sk_sp< SkImage > flutter::TestMetalSurfaceImpl::GetRasterSurfaceSnapshot ( )
overrideprivatevirtual

Reimplemented from flutter::TestMetalSurface.

Definition at line 70 of file test_metal_surface_impl.mm.

70 {
71 if (!IsValid()) {
72 return nullptr;
73 }
74
75 if (!surface_) {
76 FML_LOG(ERROR) << "Aborting snapshot because of on-screen surface "
77 "acquisition failure.";
78 return nullptr;
79 }
80
81 auto device_snapshot = surface_->makeImageSnapshot();
82
83 if (!device_snapshot) {
84 FML_LOG(ERROR) << "Could not create the device snapshot while attempting "
85 "to snapshot the Metal surface.";
86 return nullptr;
87 }
88
89 auto host_snapshot = device_snapshot->makeRasterImage();
90
91 if (!host_snapshot) {
92 FML_LOG(ERROR) << "Could not create the host snapshot while attempting to "
93 "snapshot the Metal surface.";
94 return nullptr;
95 }
96
97 return host_snapshot;
98}
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
Definition SkImage.cpp:267
sk_sp< SkImage > makeImageSnapshot()
Definition SkSurface.cpp:90

◆ GetSurface()

sk_sp< SkSurface > flutter::TestMetalSurfaceImpl::GetSurface ( ) const
overrideprivatevirtual

Reimplemented from flutter::TestMetalSurface.

Definition at line 114 of file test_metal_surface_impl.mm.

114 {
115 return IsValid() ? surface_ : nullptr;
116}

◆ GetTextureInfo()

TestMetalContext::TextureInfo flutter::TestMetalSurfaceImpl::GetTextureInfo ( )
overrideprivatevirtual

Reimplemented from flutter::TestMetalSurface.

Definition at line 119 of file test_metal_surface_impl.mm.

119 {
120 return IsValid() ? texture_info_ : TestMetalContext::TextureInfo();
121}

◆ IsValid()

bool flutter::TestMetalSurfaceImpl::IsValid ( ) const
overrideprivatevirtual

Reimplemented from flutter::TestMetalSurface.

Definition at line 104 of file test_metal_surface_impl.mm.

104 {
105 return is_valid_;
106}

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