kodi
XBTF.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <ctime>
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 #include <stdint.h>
17 
18 static const std::string XBTF_MAGIC = "XBTF";
19 static const std::string XBTF_VERSION = "2";
20 
21 #include "TextureFormats.h"
22 
24 {
25 public:
26  CXBTFFrame();
27 
28  uint32_t GetWidth() const;
29  void SetWidth(uint32_t width);
30 
31  XB_FMT GetFormat(bool raw = false) const;
32  void SetFormat(XB_FMT format);
33 
34  uint32_t GetHeight() const;
35  void SetHeight(uint32_t height);
36 
37  uint64_t GetUnpackedSize() const;
38  void SetUnpackedSize(uint64_t size);
39 
40  uint64_t GetPackedSize() const;
41  void SetPackedSize(uint64_t size);
42 
43  uint64_t GetOffset() const;
44  void SetOffset(uint64_t offset);
45 
46  uint64_t GetHeaderSize() const;
47 
48  uint32_t GetDuration() const;
49  void SetDuration(uint32_t duration);
50 
51  bool IsPacked() const;
52  bool HasAlpha() const;
53 
54 private:
55  uint32_t m_width;
56  uint32_t m_height;
57  XB_FMT m_format;
58  uint64_t m_packedSize;
59  uint64_t m_unpackedSize;
60  uint64_t m_offset;
61  uint32_t m_duration;
62 };
63 
64 class CXBTFFile
65 {
66 public:
67  CXBTFFile();
68 
69  const std::string& GetPath() const;
70  void SetPath(const std::string& path);
71 
72  uint32_t GetLoop() const;
73  void SetLoop(uint32_t loop);
74 
75  const std::vector<CXBTFFrame>& GetFrames() const;
76  std::vector<CXBTFFrame>& GetFrames();
77 
78  uint64_t GetPackedSize() const;
79  uint64_t GetUnpackedSize() const;
80  uint64_t GetHeaderSize() const;
81 
82  static const size_t MaximumPathLength = 256;
83 
84 private:
85  std::string m_path;
86  uint32_t m_loop = 0;
87  std::vector<CXBTFFrame> m_frames;
88 };
89 
90 class CXBTFBase
91 {
92 public:
93  virtual ~CXBTFBase() = default;
94 
95  uint64_t GetHeaderSize() const;
96 
97  bool Exists(const std::string& name) const;
98  bool Get(const std::string& name, CXBTFFile& file) const;
99  std::vector<CXBTFFile> GetFiles() const;
100  void AddFile(const CXBTFFile& file);
101  void UpdateFile(const CXBTFFile& file);
102 
103 protected:
104  CXBTFBase() = default;
105 
106  std::map<std::string, CXBTFFile> m_files;
107 };
Definition: XBTF.h:23
Definition: XBTF.h:90
Definition: XBTF.h:64