Flutter Engine
 
Loading...
Searching...
No Matches
flutter::gpu::Texture Class Reference

#include <texture.h>

Inheritance diagram for flutter::gpu::Texture:
flutter::RefCountedDartWrappable< Texture > fml::RefCountedThreadSafe< T > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 Texture (std::shared_ptr< impeller::Texture > texture)
 
 ~Texture () override
 
std::shared_ptr< impeller::TextureGetTexture ()
 
void SetCoordinateSystem (impeller::TextureCoordinateSystem coordinate_system)
 
bool Overwrite (Context &gpu_context, const tonic::DartByteData &source_bytes)
 
size_t GetBytesPerTexel ()
 
Dart_Handle AsImage () const
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Texture >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< T >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex ,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< T >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 17 of file texture.h.

Constructor & Destructor Documentation

◆ Texture()

flutter::gpu::Texture::Texture ( std::shared_ptr< impeller::Texture texture)
explicit

Definition at line 24 of file texture.cc.

25 : texture_(std::move(texture)) {}
FlTexture * texture

◆ ~Texture()

flutter::gpu::Texture::~Texture ( )
overridedefault

Member Function Documentation

◆ AsImage()

Dart_Handle flutter::gpu::Texture::AsImage ( ) const

Definition at line 73 of file texture.cc.

73 {
74 // DlImageImpeller isn't compiled in builds with Impeller disabled. If
75 // Impeller is disabled, it's impossible to get here anyhow, so just ifdef it
76 // out.
77#if IMPELLER_SUPPORTS_RENDERING
79 auto dl_image = impeller::DlImageImpeller::Make(texture_);
80 image->set_image(dl_image);
81 auto wrapped = image->CreateOuterWrapping();
82 return wrapped;
83#else
84 return Dart_Null();
85#endif
86}
static fml::RefPtr< CanvasImage > Create()
Definition image.h:28
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterVulkanImage * image

References flutter::CanvasImage::Create(), image, and impeller::DlImageImpeller::Make().

Referenced by InternalFlutterGpu_Texture_AsImage().

◆ GetBytesPerTexel()

size_t flutter::gpu::Texture::GetBytesPerTexel ( )

Definition at line 68 of file texture.cc.

68 {
70 texture_->GetTextureDescriptor().format);
71}
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition formats.h:466

References impeller::BytesPerPixelForPixelFormat().

Referenced by InternalFlutterGpu_Texture_BytesPerTexel().

◆ GetTexture()

std::shared_ptr< impeller::Texture > flutter::gpu::Texture::GetTexture ( )

Definition at line 29 of file texture.cc.

29 {
30 return texture_;
31}

Referenced by InternalFlutterGpu_RenderPass_SetColorAttachment().

◆ Overwrite()

bool flutter::gpu::Texture::Overwrite ( Context gpu_context,
const tonic::DartByteData source_bytes 
)

Definition at line 38 of file texture.cc.

39 {
40 const uint8_t* data = static_cast<const uint8_t*>(source_bytes.data());
41 auto copy = std::vector<uint8_t>(data, data + source_bytes.length_in_bytes());
42 // Texture::SetContents is a bit funky right now. It takes a shared_ptr of a
43 // mapping and we're forced to copy here.
44 auto mapping = std::make_shared<fml::DataMapping>(copy);
45
46 // For the GLES backend, command queue submission just flushes the reactor,
47 // which needs to happen on the raster thread.
48 if (gpu_context.GetContext().GetBackendType() ==
50 auto dart_state = flutter::UIDartState::Current();
51 auto& task_runners = dart_state->GetTaskRunners();
52
53 task_runners.GetRasterTaskRunner()->PostTask(
54 fml::MakeCopyable([texture = texture_, mapping = mapping]() mutable {
55 if (!texture->SetContents(mapping)) {
56 FML_LOG(ERROR) << "Failed to set texture contents.";
57 }
58 }));
59 }
60
61 if (!texture_->SetContents(mapping)) {
62 return false;
63 }
64 gpu_context.GetContext().DisposeThreadLocalCachedResources();
65 return true;
66}
static UIDartState * Current()
const void * data() const
size_t length_in_bytes() const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
internal::CopyableLambda< T > MakeCopyable(T lambda)

References flutter::UIDartState::Current(), flutter::data, tonic::DartByteData::data(), impeller::Context::DisposeThreadLocalCachedResources(), impeller::Context::GetBackendType(), flutter::gpu::Context::GetContext(), impeller::Context::kOpenGLES, tonic::DartByteData::length_in_bytes(), fml::MakeCopyable(), and texture.

◆ SetCoordinateSystem()

void flutter::gpu::Texture::SetCoordinateSystem ( impeller::TextureCoordinateSystem  coordinate_system)

Definition at line 33 of file texture.cc.

34 {
35 texture_->SetCoordinateSystem(coordinate_system);
36}

Referenced by InternalFlutterGpu_Texture_SetCoordinateSystem().


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