From ed0c9654ddfdcbe19d8094d4b4a43f0f06d9ee5c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 20 Apr 2019 12:56:29 +0200 Subject: Cleanup: remove unused OpenGL functions, rename some for clarity --- source/blender/editors/include/BIF_glutil.h | 104 +++++++---------- source/blender/editors/screen/glutil.c | 146 +++++++++--------------- source/blender/editors/space_clip/clip_draw.c | 2 +- source/blender/editors/space_image/image_draw.c | 2 +- source/blender/editors/space_node/drawnode.c | 4 +- source/blender/imbuf/intern/colormanagement.c | 2 +- 6 files changed, 103 insertions(+), 157 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index a2e8d6afd4b..c30674907da 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -32,35 +32,6 @@ struct ColorManagedViewSettings; struct ImBuf; struct bContext; -/* A few functions defined here are being DEPRECATED for Blender 2.8 - * - * Do not use them in new code, and you are encouraged to - * convert existing code to draw without these. - * - * These will be deleted before we ship 2.8! - * - merwin - */ - -/** - * Returns a float value as obtained by glGetFloatv. - * The param must cause only one value to be gotten from GL. - */ -float glaGetOneFloat(int param); -int glaGetOneInt(int param); - -/** - * Functions like glRasterPos2i, except ensures that the resulting - * raster position is valid. \a known_good_x and \a known_good_y - * should be coordinates of a point known to be within the current - * view frustum. - * \attention This routine should be used when the distance of \a x - * and \a y away from the known good point is small (ie. for small icons - * and for bitmap characters), when drawing large+zoomed images it is - * possible for overflow to occur, the glaDrawPixelsSafe routine should - * be used instead. - */ -void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y); - typedef struct IMMDrawPixelsTexState { struct GPUShader *shader; unsigned int pos; @@ -148,29 +119,47 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, float yzoom, float color[4]); -void set_inverted_drawing(int enable); - -/* own working polygon offset */ -float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist); -void bglPolygonOffset(float viewdist, float dist); - -/* **** Color management helper functions for GLSL display/transform ***** */ - -/* Draw imbuf on a screen, preferably using GLSL display transform */ -void glaDrawImBuf_glsl(struct ImBuf *ibuf, +/* Image buffer drawing functions, with display transform + * + * The view and display settings can either be specified manually, or retrived + * from the context with the _ctx variations. + * + * For better performance clipping coordinates can be specified so parts of the + * image outside the view are skipped. */ + +void ED_draw_imbuf(struct ImBuf *ibuf, + float x, + float y, + int zoomfilter, + struct ColorManagedViewSettings *view_settings, + struct ColorManagedDisplaySettings *display_settings, + float zoom_x, + float zoom_y); +void ED_draw_imbuf_clipping(struct ImBuf *ibuf, + float x, + float y, + int zoomfilter, + struct ColorManagedViewSettings *view_settings, + struct ColorManagedDisplaySettings *display_settings, + float clip_min_x, + float clip_min_y, + float clip_max_x, + float clip_max_y, + float zoom_x, + float zoom_y); + +void ED_draw_imbuf_ctx(const struct bContext *C, + struct ImBuf *ibuf, float x, float y, int zoomfilter, - struct ColorManagedViewSettings *view_settings, - struct ColorManagedDisplaySettings *display_settings, float zoom_x, float zoom_y); -void glaDrawImBuf_glsl_clipping(struct ImBuf *ibuf, +void ED_draw_imbuf_ctx_clipping(const struct bContext *C, + struct ImBuf *ibuf, float x, float y, int zoomfilter, - struct ColorManagedViewSettings *view_settings, - struct ColorManagedDisplaySettings *display_settings, float clip_min_x, float clip_min_y, float clip_max_x, @@ -178,25 +167,14 @@ void glaDrawImBuf_glsl_clipping(struct ImBuf *ibuf, float zoom_x, float zoom_y); -/* Draw imbuf on a screen, preferably using GLSL display transform */ -void glaDrawImBuf_glsl_ctx(const struct bContext *C, - struct ImBuf *ibuf, - float x, - float y, - int zoomfilter, - float zoom_x, - float zoom_y); -void glaDrawImBuf_glsl_ctx_clipping(const struct bContext *C, - struct ImBuf *ibuf, - float x, - float y, - int zoomfilter, - float clip_min_x, - float clip_min_y, - float clip_max_x, - float clip_max_y, - float zoom_x, - float zoom_y); +/* OpenGL drawing utility functions. Do not use these in new code, these + * are intended to be moved or removed in the future. */ + +void set_inverted_drawing(int enable); + +/* own working polygon offset */ +float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist); +void bglPolygonOffset(float viewdist, float dist); void immDrawBorderCorners(unsigned int pos, const struct rcti *border, float zoomx, float zoomy); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 7fec62157c1..868bc982c51 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -58,37 +58,6 @@ void set_inverted_drawing(int enable) GL_TOGGLE(GL_DITHER, !enable); } -float glaGetOneFloat(int param) -{ - GLfloat v; - glGetFloatv(param, &v); - return v; -} - -int glaGetOneInt(int param) -{ - GLint v; - glGetIntegerv(param, &v); - return v; -} - -void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y) -{ - GLubyte dummy = 0; - - /* As long as known good coordinates are correct - * this is guaranteed to generate an ok raster - * position (ignoring potential (real) overflow - * issues). - */ - glRasterPos2f(known_good_x, known_good_y); - - /* Now shift the raster position to where we wanted - * it in the first place using the glBitmap trick. - */ - glBitmap(0, 0, 0, 0, x - known_good_x, y - known_good_y, &dummy); -} - static int get_cached_work_texture(int *r_w, int *r_h) { static GLint texid = -1; @@ -564,18 +533,18 @@ void bglPolygonOffset(float viewdist, float dist) /* **** Color management helper functions for GLSL display/transform ***** */ /* Draw given image buffer on a screen using GLSL for display transform */ -void glaDrawImBuf_glsl_clipping(ImBuf *ibuf, - float x, - float y, - int zoomfilter, - ColorManagedViewSettings *view_settings, - ColorManagedDisplaySettings *display_settings, - float clip_min_x, - float clip_min_y, - float clip_max_x, - float clip_max_y, - float zoom_x, - float zoom_y) +void ED_draw_imbuf_clipping(ImBuf *ibuf, + float x, + float y, + int zoomfilter, + ColorManagedViewSettings *view_settings, + ColorManagedDisplaySettings *display_settings, + float clip_min_x, + float clip_min_y, + float clip_max_x, + float clip_max_y, + float zoom_x, + float zoom_y) { bool force_fallback = false; bool need_fallback = true; @@ -702,65 +671,64 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf, } } -void glaDrawImBuf_glsl(ImBuf *ibuf, - float x, - float y, - int zoomfilter, - ColorManagedViewSettings *view_settings, - ColorManagedDisplaySettings *display_settings, - float zoom_x, - float zoom_y) +void ED_draw_imbuf(ImBuf *ibuf, + float x, + float y, + int zoomfilter, + ColorManagedViewSettings *view_settings, + ColorManagedDisplaySettings *display_settings, + float zoom_x, + float zoom_y) { - glaDrawImBuf_glsl_clipping(ibuf, - x, - y, - zoomfilter, - view_settings, - display_settings, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - zoom_x, - zoom_y); + ED_draw_imbuf_clipping(ibuf, + x, + y, + zoomfilter, + view_settings, + display_settings, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + zoom_x, + zoom_y); } -void glaDrawImBuf_glsl_ctx_clipping(const bContext *C, - ImBuf *ibuf, - float x, - float y, - int zoomfilter, - float clip_min_x, - float clip_min_y, - float clip_max_x, - float clip_max_y, - float zoom_x, - float zoom_y) +void ED_draw_imbuf_ctx_clipping(const bContext *C, + ImBuf *ibuf, + float x, + float y, + int zoomfilter, + float clip_min_x, + float clip_min_y, + float clip_max_x, + float clip_max_y, + float zoom_x, + float zoom_y) { ColorManagedViewSettings *view_settings; ColorManagedDisplaySettings *display_settings; IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); - glaDrawImBuf_glsl_clipping(ibuf, - x, - y, - zoomfilter, - view_settings, - display_settings, - clip_min_x, - clip_min_y, - clip_max_x, - clip_max_y, - zoom_x, - zoom_y); + ED_draw_imbuf_clipping(ibuf, + x, + y, + zoomfilter, + view_settings, + display_settings, + clip_min_x, + clip_min_y, + clip_max_x, + clip_max_y, + zoom_x, + zoom_y); } -void glaDrawImBuf_glsl_ctx( +void ED_draw_imbuf_ctx( const bContext *C, ImBuf *ibuf, float x, float y, int zoomfilter, float zoom_x, float zoom_y) { - glaDrawImBuf_glsl_ctx_clipping( - C, ibuf, x, y, zoomfilter, 0.0f, 0.0f, 0.0f, 0.0f, zoom_x, zoom_y); + ED_draw_imbuf_ctx_clipping(C, ibuf, x, y, zoomfilter, 0.0f, 0.0f, 0.0f, 0.0f, zoom_x, zoom_y); } /* don't move to GPU_immediate_util.h because this uses user-prefs diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index a3aa4f4bed5..dbc37fc6727 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -341,7 +341,7 @@ static void draw_movieclip_buffer(const bContext *C, filter = GL_NEAREST; } - glaDrawImBuf_glsl_ctx(C, ibuf, x, y, filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y); + ED_draw_imbuf_ctx(C, ibuf, x, y, filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y); if (ibuf->planes == 32) { GPU_blend(false); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index a87808e1601..3baee1d723b 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -575,7 +575,7 @@ static void draw_image_buffer(const bContext *C, /* If RGBA display with color management */ if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) == 0) { - glaDrawImBuf_glsl_ctx_clipping( + ED_draw_imbuf_ctx_clipping( C, ibuf, x, y, GL_NEAREST, 0, 0, clip_max_x, clip_max_y, zoomx, zoomy); } else { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 327aa94ca3e..eb9c1cc2965 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3481,12 +3481,12 @@ void draw_nodespace_back_pix(const bContext *C, GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); + ED_draw_imbuf_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); GPU_blend(false); } else { - glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); + ED_draw_imbuf_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); } if (cache_handle) { diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index ac35cc10920..1370ea40137 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -3789,7 +3789,7 @@ bool IMB_colormanagement_support_glsl_draw(const ColorManagedViewSettings *UNUSE * When there's no need to apply transform on 2D textures, use * IMB_colormanagement_finish_glsl_draw(). * - * This is low-level function, use glaDrawImBuf_glsl_ctx if you + * This is low-level function, use ED_draw_imbuf_ctx if you * only need to display given image buffer */ bool IMB_colormanagement_setup_glsl_draw_from_space( -- cgit v1.2.3