Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 518 of file image_decoder_impeller.cc.

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

◆ ~ImpellerAllocator()

flutter::ImpellerAllocator::~ImpellerAllocator ( )
default

Member Function Documentation

◆ allocPixelRef()

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

Definition at line 527 of file image_decoder_impeller.cc.

527 {
528 if (!bitmap) {
529 return false;
530 }
531 const SkImageInfo& info = bitmap->info();
532 if (kUnknown_SkColorType == info.colorType() || info.width() < 0 ||
533 info.height() < 0 || !info.validRowBytes(bitmap->rowBytes())) {
534 return false;
535 }
536
539 descriptor.size = ((bitmap->height() - 1) * bitmap->rowBytes()) +
540 (bitmap->width() * bitmap->bytesPerPixel());
541
542 std::shared_ptr<impeller::DeviceBuffer> device_buffer =
543 allocator_->CreateBuffer(descriptor);
544 if (!device_buffer) {
545 return false;
546 }
547
548 struct ImpellerPixelRef final : public SkPixelRef {
549 ImpellerPixelRef(int w, int h, void* s, size_t r)
550 : SkPixelRef(w, h, s, r) {}
551
552 ~ImpellerPixelRef() override {}
553 };
554
555 auto pixel_ref = sk_sp<SkPixelRef>(
556 new ImpellerPixelRef(info.width(), info.height(),
557 device_buffer->OnGetContents(), bitmap->rowBytes()));
558
559 bitmap->setPixelRef(std::move(pixel_ref), 0, 0);
560 buffer_ = std::move(device_buffer);
561 return true;
562}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
struct MyStruct s
SkScalar w
SkScalar h

◆ GetDeviceBuffer()

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

Definition at line 522 of file image_decoder_impeller.cc.

523 {
524 return buffer_;
525}

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