AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
GifImageFactory.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12//
   13// Created by dervisdev on 1/12/2023.
   14//
   15#pragma once
   16
   17#include "AUI/Common/AByteBufferView.h"
   18#include "AUI/Image/IAnimatedImageFactory.h"
   19
   20typedef struct nsgif nsgif_t;
   21
   22class GifImageFactory : public IAnimatedImageFactory {
   23public:
   24    explicit GifImageFactory(AByteBufferView buf);
   25
   26    ~GifImageFactory();
   27
   28    AImage provideImage(const glm::ivec2& size) override;
   29
   30    bool isNewImageAvailable() override;
   31
   32    glm::ivec2 getSizeHint() override;
   33
   34    bool hasAnimationFinished() override;
   35
   36private:
   37    AByteBuffer mGifData;
   38    std::chrono::time_point<std::chrono::high_resolution_clock> mLastFrameStarted;
   39    size_t mCurrentFrameIndex = -1;
   40    size_t mFrameCount;
   41    size_t mWidth = 0;
   42    size_t mHeight = 0;
   43    uint32_t mCurrentFrameLength;
   44    bool mAnimationFinished = false;
   45    nsgif_t* mContext;
   46    uint8_t* mLastFrameBuffer = nullptr;
   47
   48    AImage fetchImage();
   49};
Acts like std::string_view but for AByteBuffer.
Definition AByteBufferView.h:24
std::vector-like growing array for byte storage.
Definition AByteBuffer.h:31
Owning image representation.
Definition AImage.h:25
glm::ivec2 getSizeHint() override
bool hasAnimationFinished() override
Returns true, if last provided frame was last (within one cycle of animation)
Produces images related to an animation.
Definition IAnimatedImageFactory.h:19