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 739 of file image_decoder_impeller.cc.

741 : 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 748 of file image_decoder_impeller.cc.

748 {
749 if (!bitmap) {
750 return false;
751 }
752 const SkImageInfo& info = bitmap->info();
753 if (kUnknown_SkColorType == info.colorType() || info.width() < 0 ||
754 info.height() < 0 || !info.validRowBytes(bitmap->rowBytes())) {
755 return false;
756 }
757
760 descriptor.size = ((bitmap->height() - 1) * bitmap->rowBytes()) +
761 (bitmap->width() * bitmap->bytesPerPixel());
762
763 std::shared_ptr<impeller::DeviceBuffer> device_buffer =
764 allocator_->CreateBuffer(descriptor);
765 if (!device_buffer) {
766 return false;
767 }
768
769 struct ImpellerPixelRef final : public SkPixelRef {
770 ImpellerPixelRef(int w, int h, void* s, size_t r)
771 : SkPixelRef(w, h, s, r) {}
772
773 ~ImpellerPixelRef() override {}
774 };
775
776 auto pixel_ref = sk_sp<SkPixelRef>(
777 new ImpellerPixelRef(info.width(), info.height(),
778 device_buffer->OnGetContents(), bitmap->rowBytes()));
779
780 bitmap->setPixelRef(std::move(pixel_ref), 0, 0);
781 buffer_ = std::move(device_buffer);
782 return true;
783}
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 743 of file image_decoder_impeller.cc.

744 {
745 return buffer_;
746}

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