1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 /** \file
21  * \ingroup DNA
22  */
23 
24 #pragma once
25 
26 #include "DNA_ID.h"
27 #include "DNA_color_types.h" /* for color management */
28 #include "DNA_defs.h"
29 
30 struct GPUTexture;
31 struct MovieCache;
32 struct PackedFile;
33 struct RenderResult;
34 struct Scene;
35 struct anim;
36 
37 /* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */
38 /* should be used in conjunction with an ID * to Image. */
39 typedef struct ImageUser {
40   /** To retrieve render result. */
41   struct Scene *scene;
42 
43   /** Movies, sequences: current to display. */
44   int framenr;
45   /** Total amount of frames to use. */
46   int frames;
47   /** Offset within movie, start frame in global time. */
48   int offset, sfra;
49   /** Cyclic flag. */
50   char _pad0, cycl;
51   char ok;
52 
53   /** Multiview current eye - for internal use of drawing routines. */
54   char multiview_eye;
55   short pass;
56   char _pad1[2];
57 
58   int tile;
59   int _pad2;
60 
61   /** Listbase indices, for menu browsing or retrieve buffer. */
62   short multi_index, view, layer;
63   short flag;
64 } ImageUser;
65 
66 typedef struct ImageAnim {
67   struct ImageAnim *next, *prev;
68   struct anim *anim;
69 } ImageAnim;
70 
71 typedef struct ImageView {
72   struct ImageView *next, *prev;
73   /** MAX_NAME. */
74   char name[64];
75   /** 1024 = FILE_MAX. */
76   char filepath[1024];
77 } ImageView;
78 
79 typedef struct ImagePackedFile {
80   struct ImagePackedFile *next, *prev;
81   struct PackedFile *packedfile;
82   /** 1024 = FILE_MAX. */
83   char filepath[1024];
84 } ImagePackedFile;
85 
86 typedef struct RenderSlot {
87   struct RenderSlot *next, *prev;
88   /** 64 = MAX_NAME. */
89   char name[64];
90   struct RenderResult *render;
91 } RenderSlot;
92 
93 typedef struct ImageTile_Runtime {
94   int tilearray_layer;
95   int _pad;
96   int tilearray_offset[2];
97   int tilearray_size[2];
98 } ImageTile_Runtime;
99 
100 typedef struct ImageTile {
101   struct ImageTile *next, *prev;
102 
103   struct ImageTile_Runtime runtime;
104 
105   char ok;
106   char _pad[3];
107 
108   int tile_number;
109   char label[64];
110 } ImageTile;
111 
112 /* iuser->flag */
113 #define IMA_ANIM_ALWAYS (1 << 0)
114 /* #define IMA_UNUSED_1         (1 << 1) */
115 /* #define IMA_UNUSED_2         (1 << 2) */
116 #define IMA_NEED_FRAME_RECALC (1 << 3)
117 #define IMA_SHOW_STEREO (1 << 4)
118 
119 /* Used to get the correct gpu texture from an Image datablock. */
120 typedef enum eGPUTextureTarget {
121   TEXTARGET_2D = 0,
122   TEXTARGET_2D_ARRAY,
123   TEXTARGET_TILE_MAPPING,
124   TEXTARGET_COUNT,
125 } eGPUTextureTarget;
126 
127 typedef struct Image {
128   ID id;
129 
130   /** File path, 1024 = FILE_MAX. */
131   char filepath[1024];
132 
133   /** Not written in file. */
134   struct MovieCache *cache;
135   /** Not written in file 3 = TEXTARGET_COUNT, 2 = stereo eyes. */
136   struct GPUTexture *gputexture[3][2];
137 
138   /* sources from: */
139   ListBase anims;
140   struct RenderResult *rr;
141 
142   ListBase renderslots;
143   short render_slot, last_render_slot;
144 
145   int flag;
146   short source, type;
147   int lastframe;
148 
149   /* GPU texture flag. */
150   int gpuframenr;
151   short gpuflag;
152   short gpu_pass;
153   short gpu_layer;
154   short gpu_slot;
155   char _pad2[4];
156 
157   /** Deprecated. */
158   struct PackedFile *packedfile DNA_DEPRECATED;
159   struct ListBase packedfiles;
160   struct PreviewImage *preview;
161 
162   int lastused;
163 
164   /* for generated images */
165   int gen_x, gen_y;
166   char gen_type, gen_flag;
167   short gen_depth;
168   float gen_color[4];
169 
170   /* display aspect - for UV editing images resized for faster openGL display */
171   float aspx, aspy;
172 
173   /* color management */
174   ColorManagedColorspaceSettings colorspace_settings;
175   char alpha_mode;
176 
177   char _pad;
178 
179   /* Multiview */
180   /** For viewer node stereoscopy. */
181   char eye;
182   char views_format;
183 
184   /* ImageTile list for UDIMs. */
185   int active_tile_index;
186   ListBase tiles;
187 
188   /** ImageView. */
189   ListBase views;
190   struct Stereo3dFormat *stereo3d_format;
191 } Image;
192 
193 /* **************** IMAGE ********************* */
194 
195 /* Image.flag */
196 enum {
197   IMA_HIGH_BITDEPTH = (1 << 0),
198   IMA_FLAG_UNUSED_1 = (1 << 1), /* cleared */
199 #ifdef DNA_DEPRECATED_ALLOW
200   IMA_DO_PREMUL = (1 << 2),
201 #endif
202   IMA_FLAG_UNUSED_4 = (1 << 4), /* cleared */
203   IMA_NOCOLLECT = (1 << 5),
204   IMA_FLAG_UNUSED_6 = (1 << 6), /* cleared */
205   IMA_OLD_PREMUL = (1 << 7),
206   IMA_FLAG_UNUSED_8 = (1 << 8), /* cleared */
207   IMA_USED_FOR_RENDER = (1 << 9),
208   /** For image user, but these flags are mixed. */
209   IMA_USER_FRAME_IN_RANGE = (1 << 10),
210   IMA_VIEW_AS_RENDER = (1 << 11),
211   IMA_FLAG_UNUSED_12 = (1 << 12), /* cleared */
212   IMA_DEINTERLACE = (1 << 13),
213   IMA_USE_VIEWS = (1 << 14),
214   IMA_FLAG_UNUSED_15 = (1 << 15), /* cleared */
215   IMA_FLAG_UNUSED_16 = (1 << 16), /* cleared */
216 };
217 
218 /* Image.gpuflag */
219 enum {
220   /** GPU texture needs to be refreshed. */
221   IMA_GPU_REFRESH = (1 << 0),
222   /** All mipmap levels in OpenGL texture set? */
223   IMA_GPU_MIPMAP_COMPLETE = (1 << 1),
224 };
225 
226 /* Image.source, where the image comes from */
227 enum {
228   /* IMA_SRC_CHECK = 0, */ /* UNUSED */
229   IMA_SRC_FILE = 1,
230   IMA_SRC_SEQUENCE = 2,
231   IMA_SRC_MOVIE = 3,
232   IMA_SRC_GENERATED = 4,
233   IMA_SRC_VIEWER = 5,
234   IMA_SRC_TILED = 6,
235 };
236 
237 /* Image.type, how to handle or generate the image */
238 enum {
239   IMA_TYPE_IMAGE = 0,
240   IMA_TYPE_MULTILAYER = 1,
241   /* generated */
242   IMA_TYPE_UV_TEST = 2,
243   /* viewers */
244   IMA_TYPE_R_RESULT = 4,
245   IMA_TYPE_COMPOSITE = 5,
246 };
247 
248 /* Image.gen_type */
249 enum {
250   IMA_GENTYPE_BLANK = 0,
251   IMA_GENTYPE_GRID = 1,
252   IMA_GENTYPE_GRID_COLOR = 2,
253 };
254 
255 /* render */
256 #define IMA_MAX_RENDER_TEXT (1 << 9)
257 
258 /* Image.gen_flag */
259 enum {
260   IMA_GEN_FLOAT = 1,
261 };
262 
263 /* Image.alpha_mode */
264 enum {
265   IMA_ALPHA_STRAIGHT = 0,
266   IMA_ALPHA_PREMUL = 1,
267   IMA_ALPHA_CHANNEL_PACKED = 2,
268   IMA_ALPHA_IGNORE = 3,
269 };
270