Cleanup: Image: Rename redundant enum for clarity
This commit is contained in:
parent
487eaeed7e
commit
54237994d8
|
@ -3351,8 +3351,7 @@ static void image_free_tile(Image *ima, ImageTile *tile)
|
|||
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
||||
/* Only two textures depends on all tiles, so if this is a secondary tile we can keep the other
|
||||
* two. */
|
||||
if (tile != ima->tiles.first &&
|
||||
!(ELEM(i, TEXTARGET_TEXTURE_2D_ARRAY, TEXTARGET_TEXTURE_TILE_MAPPING))) {
|
||||
if (tile != ima->tiles.first && !(ELEM(i, TEXTARGET_2D_ARRAY, TEXTARGET_TILE_MAPPING))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3629,13 +3628,13 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la
|
|||
|
||||
for (int eye = 0; eye < 2; eye++) {
|
||||
/* Reallocate GPU tile array. */
|
||||
if (ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] != NULL) {
|
||||
GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye]);
|
||||
ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] = NULL;
|
||||
if (ima->gputexture[TEXTARGET_2D_ARRAY][eye] != NULL) {
|
||||
GPU_texture_free(ima->gputexture[TEXTARGET_2D_ARRAY][eye]);
|
||||
ima->gputexture[TEXTARGET_2D_ARRAY][eye] = NULL;
|
||||
}
|
||||
if (ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] != NULL) {
|
||||
GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye]);
|
||||
ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] = NULL;
|
||||
if (ima->gputexture[TEXTARGET_TILE_MAPPING][eye] != NULL) {
|
||||
GPU_texture_free(ima->gputexture[TEXTARGET_TILE_MAPPING][eye]);
|
||||
ima->gputexture[TEXTARGET_TILE_MAPPING][eye] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static struct GPUTexture *gpencil_image_texture_get(Image *image, bool *r_alpha_
|
|||
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
||||
|
||||
if (ibuf != NULL && ibuf->rect != NULL) {
|
||||
gpu_tex = GPU_texture_from_blender(image, &iuser, ibuf, TEXTARGET_TEXTURE_2D);
|
||||
gpu_tex = GPU_texture_from_blender(image, &iuser, ibuf, TEXTARGET_2D);
|
||||
*r_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL);
|
||||
}
|
||||
BKE_image_release_ibuf(image, ibuf, lock);
|
||||
|
|
|
@ -175,7 +175,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
|
|||
}
|
||||
width = ibuf->x;
|
||||
height = ibuf->y;
|
||||
tex = GPU_texture_from_blender(image, iuser, ibuf, TEXTARGET_TEXTURE_2D);
|
||||
tex = GPU_texture_from_blender(image, iuser, ibuf, TEXTARGET_2D);
|
||||
BKE_image_release_ibuf(image, ibuf, lock);
|
||||
iuser->scene = NULL;
|
||||
|
||||
|
@ -203,7 +203,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
|
|||
}
|
||||
|
||||
BKE_movieclip_user_set_frame(&bgpic->cuser, ctime);
|
||||
tex = GPU_texture_from_movieclip(clip, &bgpic->cuser, TEXTARGET_TEXTURE_2D);
|
||||
tex = GPU_texture_from_movieclip(clip, &bgpic->cuser, TEXTARGET_2D);
|
||||
if (tex == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
if (ima != NULL) {
|
||||
ImageUser iuser = *ob->iuser;
|
||||
camera_background_images_stereo_setup(draw_ctx->scene, draw_ctx->v3d, ima, &iuser);
|
||||
tex = GPU_texture_from_blender(ima, &iuser, NULL, TEXTARGET_TEXTURE_2D);
|
||||
tex = GPU_texture_from_blender(ima, &iuser, NULL, TEXTARGET_2D);
|
||||
if (tex) {
|
||||
size[0] = GPU_texture_orig_width(tex);
|
||||
size[1] = GPU_texture_orig_height(tex);
|
||||
|
|
|
@ -136,8 +136,7 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata)
|
|||
state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA;
|
||||
DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state);
|
||||
|
||||
GPUTexture *tex = GPU_texture_from_blender(
|
||||
imapaint->stencil, NULL, NULL, TEXTARGET_TEXTURE_2D);
|
||||
GPUTexture *tex = GPU_texture_from_blender(imapaint->stencil, NULL, NULL, TEXTARGET_2D);
|
||||
|
||||
const bool mask_premult = (imapaint->stencil->alpha_mode == IMA_ALPHA_PREMUL);
|
||||
const bool mask_inverted = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0;
|
||||
|
|
|
@ -261,11 +261,11 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
|
|||
|
||||
if (ima) {
|
||||
if (ima->source == IMA_SRC_TILED) {
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TEXTURE_2D_ARRAY);
|
||||
tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TEXTURE_TILE_MAPPING);
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_2D_ARRAY);
|
||||
tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TILE_MAPPING);
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TEXTURE_2D);
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_2D);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1189,10 +1189,10 @@ GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat tex_format, const GLuint
|
|||
static GLenum convert_target_to_gl(int target)
|
||||
{
|
||||
static const GLenum table[] = {
|
||||
[TEXTARGET_TEXTURE_2D] = GL_TEXTURE_2D,
|
||||
[TEXTARGET_TEXTURE_CUBE_MAP] = GL_TEXTURE_CUBE_MAP,
|
||||
[TEXTARGET_TEXTURE_2D_ARRAY] = GL_TEXTURE_2D_ARRAY,
|
||||
[TEXTARGET_TEXTURE_TILE_MAPPING] = GL_TEXTURE_1D_ARRAY,
|
||||
[TEXTARGET_2D] = GL_TEXTURE_2D,
|
||||
[TEXTARGET_CUBE_MAP] = GL_TEXTURE_CUBE_MAP,
|
||||
[TEXTARGET_2D_ARRAY] = GL_TEXTURE_2D_ARRAY,
|
||||
[TEXTARGET_TILE_MAPPING] = GL_TEXTURE_1D_ARRAY,
|
||||
};
|
||||
return table[target];
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ static GPUTexture **gpu_get_image_gputexture(Image *ima, int textarget, const in
|
|||
|
||||
static uint gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
|
||||
{
|
||||
GPUTexture *tilearray = ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][multiview_eye];
|
||||
GPUTexture *tilearray = ima->gputexture[TEXTARGET_2D_ARRAY][multiview_eye];
|
||||
|
||||
if (tilearray == NULL) {
|
||||
return 0;
|
||||
|
@ -559,10 +559,10 @@ static GPUTexture **gpu_get_movieclip_gputexture(MovieClip *clip,
|
|||
}
|
||||
|
||||
if (textarget == GL_TEXTURE_2D) {
|
||||
return &tex->gputexture[TEXTARGET_TEXTURE_2D];
|
||||
return &tex->gputexture[TEXTARGET_2D];
|
||||
}
|
||||
else if (textarget == GL_TEXTURE_CUBE_MAP) {
|
||||
return &tex->gputexture[TEXTARGET_TEXTURE_CUBE_MAP];
|
||||
return &tex->gputexture[TEXTARGET_CUBE_MAP];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -886,10 +886,10 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf,
|
|||
}
|
||||
}
|
||||
|
||||
if (textarget == TEXTARGET_TEXTURE_2D_ARRAY) {
|
||||
if (textarget == TEXTARGET_2D_ARRAY) {
|
||||
bindcode = gpu_texture_create_tile_array(ima, ibuf_intern);
|
||||
}
|
||||
else if (textarget == TEXTARGET_TEXTURE_TILE_MAPPING) {
|
||||
else if (textarget == TEXTARGET_TILE_MAPPING) {
|
||||
bindcode = gpu_texture_create_tile_mapping(ima, iuser ? iuser->multiview_eye : 0);
|
||||
}
|
||||
else {
|
||||
|
@ -905,7 +905,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf,
|
|||
|
||||
GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
|
||||
|
||||
if (textarget == TEXTARGET_TEXTURE_TILE_MAPPING) {
|
||||
if (textarget == TEXTARGET_TILE_MAPPING) {
|
||||
/* Special for tile mapping. */
|
||||
GPU_texture_mipmap_mode(*tex, false, false);
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
|
|||
if (ima->gpuflag & IMA_GPU_MIPMAP_COMPLETE) {
|
||||
for (int eye = 0; eye < 2; eye++) {
|
||||
for (int a = 0; a < TEXTARGET_COUNT; a++) {
|
||||
if (ELEM(a, TEXTARGET_TEXTURE_2D, TEXTARGET_TEXTURE_2D_ARRAY)) {
|
||||
if (ELEM(a, TEXTARGET_2D, TEXTARGET_2D_ARRAY)) {
|
||||
GPUTexture *tex = ima->gputexture[a][eye];
|
||||
if (tex != NULL) {
|
||||
GPU_texture_bind(tex, 0);
|
||||
|
@ -1291,7 +1291,7 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
|
|||
if (BKE_image_has_opengl_texture(ima)) {
|
||||
for (int eye = 0; eye < 2; eye++) {
|
||||
for (int a = 0; a < TEXTARGET_COUNT; a++) {
|
||||
if (ELEM(a, TEXTARGET_TEXTURE_2D, TEXTARGET_TEXTURE_2D_ARRAY)) {
|
||||
if (ELEM(a, TEXTARGET_2D, TEXTARGET_2D_ARRAY)) {
|
||||
GPUTexture *tex = ima->gputexture[a][eye];
|
||||
if (tex != NULL) {
|
||||
GPU_texture_bind(tex, 0);
|
||||
|
@ -1322,14 +1322,14 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
|
|||
GPU_free_image(ima);
|
||||
}
|
||||
|
||||
GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D][0];
|
||||
GPUTexture *tex = ima->gputexture[TEXTARGET_2D][0];
|
||||
/* Check if we need to update the main gputexture. */
|
||||
if (tex != NULL && tile == ima->tiles.first) {
|
||||
gpu_texture_update_from_ibuf(tex, ima, ibuf, NULL, x, y, w, h);
|
||||
}
|
||||
|
||||
/* Check if we need to update the array gputexture. */
|
||||
tex = ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][0];
|
||||
tex = ima->gputexture[TEXTARGET_2D_ARRAY][0];
|
||||
if (tex != NULL) {
|
||||
gpu_texture_update_from_ibuf(tex, ima, ibuf, tile, x, y, w, h);
|
||||
}
|
||||
|
|
|
@ -118,10 +118,10 @@ typedef struct ImageTile {
|
|||
#define IMA_SHOW_STEREO (1 << 4)
|
||||
|
||||
enum {
|
||||
TEXTARGET_TEXTURE_2D = 0,
|
||||
TEXTARGET_TEXTURE_CUBE_MAP,
|
||||
TEXTARGET_TEXTURE_2D_ARRAY,
|
||||
TEXTARGET_TEXTURE_TILE_MAPPING,
|
||||
TEXTARGET_2D = 0,
|
||||
TEXTARGET_CUBE_MAP,
|
||||
TEXTARGET_2D_ARRAY,
|
||||
TEXTARGET_TILE_MAPPING,
|
||||
TEXTARGET_COUNT,
|
||||
};
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
|
|||
static int rna_Image_bindcode_get(PointerRNA *ptr)
|
||||
{
|
||||
Image *ima = (Image *)ptr->data;
|
||||
GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D][0];
|
||||
GPUTexture *tex = ima->gputexture[TEXTARGET_2D][0];
|
||||
return (tex) ? GPU_texture_opengl_bindcode(tex) : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame)
|
|||
BKE_imageuser_default(&iuser);
|
||||
iuser.framenr = frame;
|
||||
|
||||
GPUTexture *tex = GPU_texture_from_blender(image, &iuser, NULL, TEXTARGET_TEXTURE_2D);
|
||||
GPUTexture *tex = GPU_texture_from_blender(image, &iuser, NULL, TEXTARGET_2D);
|
||||
|
||||
if (tex == NULL) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Failed to load image texture '%s'", image->id.name + 2);
|
||||
|
@ -239,7 +239,7 @@ static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame)
|
|||
|
||||
BKE_image_tag_time(image);
|
||||
|
||||
if (image->gputexture[TEXTARGET_TEXTURE_2D] == NULL) {
|
||||
if (image->gputexture[TEXTARGET_2D] == NULL) {
|
||||
error = rna_Image_gl_load(image, reports, frame);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue