mirror of
https://github.com/esphome/esphome.git
synced 2026-02-14 21:47:41 -07:00
Compare commits
1 Commits
online-ima
...
runtime-im
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be5f4845eb |
@@ -50,7 +50,8 @@ static void draw_callback(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, ui
|
||||
|
||||
PngDecoder::PngDecoder(RuntimeImage *image) : ImageDecoder(image) {
|
||||
{
|
||||
pngle_t *pngle = this->allocator_.allocate(1, PNGLE_T_SIZE);
|
||||
RAMAllocator<pngle_t> allocator;
|
||||
pngle_t *pngle = allocator.allocate(1, PNGLE_T_SIZE);
|
||||
if (!pngle) {
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for PNGLE engine!");
|
||||
return;
|
||||
@@ -64,7 +65,8 @@ PngDecoder::PngDecoder(RuntimeImage *image) : ImageDecoder(image) {
|
||||
PngDecoder::~PngDecoder() {
|
||||
if (this->pngle_) {
|
||||
pngle_reset(this->pngle_);
|
||||
this->allocator_.deallocate(this->pngle_, PNGLE_T_SIZE);
|
||||
RAMAllocator<pngle_t> allocator;
|
||||
allocator.deallocate(this->pngle_, PNGLE_T_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ class PngDecoder : public ImageDecoder {
|
||||
uint32_t get_pixels_decoded() const { return this->pixels_decoded_; }
|
||||
|
||||
protected:
|
||||
RAMAllocator<pngle_t> allocator_;
|
||||
pngle_t *pngle_{nullptr};
|
||||
uint32_t pixels_decoded_{0};
|
||||
};
|
||||
|
||||
@@ -230,7 +230,8 @@ void RuntimeImage::release() {
|
||||
void RuntimeImage::release_buffer_() {
|
||||
if (this->buffer_) {
|
||||
ESP_LOGV(TAG, "Releasing buffer of size %zu", this->get_buffer_size_(this->buffer_width_, this->buffer_height_));
|
||||
this->allocator_.deallocate(this->buffer_, this->get_buffer_size_(this->buffer_width_, this->buffer_height_));
|
||||
RAMAllocator<uint8_t> allocator;
|
||||
allocator.deallocate(this->buffer_, this->get_buffer_size_(this->buffer_width_, this->buffer_height_));
|
||||
this->buffer_ = nullptr;
|
||||
this->data_start_ = nullptr;
|
||||
this->width_ = 0;
|
||||
@@ -254,11 +255,12 @@ size_t RuntimeImage::resize_buffer_(int width, int height) {
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Allocating buffer: %dx%d, %zu bytes", width, height, new_size);
|
||||
this->buffer_ = this->allocator_.allocate(new_size);
|
||||
RAMAllocator<uint8_t> allocator;
|
||||
this->buffer_ = allocator.allocate(new_size);
|
||||
|
||||
if (!this->buffer_) {
|
||||
ESP_LOGE(TAG, "Failed to allocate %zu bytes. Largest free block: %zu", new_size,
|
||||
this->allocator_.get_max_free_block_size());
|
||||
allocator.get_max_free_block_size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ class RuntimeImage : public image::Image {
|
||||
std::unique_ptr<ImageDecoder> create_decoder_();
|
||||
|
||||
// Memory management
|
||||
RAMAllocator<uint8_t> allocator_{};
|
||||
uint8_t *buffer_{nullptr};
|
||||
|
||||
// Decoder management
|
||||
|
||||
Reference in New Issue
Block a user