Flutter Engine
 
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 26 of file image_decoder_impeller.h.

Constructor & Destructor Documentation

◆ ImpellerAllocator()

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

Definition at line 605 of file image_decoder_impeller.cc.

607 : allocator_(std::move(allocator)) {}

◆ ~ImpellerAllocator()

flutter::ImpellerAllocator::~ImpellerAllocator ( )
default

Member Function Documentation

◆ allocPixelRef()

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

Definition at line 614 of file image_decoder_impeller.cc.

614 {
615 if (!bitmap) {
616 return false;
617 }
618 const SkImageInfo& info = bitmap->info();
619 if (kUnknown_SkColorType == info.colorType() || info.width() < 0 ||
620 info.height() < 0 || !info.validRowBytes(bitmap->rowBytes())) {
621 return false;
622 }
623
626 descriptor.size = ((bitmap->height() - 1) * bitmap->rowBytes()) +
627 (bitmap->width() * bitmap->bytesPerPixel());
628
629 std::shared_ptr<impeller::DeviceBuffer> device_buffer =
630 allocator_->CreateBuffer(descriptor);
631 if (!device_buffer) {
632 return false;
633 }
634
635 struct ImpellerPixelRef final : public SkPixelRef {
636 ImpellerPixelRef(int w, int h, void* s, size_t r)
637 : SkPixelRef(w, h, s, r) {}
638
639 ~ImpellerPixelRef() override {}
640 };
641
642 auto pixel_ref = sk_sp<SkPixelRef>(
643 new ImpellerPixelRef(info.width(), info.height(),
644 device_buffer->OnGetContents(), bitmap->rowBytes()));
645
646 bitmap->setPixelRef(std::move(pixel_ref), 0, 0);
647 buffer_ = std::move(device_buffer);
648 return true;
649}
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 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 609 of file image_decoder_impeller.cc.

610 {
611 return buffer_;
612}

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