2020-04-09 08:04:21 +02:00
|
|
|
//
|
|
|
|
// XCinema.hpp
|
|
|
|
// Clover
|
|
|
|
//
|
|
|
|
// Created by Sergey Isakov on 09/04/2020.
|
|
|
|
// Copyright © 2020 Slice. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef XCinema_h
|
|
|
|
#define XCinema_h
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <Protocol/GraphicsOutput.h>
|
|
|
|
}
|
|
|
|
#include "../cpp_foundation/XArray.h"
|
2020-04-23 15:20:48 +02:00
|
|
|
#include "../cpp_foundation/XString.h"
|
2020-04-09 08:04:21 +02:00
|
|
|
#include "../libeg/libeg.h"
|
2023-11-08 14:35:22 +01:00
|
|
|
#include "../libeg/nanosvg.h"
|
2020-04-09 08:04:21 +02:00
|
|
|
#include "XImage.h"
|
|
|
|
|
2020-04-14 18:52:13 +02:00
|
|
|
class XTheme;
|
2020-08-17 21:40:52 +02:00
|
|
|
class XCinema;
|
2020-04-09 08:04:21 +02:00
|
|
|
|
|
|
|
class FILM
|
|
|
|
{
|
2020-04-14 21:37:44 +02:00
|
|
|
protected:
|
|
|
|
INTN Id; //ScreenID, enumeration value but keep it to be int for extensibility
|
2020-04-09 15:04:12 +02:00
|
|
|
public:
|
2020-04-14 18:52:13 +02:00
|
|
|
//I see no reason to make they protected
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool RunOnce;
|
2020-04-14 18:52:13 +02:00
|
|
|
INTN NumFrames; //set by user in Theme.plist or in Theme.svg
|
|
|
|
INTN FrameTime; //usually 50, 100, 200 ms
|
|
|
|
INTN FilmX, FilmY; //relative
|
|
|
|
INTN ScreenEdgeHorizontal;
|
|
|
|
INTN ScreenEdgeVertical;
|
|
|
|
INTN NudgeX, NudgeY;
|
|
|
|
XStringW Path; //user defined name for folder and files Path/Path_002.png etc
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool AnimeRun;
|
2020-04-23 10:42:18 +02:00
|
|
|
UINT64 LastDraw;
|
2020-04-13 21:01:40 +02:00
|
|
|
|
2020-04-14 18:52:13 +02:00
|
|
|
protected:
|
|
|
|
XObjArray<IndexedImage> Frames; //Frames can be not sorted
|
2020-04-23 10:42:18 +02:00
|
|
|
INTN LastIndex; // it is not Frames.size(), it is last index inclusive, so frames 0,1,2,5,8 be LastIndex = 8
|
|
|
|
INTN CurrentFrame; // must be unique for each film
|
2020-04-14 18:52:13 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
EG_RECT FilmPlace; // Screen has several Films each in own place
|
2020-04-09 08:04:21 +02:00
|
|
|
|
|
|
|
public:
|
2021-09-28 10:28:45 +02:00
|
|
|
FILM() : Id(0), RunOnce(false), NumFrames(0), FrameTime(0), FilmX(0), FilmY(0), ScreenEdgeHorizontal(0), ScreenEdgeVertical(0),
|
|
|
|
NudgeX(0), NudgeY(0), Path(), AnimeRun(false), LastDraw(0), Frames(), LastIndex(0), CurrentFrame(0), FilmPlace()
|
2020-08-11 14:43:53 +02:00
|
|
|
{}
|
2021-09-28 10:28:45 +02:00
|
|
|
FILM(INTN Id) : Id(Id), RunOnce(false), NumFrames(0), FrameTime(0), FilmX(0), FilmY(0), ScreenEdgeHorizontal(0), ScreenEdgeVertical(0),
|
|
|
|
NudgeX(0), NudgeY(0), Path(), AnimeRun(false), LastDraw(0), Frames(), LastIndex(0), CurrentFrame(0), FilmPlace()
|
2020-08-11 14:43:53 +02:00
|
|
|
{}
|
2020-04-13 21:01:40 +02:00
|
|
|
~FILM() {}
|
2020-04-09 08:04:21 +02:00
|
|
|
|
2020-04-14 21:37:44 +02:00
|
|
|
INTN GetIndex() { return Id; }
|
|
|
|
void SetIndex(INTN Index) { Id = Index; }
|
|
|
|
|
2020-04-14 18:52:13 +02:00
|
|
|
const XImage& GetImage(INTN Index) const;
|
2021-09-28 15:54:31 +02:00
|
|
|
const XImage& GetImage(XBool *free = nullptr) const;
|
2020-04-14 18:52:13 +02:00
|
|
|
void AddFrame(XImage* Frame, INTN Index); //IndexedImage will be created
|
2020-04-09 08:04:21 +02:00
|
|
|
size_t Size() { return Frames.size(); }
|
2020-04-14 18:52:13 +02:00
|
|
|
INTN LastFrameID() { return LastIndex; }
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool Finished() { return CurrentFrame == 0; }
|
2020-04-14 21:37:44 +02:00
|
|
|
void GetFrames(XTheme& TheTheme/*, const XStringW& Path*/); //read image sequence from Theme/Path/
|
2023-11-08 14:35:22 +01:00
|
|
|
void GetFramesSVG(NSVGparser* SVGParser, XTheme& TheTheme);
|
2020-04-14 18:52:13 +02:00
|
|
|
void SetPlace(const EG_RECT& Rect) { FilmPlace = Rect; }
|
|
|
|
void Advance() { ++CurrentFrame %= (LastIndex + 1); }
|
|
|
|
void Reset() { CurrentFrame = 0; }
|
|
|
|
// EFI_STATUS GetFrame(IN INTN Index, OUT XImage *Frame); //usually Index=CurrentFrame
|
|
|
|
// EFI_STATUS GetFrame(OUT XImage *Frame);
|
2020-04-09 08:04:21 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//initially it was supposed to be one anime per one REFIT_SCREEN
|
|
|
|
// but this leads to large delays switching screens to initialize Film sequence again and again
|
2020-04-13 21:01:40 +02:00
|
|
|
// otherwise anime depends on theme and should be a member of XTheme
|
2020-04-09 08:04:21 +02:00
|
|
|
// then it should contain Screen->ID for each film
|
2020-04-13 21:01:40 +02:00
|
|
|
// but for next future we want to have other animated images in addition to screen->titleimage
|
2020-04-09 08:04:21 +02:00
|
|
|
// so let it be frames arrays each with own purpose (Id)
|
2020-04-14 18:52:13 +02:00
|
|
|
//
|
2020-04-13 21:01:40 +02:00
|
|
|
// XTheme contains Cinema which is an array of FILMs
|
|
|
|
// Each Screen contains a pointer to a FILM. And moreover titleFilm, or BackgroundFilm or even entryFilm
|
2020-04-09 08:04:21 +02:00
|
|
|
// Next problem is a timeout between frames.
|
|
|
|
// A theme contains images with indexes 1,2,5,6 for one Id.
|
2020-04-09 15:04:12 +02:00
|
|
|
// This Id contains fixed timeout between frames. Then next updateAnime Index will be compared with current tick
|
|
|
|
// if yes then update. Static index?
|
|
|
|
//
|
|
|
|
// in the far future I'll plan to make dynamic SVG: parse SVGIcon with a variable argument
|
2020-04-14 18:52:13 +02:00
|
|
|
// and then rasterize it. Real SVG contains constants only so it will be new dynamicSVG.
|
2020-04-09 15:04:12 +02:00
|
|
|
// then Entry->Image should be reparsed each time it created or contains flag to update every frameTime
|
|
|
|
|
2020-04-09 08:04:21 +02:00
|
|
|
class XCinema
|
|
|
|
{
|
|
|
|
protected:
|
2020-04-09 15:04:12 +02:00
|
|
|
XObjArray<FILM> Cinema;
|
2020-04-09 08:04:21 +02:00
|
|
|
|
|
|
|
public:
|
2020-08-11 14:43:53 +02:00
|
|
|
XCinema() : Cinema() {}
|
2020-04-13 21:01:40 +02:00
|
|
|
~XCinema() {}
|
2020-04-09 08:04:21 +02:00
|
|
|
|
|
|
|
FILM* GetFilm(INTN Id);
|
2020-04-14 18:52:13 +02:00
|
|
|
void AddFilm(FILM* NewFilm);
|
2020-08-12 17:15:47 +02:00
|
|
|
void setEmpty() { Cinema.setEmpty(); }
|
2020-04-09 08:04:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* XCinema_h */
|