Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::ImpellerAllocator Class Reference

#include <image_decoder_impeller.h>

Inheritance diagram for flutter::ImpellerAllocator:

Public Member Functions

 ImpellerAllocator (std::shared_ptr< impeller::Allocator > allocator)
 
 ~ImpellerAllocator ()=default
 
bool allocPixelRef (SkBitmap *bitmap) override
 
std::shared_ptr< impeller::DeviceBufferGetDeviceBuffer () const
 

Detailed Description

Definition at line 27 of file image_decoder_impeller.h.

Constructor & Destructor Documentation

◆ ImpellerAllocator()

flutter::ImpellerAllocator::ImpellerAllocator ( std::shared_ptr< impeller::Allocator allocator)
explicit

Definition at line 741 of file image_decoder_impeller.cc.

743 : allocator_(std::move(allocator)) {}
std::shared_ptr< ImpellerAllocator > allocator

◆ ~ImpellerAllocator()

flutter::ImpellerAllocator::~ImpellerAllocator ( )
default

Member Function Documentation

◆ allocPixelRef()

bool flutter::ImpellerAllocator::allocPixelRef ( SkBitmap *  bitmap)
override

Definition at line 750 of file image_decoder_impeller.cc.

750 {
751 if (!bitmap) {
752 return false;
753 }
754 const SkImageInfo& info = bitmap->info();
755 if (kUnknown_SkColorType == info.colorType() || info.width() < 0 ||
756 info.height() < 0 || !info.validRowBytes(bitmap->rowBytes())) {
757 return false;
758 }
759
762 descriptor.size = ((bitmap->height() - 1) * bitmap->rowBytes()) +
763 (bitmap->width() * bitmap->bytesPerPixel());
764
765 std::shared_ptr<impeller::DeviceBuffer> device_buffer =
766 allocator_->CreateBuffer(descriptor);
767 if (!device_buffer) {
768 return false;
769 }
770
771 struct ImpellerPixelRef final : public SkPixelRef {
772 ImpellerPixelRef(int w, int h, void* s, size_t r)
773 : SkPixelRef(w, h, s, r) {}
774
775 ~ImpellerPixelRef() override {}
776 };
777
778 auto pixel_ref = sk_sp<SkPixelRef>(
779 new ImpellerPixelRef(info.width(), info.height(),
780 device_buffer->OnGetContents(), bitmap->rowBytes()));
781
782 bitmap->setPixelRef(std::move(pixel_ref), 0, 0);
783 buffer_ = std::move(device_buffer);
784 return true;
785}
std::shared_ptr< SkBitmap > bitmap
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder h
Definition switch_defs.h:54

References bitmap, flutter::h, impeller::kHostVisible, impeller::DeviceBufferDescriptor::size, and impeller::DeviceBufferDescriptor::storage_mode.

◆ GetDeviceBuffer()

std::shared_ptr< impeller::DeviceBuffer > flutter::ImpellerAllocator::GetDeviceBuffer ( ) const

Definition at line 745 of file image_decoder_impeller.cc.

746 {
747 return buffer_;
748}

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