Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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 26 of file texture.cc.

27 : 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 75 of file texture.cc.

75 {
76 // DlImageImpeller isn't compiled in builds with Impeller disabled. If
77 // Impeller is disabled, it's impossible to get here anyhow, so just ifdef it
78 // out.
79#if IMPELLER_SUPPORTS_RENDERING
81 auto dl_image = impeller::DlImageImpeller::Make(texture_);
82 image->set_image(dl_image);
83 auto wrapped = image->CreateOuterWrapping();
84 return wrapped;
85#else
86 return Dart_Null();
87#endif
88}
static fml::RefPtr< CanvasImage > Create()
Definition image.h:36
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 70 of file texture.cc.

70 {
72 texture_->GetTextureDescriptor().format);
73}
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition formats.h:469

References impeller::BytesPerPixelForPixelFormat().

Referenced by InternalFlutterGpu_Texture_BytesPerTexel().

◆ GetTexture()

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

Definition at line 31 of file texture.cc.

31 {
32 return texture_;
33}

Referenced by InternalFlutterGpu_RenderPass_SetColorAttachment().

◆ Overwrite()

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

Definition at line 40 of file texture.cc.

41 {
42 const uint8_t* data = static_cast<const uint8_t*>(source_bytes.data());
43 auto copy = std::vector<uint8_t>(data, data + source_bytes.length_in_bytes());
44 // Texture::SetContents is a bit funky right now. It takes a shared_ptr of a
45 // mapping and we're forced to copy here.
46 auto mapping = std::make_shared<fml::DataMapping>(copy);
47
48 // For the GLES backend, command queue submission just flushes the reactor,
49 // which needs to happen on the raster thread.
50 if (gpu_context.GetContext().GetBackendType() ==
52 auto dart_state = flutter::UIDartState::Current();
53 auto& task_runners = dart_state->GetTaskRunners();
54
55 task_runners.GetRasterTaskRunner()->PostTask(
56 fml::MakeCopyable([texture = texture_, mapping = mapping]() mutable {
57 if (!texture->SetContents(mapping)) {
58 FML_LOG(ERROR) << "Failed to set texture contents.";
59 }
60 }));
61 }
62
63 if (!texture_->SetContents(mapping)) {
64 return false;
65 }
66 gpu_context.GetContext().DisposeThreadLocalCachedResources();
67 return true;
68}
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 35 of file texture.cc.

36 {
37 texture_->SetCoordinateSystem(coordinate_system);
38}

Referenced by InternalFlutterGpu_Texture_SetCoordinateSystem().


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