Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::ImpellerAllocator Class Reference

#include <image_decoder_impeller.h>

Inheritance diagram for flutter::ImpellerAllocator:
Allocator

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 24 of file image_decoder_impeller.h.

Constructor & Destructor Documentation

◆ ImpellerAllocator()

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

Definition at line 504 of file image_decoder_impeller.cc.

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

◆ ~ImpellerAllocator()

flutter::ImpellerAllocator::~ImpellerAllocator ( )
default

Member Function Documentation

◆ allocPixelRef()

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

Definition at line 513 of file image_decoder_impeller.cc.

513 {
514 if (!bitmap) {
515 return false;
516 }
517 const SkImageInfo& info = bitmap->info();
518 if (kUnknown_SkColorType == info.colorType() || info.width() < 0 ||
519 info.height() < 0 || !info.validRowBytes(bitmap->rowBytes())) {
520 return false;
521 }
522
525 descriptor.size = ((bitmap->height() - 1) * bitmap->rowBytes()) +
526 (bitmap->width() * bitmap->bytesPerPixel());
527
528 std::shared_ptr<impeller::DeviceBuffer> device_buffer =
529 allocator_->CreateBuffer(descriptor);
530 if (!device_buffer) {
531 return false;
532 }
533
534 struct ImpellerPixelRef final : public SkPixelRef {
535 ImpellerPixelRef(int w, int h, void* s, size_t r)
536 : SkPixelRef(w, h, s, r) {}
537
538 ~ImpellerPixelRef() override {}
539 };
540
541 auto pixel_ref = sk_sp<SkPixelRef>(
542 new ImpellerPixelRef(info.width(), info.height(),
543 device_buffer->OnGetContents(), bitmap->rowBytes()));
544
545 bitmap->setPixelRef(std::move(pixel_ref), 0, 0);
546 buffer_ = std::move(device_buffer);
547 return true;
548}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
struct MyStruct s
Definition: bitmap.py:1
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: switches.h:59
SkScalar w

◆ GetDeviceBuffer()

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

Definition at line 508 of file image_decoder_impeller.cc.

509 {
510 return buffer_;
511}

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