Blender  V2.93
image_engine.c
Go to the documentation of this file.
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  * Copyright 2020, Blender Foundation.
17  */
18 
25 #include "DRW_render.h"
26 
27 #include "BKE_image.h"
28 #include "BKE_main.h"
29 #include "BKE_object.h"
30 
31 #include "DNA_camera_types.h"
32 #include "DNA_screen_types.h"
33 
34 #include "IMB_imbuf.h"
35 #include "IMB_imbuf_types.h"
36 
37 #include "ED_image.h"
38 
39 #include "GPU_batch.h"
40 
41 #include "image_engine.h"
42 #include "image_private.h"
43 
44 #define IMAGE_DRAW_FLAG_SHOW_ALPHA (1 << 0)
45 #define IMAGE_DRAW_FLAG_APPLY_ALPHA (1 << 1)
46 #define IMAGE_DRAW_FLAG_SHUFFLING (1 << 2)
47 #define IMAGE_DRAW_FLAG_DEPTH (1 << 3)
48 #define IMAGE_DRAW_FLAG_DO_REPEAT (1 << 4)
49 #define IMAGE_DRAW_FLAG_USE_WORLD_POS (1 << 5)
50 
51 static void image_cache_image_add(DRWShadingGroup *grp, Image *image, ImBuf *ibuf)
52 {
53  const DRWContextState *draw_ctx = DRW_context_state_get();
54  const ARegion *region = draw_ctx->region;
55  const char space_type = draw_ctx->space_data->spacetype;
56 
57  float zoom_x = 1.0f;
58  float zoom_y = 1.0f;
59  float translate_x = 0.0f;
60  float translate_y = 0.0f;
61 
62  /* User can freely move the backdrop in the space of the node editor */
63  if (space_type == SPACE_NODE) {
64  SpaceNode *snode = (SpaceNode *)draw_ctx->space_data;
65  const float ibuf_width = ibuf->x;
66  const float ibuf_height = ibuf->y;
67  const float x = (region->winx - snode->zoom * ibuf_width) / 2 + snode->xof;
68  const float y = (region->winy - snode->zoom * ibuf_height) / 2 + snode->yof;
69 
70  zoom_x = ibuf_width * snode->zoom;
71  zoom_y = ibuf_height * snode->zoom;
72  translate_x = x;
73  translate_y = y;
74  }
75 
76  const bool is_tiled_texture = image && image->source == IMA_SRC_TILED;
77  float obmat[4][4];
78  unit_m4(obmat);
79 
80  GPUBatch *geom = DRW_cache_quad_get();
81 
82  obmat[0][0] = zoom_x;
83  obmat[1][1] = zoom_y;
84  obmat[3][1] = translate_y;
85  obmat[3][0] = translate_x;
86 
87  if (is_tiled_texture) {
88  LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
89  const int tile_x = ((tile->tile_number - 1001) % 10);
90  const int tile_y = ((tile->tile_number - 1001) / 10);
91  obmat[3][1] = (float)tile_y + translate_y;
92  obmat[3][0] = (float)tile_x + translate_x;
93  DRW_shgroup_call_obmat(grp, geom, obmat);
94  }
95  }
96  else {
97  DRW_shgroup_call_obmat(grp, geom, obmat);
98  }
99 }
100 
102  ImageUser *iuser,
103  ImBuf *ibuf,
104  GPUTexture **r_gpu_texture,
105  bool *r_owns_texture,
106  GPUTexture **r_tex_tile_data)
107 {
108  const DRWContextState *draw_ctx = DRW_context_state_get();
109  SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
110  if (image->rr != NULL) {
111  /* Update multi-index and pass for the current eye. */
112  BKE_image_multilayer_index(image->rr, &sima->iuser);
113  }
114  else {
115  BKE_image_multiview_index(image, &sima->iuser);
116  }
117 
118  if (ibuf) {
119  const int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf);
120  if (sima_flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
121  if (ibuf->zbuf) {
122  BLI_assert(!"Integer based depth buffers not supported");
123  }
124  else if (ibuf->zbuf_float) {
125  *r_gpu_texture = GPU_texture_create_2d(
126  __func__, ibuf->x, ibuf->y, 0, GPU_R16F, ibuf->zbuf_float);
127  *r_owns_texture = true;
128  }
129  else if (ibuf->rect_float && ibuf->channels == 1) {
130  *r_gpu_texture = GPU_texture_create_2d(
131  __func__, ibuf->x, ibuf->y, 0, GPU_R16F, ibuf->rect_float);
132  *r_owns_texture = true;
133  }
134  }
135  else if (image->source == IMA_SRC_TILED) {
136  *r_gpu_texture = BKE_image_get_gpu_tiles(image, iuser, ibuf);
137  *r_tex_tile_data = BKE_image_get_gpu_tilemap(image, iuser, NULL);
138  *r_owns_texture = false;
139  }
140  else {
141  *r_gpu_texture = BKE_image_get_gpu_texture(image, iuser, ibuf);
142  *r_owns_texture = false;
143  }
144  }
145 }
146 
148  ImageUser *iuser,
149  ImBuf *ibuf,
150  GPUTexture **r_gpu_texture,
151  bool *r_owns_texture,
152  GPUTexture **r_tex_tile_data)
153 {
154  *r_gpu_texture = BKE_image_get_gpu_texture(image, iuser, ibuf);
155  *r_owns_texture = false;
156  *r_tex_tile_data = NULL;
157 }
158 
159 static void image_gpu_texture_get(Image *image,
160  ImageUser *iuser,
161  ImBuf *ibuf,
162  GPUTexture **r_gpu_texture,
163  bool *r_owns_texture,
164  GPUTexture **r_tex_tile_data)
165 {
166  if (!image) {
167  return;
168  }
169 
170  const DRWContextState *draw_ctx = DRW_context_state_get();
171  const char space_type = draw_ctx->space_data->spacetype;
172 
173  if (space_type == SPACE_IMAGE) {
175  image, iuser, ibuf, r_gpu_texture, r_owns_texture, r_tex_tile_data);
176  }
177  else if (space_type == SPACE_NODE) {
178  space_node_gpu_texture_get(image, iuser, ibuf, r_gpu_texture, r_owns_texture, r_tex_tile_data);
179  }
180 }
181 
182 static void image_cache_image(IMAGE_Data *vedata, Image *image, ImageUser *iuser, ImBuf *ibuf)
183 {
184  IMAGE_PassList *psl = vedata->psl;
185  IMAGE_StorageList *stl = vedata->stl;
186  IMAGE_PrivateData *pd = stl->pd;
187 
188  const DRWContextState *draw_ctx = DRW_context_state_get();
189  const char space_type = draw_ctx->space_data->spacetype;
190  const Scene *scene = draw_ctx->scene;
191 
192  GPUTexture *tex_tile_data = NULL;
193  image_gpu_texture_get(image, iuser, ibuf, &pd->texture, &pd->owns_texture, &tex_tile_data);
194 
195  if (pd->texture) {
196  static float color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
197  static float shuffle[4] = {1.0f, 1.0f, 1.0f, 1.0f};
198  static float far_near[2] = {100.0f, 0.0f};
199 
200  if (scene->camera && scene->camera->type == OB_CAMERA) {
201  far_near[1] = ((Camera *)scene->camera->data)->clip_start;
202  far_near[0] = ((Camera *)scene->camera->data)->clip_end;
203  }
204 
205  const bool use_premul_alpha = BKE_image_has_gpu_texture_premultiplied_alpha(image, ibuf);
206  const bool is_tiled_texture = tex_tile_data != NULL;
207 
208  int draw_flags = 0;
209  if (space_type == SPACE_IMAGE) {
210  SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
211  const int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf);
212  const bool do_repeat = (!is_tiled_texture) && ((sima->flag & SI_DRAW_TILE) != 0);
213  SET_FLAG_FROM_TEST(draw_flags, do_repeat, IMAGE_DRAW_FLAG_DO_REPEAT);
214  SET_FLAG_FROM_TEST(draw_flags, is_tiled_texture, IMAGE_DRAW_FLAG_USE_WORLD_POS);
215  if ((sima_flag & SI_USE_ALPHA) != 0) {
216  /* Show RGBA */
218  }
219  else if ((sima_flag & SI_SHOW_ALPHA) != 0) {
220  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
221  copy_v4_fl4(shuffle, 0.0f, 0.0f, 0.0f, 1.0f);
222  }
223  else if ((sima_flag & SI_SHOW_ZBUF) != 0) {
225  copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
226  }
227  else if ((sima_flag & SI_SHOW_R) != 0) {
228  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
229  if (IMB_alpha_affects_rgb(ibuf)) {
230  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
231  }
232  copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
233  }
234  else if ((sima_flag & SI_SHOW_G) != 0) {
235  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
236  if (IMB_alpha_affects_rgb(ibuf)) {
237  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
238  }
239  copy_v4_fl4(shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
240  }
241  else if ((sima_flag & SI_SHOW_B) != 0) {
242  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
243  if (IMB_alpha_affects_rgb(ibuf)) {
244  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
245  }
246  copy_v4_fl4(shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
247  }
248  else /* RGB */ {
249  if (IMB_alpha_affects_rgb(ibuf)) {
250  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
251  }
252  }
253  }
254  if (space_type == SPACE_NODE) {
255  SpaceNode *snode = (SpaceNode *)draw_ctx->space_data;
256  if ((snode->flag & SNODE_USE_ALPHA) != 0) {
257  /* Show RGBA */
259  }
260  else if ((snode->flag & SNODE_SHOW_ALPHA) != 0) {
261  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
262  copy_v4_fl4(shuffle, 0.0f, 0.0f, 0.0f, 1.0f);
263  }
264  else if ((snode->flag & SNODE_SHOW_R) != 0) {
265  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
266  if (IMB_alpha_affects_rgb(ibuf)) {
267  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
268  }
269  copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
270  }
271  else if ((snode->flag & SNODE_SHOW_G) != 0) {
272  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
273  if (IMB_alpha_affects_rgb(ibuf)) {
274  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
275  }
276  copy_v4_fl4(shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
277  }
278  else if ((snode->flag & SNODE_SHOW_B) != 0) {
279  draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
280  if (IMB_alpha_affects_rgb(ibuf)) {
281  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
282  }
283  copy_v4_fl4(shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
284  }
285  else /* RGB */ {
286  if (IMB_alpha_affects_rgb(ibuf)) {
287  draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
288  }
289  }
290  }
291 
292  GPUShader *shader = IMAGE_shader_image_get(is_tiled_texture);
294  if (is_tiled_texture) {
295  DRW_shgroup_uniform_texture_ex(shgrp, "imageTileArray", pd->texture, 0);
296  DRW_shgroup_uniform_texture(shgrp, "imageTileData", tex_tile_data);
297  }
298  else {
299  DRW_shgroup_uniform_texture_ex(shgrp, "imageTexture", pd->texture, 0);
300  }
301  DRW_shgroup_uniform_vec2_copy(shgrp, "farNearDistances", far_near);
302  DRW_shgroup_uniform_vec4_copy(shgrp, "color", color);
303  DRW_shgroup_uniform_vec4_copy(shgrp, "shuffle", shuffle);
304  DRW_shgroup_uniform_int_copy(shgrp, "drawFlags", draw_flags);
305  DRW_shgroup_uniform_bool_copy(shgrp, "imgPremultiplied", use_premul_alpha);
306  image_cache_image_add(shgrp, image, ibuf);
307  }
308 }
309 
310 /* -------------------------------------------------------------------- */
314 static void IMAGE_engine_init(void *ved)
315 {
317  IMAGE_Data *vedata = (IMAGE_Data *)ved;
318  IMAGE_StorageList *stl = vedata->stl;
319  if (!stl->pd) {
320  stl->pd = MEM_callocN(sizeof(IMAGE_PrivateData), __func__);
321  }
322  IMAGE_PrivateData *pd = stl->pd;
323 
324  pd->ibuf = NULL;
325  pd->lock = NULL;
326  pd->texture = NULL;
327 }
328 
329 static void IMAGE_cache_init(void *ved)
330 {
331  IMAGE_Data *vedata = (IMAGE_Data *)ved;
332  IMAGE_StorageList *stl = vedata->stl;
333  IMAGE_PrivateData *pd = stl->pd;
334  IMAGE_PassList *psl = vedata->psl;
335  const DRWContextState *draw_ctx = DRW_context_state_get();
336 
337  {
338  /* Write depth is needed for background overlay rendering. Near depth is used for
339  * transparency checker and Far depth is used for indicating the image size. */
342  psl->image_pass = DRW_pass_create("Image", state);
343  }
344 
345  const SpaceLink *space_link = draw_ctx->space_data;
346  const char space_type = space_link->spacetype;
347  pd->view = NULL;
348  if (space_type == SPACE_IMAGE) {
349  SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
350  Image *image = ED_space_image(sima);
351  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &pd->lock, 0);
352  image_cache_image(vedata, image, &sima->iuser, ibuf);
353  pd->image = image;
354  pd->ibuf = ibuf;
355  }
356  else if (space_type == SPACE_NODE) {
357  ARegion *region = draw_ctx->region;
358  Main *bmain = CTX_data_main(draw_ctx->evil_C);
359  Image *image = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
360  ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, &pd->lock);
361  {
362  /* Setup a screen pixel view. The backdrop of the node editor doesn't follow the region. */
363  float winmat[4][4], viewmat[4][4];
364  orthographic_m4(viewmat, 0.0, region->winx, 0.0, region->winy, 0.0, 1.0);
365  unit_m4(winmat);
366  pd->view = DRW_view_create(viewmat, winmat, NULL, NULL, NULL);
367  }
368  image_cache_image(vedata, image, NULL, ibuf);
369  pd->image = image;
370  pd->ibuf = ibuf;
371  }
372 }
373 
374 static void IMAGE_cache_populate(void *UNUSED(vedata), Object *UNUSED(ob))
375 {
376  /* Function intentional left empty. `cache_populate` is required to be implemented. */
377 }
378 
379 static void image_draw_finish(IMAGE_Data *ved)
380 {
381  IMAGE_Data *vedata = (IMAGE_Data *)ved;
382  IMAGE_StorageList *stl = vedata->stl;
383  IMAGE_PrivateData *pd = stl->pd;
384  const DRWContextState *draw_ctx = DRW_context_state_get();
385  const char space_type = draw_ctx->space_data->spacetype;
386  if (space_type == SPACE_IMAGE) {
387  SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
388  ED_space_image_release_buffer(sima, pd->ibuf, pd->lock);
389  }
390  else if (space_type == SPACE_NODE) {
391  BKE_image_release_ibuf(pd->image, pd->ibuf, pd->lock);
392  }
393  pd->image = NULL;
394  pd->ibuf = NULL;
395 
396  if (pd->texture && pd->owns_texture) {
398  pd->owns_texture = false;
399  }
400  pd->texture = NULL;
401 }
402 
403 static void IMAGE_draw_scene(void *ved)
404 {
405  IMAGE_Data *vedata = (IMAGE_Data *)ved;
406  IMAGE_PassList *psl = vedata->psl;
407  IMAGE_PrivateData *pd = vedata->stl->pd;
408 
411  static float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
412  GPU_framebuffer_clear_color_depth(dfbl->default_fb, clear_col, 1.0);
413 
417  image_draw_finish(vedata);
418 }
419 
420 static void IMAGE_engine_free(void)
421 {
423 }
424 
428 
430  NULL, /* next */
431  NULL, /* prev */
432  N_("UV/Image"), /* idname */
433  &IMAGE_data_size, /* vedata_size */
434  &IMAGE_engine_init, /* engine_init */
435  &IMAGE_engine_free, /* engine_free */
436  &IMAGE_cache_init, /* cache_init */
437  &IMAGE_cache_populate, /* cache_populate */
438  NULL, /* cache_finish */
439  &IMAGE_draw_scene, /* draw_scene */
440  NULL, /* view_update */
441  NULL, /* id_update */
442  NULL, /* render_to_image */
443  NULL, /* store_metadata */
444 };
typedef float(TangentPoint)[2]
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
void BKE_image_multiview_index(struct Image *ima, struct ImageUser *iuser)
Definition: image.c:3846
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
Definition: image.c:5113
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
Definition: image.c:5100
bool BKE_image_has_gpu_texture_premultiplied_alpha(struct Image *image, struct ImBuf *ibuf)
Definition: image_gpu.c:64
struct GPUTexture * BKE_image_get_gpu_tiles(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:444
struct RenderPass * BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser)
Definition: image.c:3813
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
Definition: image.c:3162
struct GPUTexture * BKE_image_get_gpu_texture(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:439
struct GPUTexture * BKE_image_get_gpu_tilemap(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:449
General operations, lookup, etc. for blender objects.
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void orthographic_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
Definition: math_geom.c:4802
void unit_m4(float m[4][4])
Definition: rct.c:1140
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define N_(msgid)
@ IMA_TYPE_COMPOSITE
@ IMA_SRC_TILED
@ OB_CAMERA
@ SI_DRAW_TILE
@ SI_SHOW_ZBUF
@ SI_SHOW_R
@ SI_USE_ALPHA
@ SI_SHOW_G
@ SI_SHOW_B
@ SI_SHOW_ALPHA
@ SNODE_USE_ALPHA
@ SNODE_SHOW_B
@ SNODE_SHOW_G
@ SNODE_SHOW_R
@ SNODE_SHOW_ALPHA
@ SPACE_NODE
@ SPACE_IMAGE
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_WRITE_DEPTH
Definition: DRW_render.h:314
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
@ DRW_STATE_DEPTH_ALWAYS
Definition: DRW_render.h:321
@ DRW_STATE_BLEND_ALPHA_PREMUL
Definition: DRW_render.h:342
#define DRW_shgroup_call_obmat(shgroup, geom, obmat)
Definition: DRW_render.h:424
#define DRW_VIEWPORT_DATA_SIZE(ty)
Definition: DRW_render.h:97
void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock)
Definition: image_edit.c:171
struct Image * ED_space_image(struct SpaceImage *sima)
Definition: image_edit.c:55
int ED_space_image_get_display_channel_mask(struct ImBuf *ibuf)
Definition: image_edit.c:179
struct ImBuf * ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile)
Definition: image_edit.c:139
GPUBatch
Definition: GPU_batch.h:93
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
struct GPUShader GPUShader
Definition: GPU_shader.h:33
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
@ GPU_R16F
Definition: GPU_texture.h:114
bool IMB_alpha_affects_rgb(const struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
ListBase tiles
short source
struct RenderResult * rr
Scene scene
GPUBatch * DRW_cache_quad_get(void)
Definition: draw_cache.c:392
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:697
const DRWContextState * DRW_context_state_get(void)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
DRWView * DRW_view_create(const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4], DRWCallVisibilityFn *visibility_fn)
void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, eGPUSamplerState sampler_state)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
DRWPass * DRW_pass_create(const char *name, DRWState state)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_view_set_active(DRWView *view)
void DRW_draw_pass(DRWPass *pass)
static void IMAGE_cache_init(void *ved)
Definition: image_engine.c:329
#define IMAGE_DRAW_FLAG_DO_REPEAT
Definition: image_engine.c:48
static void image_draw_finish(IMAGE_Data *ved)
Definition: image_engine.c:379
static void space_node_gpu_texture_get(Image *image, ImageUser *iuser, ImBuf *ibuf, GPUTexture **r_gpu_texture, bool *r_owns_texture, GPUTexture **r_tex_tile_data)
Definition: image_engine.c:147
static void IMAGE_draw_scene(void *ved)
Definition: image_engine.c:403
static void IMAGE_cache_populate(void *UNUSED(vedata), Object *UNUSED(ob))
Definition: image_engine.c:374
static const DrawEngineDataSize IMAGE_data_size
Definition: image_engine.c:427
static void IMAGE_engine_init(void *ved)
Definition: image_engine.c:314
#define IMAGE_DRAW_FLAG_SHOW_ALPHA
Definition: image_engine.c:44
static void space_image_gpu_texture_get(Image *image, ImageUser *iuser, ImBuf *ibuf, GPUTexture **r_gpu_texture, bool *r_owns_texture, GPUTexture **r_tex_tile_data)
Definition: image_engine.c:101
static void image_cache_image_add(DRWShadingGroup *grp, Image *image, ImBuf *ibuf)
Definition: image_engine.c:51
DrawEngineType draw_engine_image_type
Definition: image_engine.c:429
#define IMAGE_DRAW_FLAG_SHUFFLING
Definition: image_engine.c:46
static void IMAGE_engine_free(void)
Definition: image_engine.c:420
#define IMAGE_DRAW_FLAG_USE_WORLD_POS
Definition: image_engine.c:49
#define IMAGE_DRAW_FLAG_APPLY_ALPHA
Definition: image_engine.c:45
static void image_cache_image(IMAGE_Data *vedata, Image *image, ImageUser *iuser, ImBuf *ibuf)
Definition: image_engine.c:182
#define IMAGE_DRAW_FLAG_DEPTH
Definition: image_engine.c:47
static void image_gpu_texture_get(Image *image, ImageUser *iuser, ImBuf *ibuf, GPUTexture **r_gpu_texture, bool *r_owns_texture, GPUTexture **r_tex_tile_data)
Definition: image_engine.c:159
GPUShader * IMAGE_shader_image_get(bool is_tiled_image)
Definition: image_shader.c:59
void IMAGE_shader_library_ensure(void)
Definition: image_shader.c:48
void IMAGE_shader_free(void)
Definition: image_shader.c:74
static void shuffle(float2 points[], int size, int rng_seed)
Definition: jitter.cpp:243
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static ulong state[N]
struct Scene * scene
Definition: DRW_render.h:745
struct SpaceLink * space_data
Definition: DRW_render.h:743
const struct bContext * evil_C
Definition: DRW_render.h:763
struct ARegion * region
Definition: DRW_render.h:740
struct GPUFrameBuffer * default_fb
IMAGE_StorageList * stl
Definition: image_private.h:59
IMAGE_PassList * psl
Definition: image_private.h:58
DRWPass * image_pass
Definition: image_private.h:37
struct GPUTexture * texture
Definition: image_private.h:46
struct Image * image
Definition: image_private.h:43
struct ImBuf * ibuf
Definition: image_private.h:42
struct DRWView * view
Definition: image_private.h:44
IMAGE_PrivateData * pd
Definition: image_private.h:51
float * zbuf_float
int channels
float * rect_float
int * zbuf
Definition: BKE_main.h:116
void * data
struct Object * camera
struct ImageUser iuser