-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFrameInfo.h
executable file
·148 lines (122 loc) · 3.88 KB
/
FrameInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* Copyright (C) 2018-2024 The Surface Frame-Animation Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _FRAME_INFO_H_
#define _FRAME_INFO_H_
#include <istream>
#include <vector>
#include <androidfw/ZipFileRO.h>
#include <androidfw/AssetManager.h>
#include "FrameStream.h"
#include "FrameError.h"
using namespace std;
using namespace android;
namespace frame_animation {
/* Animation Resource Type */
enum AnimResType {
FRAME_RES_TYPE_DIR,
FRAME_RES_TYPE_ZIP,
FRAME_RES_TYPE_APK,
FRAME_RES_TYPE_NONE,
};
/* Display Area of Animation */
struct Size {
int width;
int height;
};
/* Animation Excute Mode */
enum AnimMode {
FRAME_MODE_REVERSE,
FRAME_MODE_REPEATE,
FRAME_MODE_NORMAL,
};
/* Animation Information */
struct AnimInfo {
string frame_path; /* Images Directory Relative Root */
vector<string> frames; /* Frame Image Name Relative Images */
AnimMode mode; /* reapte/reverse/normal */
int rate; /* frames per seconds */
Size size; /* Anim Display Area */
};
class FrameInfo {
/* Frme Desc key/value */
static const string DESC_KEY_RESOLUTION;
static const string DESC_KEY_MODE;
static const string DESC_KEY_RATE;
static const string DESC_KEY_FRAMES;
static const string DESC_KEY_FRAME_PATH;
static const string DESC_KEY_FRAME_TYPE;
/* Frame Mode String */
static const string FRAME_MODE_REVERSE_STR;
static const string FRAME_MODE_REPEATE_STR;
static const string FRAME_MODE_NORMAL_STR;
static const string PROP_SDK_VERSION;
static ResTable_config default_resource_config();
void parse_desc_item(const string&, const string&);
AnimMode frame_mode (const string&) const;
void dump () const;
protected:
/* Frame Info FileName */
static const string ENTRY_DESC;
int max_frame; /* max frames */
AnimInfo info;
virtual string parse_anim_file() = 0;
public:
virtual ~FrameInfo () {}
int count();
AnimMode mode();
int rate();
Size size();
void parse_anim_info ();
virtual shared_ptr<istream> frame(int) = 0;
static shared_ptr<FrameInfo> create_from_type (const string&, AnimResType type);
};
// --------------------------------------------------------
class ZipFrameInfo : public FrameInfo {
shared_ptr<ZipFileRO> zip_file;
public:
ZipFrameInfo (shared_ptr<ZipFileRO> zip) {
zip_file = zip;
}
virtual ~ZipFrameInfo () {}
virtual shared_ptr<istream> frame(int) override;
protected:
virtual string parse_anim_file () override;
};
// --------------------------------------------------------
class ApkFrameInfo : public FrameInfo {
static const string APK_PACKAGE;
static const string APK_NAME;
static const string APK_DESC_TYPE;
static const string APK_ANIM_TYPE;
shared_ptr<AssetManager> assetManager;
public:
ApkFrameInfo (shared_ptr<AssetManager> assetManager):assetManager(assetManager) {}
virtual shared_ptr<istream> frame(int) override;
virtual ~ApkFrameInfo() {}
protected:
virtual string parse_anim_file () override;
};
class DIRFrameInfo : public FrameInfo {
string parent_path; /* Root Path */
public:
DIRFrameInfo (const string& path):parent_path(path) {}
virtual shared_ptr<istream> frame(int) override;
virtual ~DIRFrameInfo() {}
protected:
virtual string parse_anim_file () override;
};
}; //namespace frame_animation
#endif