Cleanup: rename tpageflag to gpuflag, make it purely runtime data.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 18 Feb 2019 13:45:22 +0000 (14:45 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 18 Feb 2019 15:38:17 +0000 (16:38 +0100)
source/blender/blenkernel/intern/image.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_280.c
source/blender/editors/space_image/image_buttons.c
source/blender/gpu/intern/gpu_draw.c
source/blender/makesdna/DNA_image_types.h

index c8d879f..0d5bfc5 100644 (file)
@@ -3188,7 +3188,7 @@ static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, cons
 
        /* XXX temp stuff? */
        if (ima->lastframe != frame)
-               ima->tpageflag |= IMA_TPAGE_REFRESH;
+               ima->gpuflag |= IMA_GPU_REFRESH;
 
        ima->lastframe = frame;
 
@@ -3912,7 +3912,7 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame,
                ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
                /* XXX temp stuff? */
                if (ima->lastframe != frame)
-                       ima->tpageflag |= IMA_TPAGE_REFRESH;
+                       ima->gpuflag |= IMA_GPU_REFRESH;
                ima->lastframe = frame;
        }
        else if (ima->source == IMA_SRC_SEQUENCE) {
@@ -3922,7 +3922,7 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame,
 
                        /* XXX temp stuff? */
                        if (ima->lastframe != frame) {
-                               ima->tpageflag |= IMA_TPAGE_REFRESH;
+                               ima->gpuflag |= IMA_GPU_REFRESH;
                        }
                        ima->lastframe = frame;
 
@@ -4317,11 +4317,6 @@ void BKE_image_user_frame_calc(ImageUser *iuser, int cfra)
                        iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
                }
 
-               /* allows image users to handle redraws */
-               if (iuser->flag & IMA_ANIM_ALWAYS)
-                       if (framenr != iuser->framenr)
-                               iuser->flag |= IMA_ANIM_REFRESHED;
-
                iuser->framenr = framenr;
                if (iuser->ok == 0) iuser->ok = 1;
        }
index 8fcae12..8259a5e 100644 (file)
@@ -1678,7 +1678,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
        for (; ima; ima = ima->id.next) {
                ima->cache = newimaadr(fd, ima->cache);
                if (ima->cache == NULL) {
-                       ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
+                       ima->gpuflag = 0;
                        for (i = 0; i < TEXTARGET_COUNT; i++) {
                                ima->gputexture[i] = NULL;
                        }
@@ -3945,7 +3945,7 @@ static void direct_link_image(FileData *fd, Image *ima)
 
        /* if not restored, we keep the binded opengl index */
        if (!ima->cache) {
-               ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
+               ima->gpuflag = 0;
                for (int i = 0; i < TEXTARGET_COUNT; i++) {
                        ima->gputexture[i] = NULL;
                }
index cfba6f8..9cb63e7 100644 (file)
@@ -2645,12 +2645,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
                                IMA_FLAG_DEPRECATED_8 |
                                IMA_FLAG_DEPRECATED_15 |
                                IMA_FLAG_DEPRECATED_16);
-                       image->tpageflag &= ~(
-                               IMA_TPAGEFLAG_DEPRECATED_0 |
-                               IMA_TPAGEFLAG_DEPRECATED_1 |
-                               IMA_TPAGEFLAG_DEPRECATED_2 |
-                               IMA_TPAGEFLAG_DEPRECATED_4 |
-                               IMA_TPAGEFLAG_DEPRECATED_5);
                }
 
                for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
index d43ad5c..f2185c2 100644 (file)
@@ -932,17 +932,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
                                uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
                        }
 
-                       // XXX what was this for?
-#if 0
-                       /* check for re-render, only buttons */
-                       if (imagechanged == B_IMAGECHANGED) {
-                               if (iuser->flag & IMA_ANIM_REFRESHED) {
-                                       iuser->flag &= ~IMA_ANIM_REFRESHED;
-                                       WM_event_add_notifier(C, NC_IMAGE, ima);
-                               }
-                       }
-#endif
-
                        /* multilayer? */
                        if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
                                const float dpi_fac = UI_DPI_FAC;
index 93882ce..a3a220a 100644 (file)
@@ -284,9 +284,9 @@ GPUTexture *GPU_texture_from_blender(
        }
 
        /* currently, tpage refresh is used by ima sequences */
-       if (ima->tpageflag & IMA_TPAGE_REFRESH) {
+       if (ima->gpuflag & IMA_GPU_REFRESH) {
                GPU_free_image(ima);
-               ima->tpageflag &= ~IMA_TPAGE_REFRESH;
+               ima->gpuflag &= ~IMA_GPU_REFRESH;
        }
 
        /* check if we have a valid image buffer */
@@ -339,9 +339,9 @@ GPUTexture *GPU_texture_from_blender(
        /* mark as non-color data texture */
        if (bindcode) {
                if (is_data)
-                       ima->tpageflag |= IMA_GLBIND_IS_DATA;
+                       ima->gpuflag |= IMA_GPU_IS_DATA;
                else
-                       ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
+                       ima->gpuflag &= ~IMA_GPU_IS_DATA;
        }
 
        /* clean up */
@@ -446,7 +446,7 @@ void GPU_create_gl_tex(
                        glGenerateMipmap(GL_TEXTURE_2D);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
                        if (ima)
-                               ima->tpageflag |= IMA_MIPMAP_COMPLETE;
+                               ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
                }
                else {
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -471,7 +471,7 @@ void GPU_create_gl_tex(
                                glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
 
                                if (ima)
-                                       ima->tpageflag |= IMA_MIPMAP_COMPLETE;
+                                       ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
                        }
                        else {
                                glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -598,7 +598,7 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
        if (mipmap) {
                for (Image *ima = bmain->image.first; ima; ima = ima->id.next) {
                        if (BKE_image_has_opengl_texture(ima)) {
-                               if (ima->tpageflag & IMA_MIPMAP_COMPLETE) {
+                               if (ima->gpuflag & IMA_GPU_MIPMAP_COMPLETE) {
                                        if (ima->gputexture[TEXTARGET_TEXTURE_2D]) {
                                                GPU_texture_bind(ima->gputexture[TEXTARGET_TEXTURE_2D], 0);
                                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
@@ -610,7 +610,7 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
                                        GPU_free_image(ima);
                        }
                        else
-                               ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+                               ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
                }
 
        }
@@ -625,7 +625,7 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
                                }
                        }
                        else
-                               ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+                               ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
                }
        }
 }
@@ -693,7 +693,7 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x,
                        glGenerateMipmap(GL_TEXTURE_2D);
                }
                else {
-                       ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+                       ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
                }
 
                GPU_texture_unbind(ima->gputexture[TEXTARGET_TEXTURE_2D]);
@@ -723,7 +723,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
                /* if color correction is needed, we must update the part that needs updating. */
                if (ibuf->rect_float) {
                        float *buffer = MEM_mallocN(w * h * sizeof(float) * 4, "temp_texpaint_float_buf");
-                       bool is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA) != 0;
+                       bool is_data = (ima->gpuflag & IMA_GPU_IS_DATA) != 0;
                        IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data);
 
                        if (gpu_check_scaled_image(ibuf, ima, buffer, x, y, w, h)) {
@@ -741,7 +741,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
                                glGenerateMipmap(GL_TEXTURE_2D);
                        }
                        else {
-                               ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+                               ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
                        }
 
                        GPU_texture_unbind(ima->gputexture[TEXTARGET_TEXTURE_2D]);
@@ -778,7 +778,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
                        glGenerateMipmap(GL_TEXTURE_2D);
                }
                else {
-                       ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+                       ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
                }
 
                GPU_texture_unbind(ima->gputexture[TEXTARGET_TEXTURE_2D]);
@@ -1143,7 +1143,7 @@ void GPU_free_image(Image *ima)
                }
        }
 
-       ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA);
+       ima->gpuflag &= ~(IMA_GPU_MIPMAP_COMPLETE | IMA_GPU_IS_DATA);
 }
 
 void GPU_free_images(Main *bmain)
index 4a527d9..b6ae324 100644 (file)
@@ -90,8 +90,8 @@ typedef struct RenderSlot {
 
 /* iuser->flag */
 #define IMA_ANIM_ALWAYS         (1 << 0)
-#define IMA_ANIM_REFRESHED      (1 << 1)
-/* #define IMA_DO_PREMUL        (1 << 2) */
+/* #define IMA_DEPRECATED_1     (1 << 1) */
+/* #define IMA_DEPRECATED_2     (1 << 2) */
 #define IMA_NEED_FRAME_RECALC   (1 << 3)
 #define IMA_SHOW_STEREO         (1 << 4)
 
@@ -123,8 +123,8 @@ typedef struct Image {
        short source, type;
        int lastframe;
 
-       /* texture page */
-       short tpageflag;
+       /* GPU texture flag. */
+       short gpuflag;
        short pad2;
        unsigned int pad3;
 
@@ -187,18 +187,14 @@ enum {
        IMA_FLAG_DEPRECATED_16  = (1 << 16),  /* cleared */
 };
 
-/* Image.tpageflag */
+/* Image.gpuflag */
 enum {
-       IMA_TPAGEFLAG_DEPRECATED_0 =      (1 << 0),  /* cleared */
-       IMA_TPAGEFLAG_DEPRECATED_1 =      (1 << 1),  /* cleared */
-       IMA_TPAGEFLAG_DEPRECATED_2 =      (1 << 2),  /* cleared */
+       /** GPU texture needs to be refreshed. */
+       IMA_GPU_REFRESH =                 (1 << 0),
        /** All mipmap levels in OpenGL texture set? */
-       IMA_MIPMAP_COMPLETE =             (1 << 3),
-       IMA_TPAGEFLAG_DEPRECATED_4 =      (1 << 4),  /* cleared */
-       IMA_TPAGEFLAG_DEPRECATED_5 =      (1 << 5),  /* cleared */
-       IMA_TPAGE_REFRESH =               (1 << 6),
+       IMA_GPU_MIPMAP_COMPLETE =         (1 << 1),
        /** OpenGL image texture bound as non-color data. */
-       IMA_GLBIND_IS_DATA =              (1 << 7),
+       IMA_GPU_IS_DATA =                 (1 << 2),
 };
 
 /* ima->type and ima->source moved to BKE_image.h, for API */