From 0a4b030145fdad2b36290454bbd3ba37406d4f9a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 17 Mar 2013 14:38:58 +0000 Subject: New feature: Automatic switching for drawing pixel buffers via glDrawPixels or using GPU textures It works with a User Preference limit, in megapixels, to define whether to use GPU or direct pixel drawing. Default is now initialized to 10 MP (4k buffers). Especially for zooming out (draw smaller) texture drawing is much smaller. Also Nvidia cards typically draw much faster with textures in general. Added to node backdrop first now, the other editors follow in a next commit. For coders: added new DNA function to initialize new struct variables, so you don't have to sub-version files anymore. DNA_struct_elem_find(fd->filesdna, "structname", "typename", "varname") "filesdna" is the sdna description of the current file being versioned. --- source/blender/editors/screen/glutil.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/editors/screen') diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index f6e9b5e4f8a..6e7972200c7 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -669,6 +669,22 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo } } +/* uses either DrawPixelsSafe or DrawPixelsTex, based on user defined maximum */ +void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, void *rect) +{ + if (U.image_gpubuffer_limit) { + /* Megapixels, use float math to prevent overflow */ + float img_size = ((float)img_w * (float)img_h) / (1024.0f * 1024.0f); + + if (U.image_gpubuffer_limit > (int)img_size) { + glColor4f(1.0, 1.0, 1.0, 1.0); + glaDrawPixelsTex(x, y, img_w, img_h, format, rect); + return; + } + } + glaDrawPixelsSafe(x, y, img_w, img_h, img_w, GL_RGBA, format, rect); +} + /* 2D Drawing Assistance */ void glaDefine2DArea(rcti *screen_rect) -- cgit v1.2.3