Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-10-17 13:01:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-17 13:01:12 +0400
commit856389eac7705b857ba50f0c3e3ee9d08639177e (patch)
treed322bff3c2425a7b58f2501b4a6152b6779241ae /source/blender/editors/interface/interface_icons.c
parent7d10ad012d9307cc9db0f91111a14376790f1536 (diff)
re-arrange icon_draw_rect, also use an assert() for odd icon sizes. this can happen in some cases but hard to find when.
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r--source/blender/editors/interface/interface_icons.c58
1 files changed, 22 insertions, 36 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 6d1a72fcd1a..39e062a13aa 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -28,6 +28,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#ifndef WIN32
#include <unistd.h>
@@ -845,6 +846,15 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miple
static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview)
{
+ ImBuf *ima= NULL;
+
+ /* sanity check */
+ if(w<=0 || h<=0 || w>2000 || h>2000) {
+ printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h);
+ assert(!"invalid icon size");
+ return;
+ }
+
/* modulate color */
if(alpha != 1.0f)
glPixelTransferf(GL_ALPHA_SCALE, alpha);
@@ -861,45 +871,21 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
}
/* draw */
- if((w<1 || h<1)) {
- // XXX - TODO 2.5 verify whether this case can happen
- if (G.f & G_DEBUG)
- printf("what the heck! - icons are %i x %i pixels?\n", w, h);
- }
- /* rect contains image in 'rendersize', we only scale if needed */
- else if(rw!=w && rh!=h) {
- if(w>2000 || h>2000) { /* something has gone wrong! */
- if (G.f & G_DEBUG)
- printf("insane icon size w=%d h=%d\n",w,h);
- }
- else {
- ImBuf *ima;
- /* first allocate imbuf for scaling and copy preview into it */
- ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
- memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));
-
- /* scale it */
- IMB_scaleImBuf(ima, w, h);
+ /* rect contains image in 'rendersize', we only scale if needed */
+ if(rw!=w && rh!=h) {
+ /* first allocate imbuf for scaling and copy preview into it */
+ ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
+ memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));
+ IMB_scaleImBuf(ima, w, h); /* scale it */
+ rect= ima->rect;
+ }
- if(is_preview) {
- glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, ima->rect);
- }
- else {
- glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, ima->rect);
- }
+ if(is_preview) glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ else glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- IMB_freeImBuf(ima);
- }
- }
- else {
- if(is_preview) {
- glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- }
- else {
- glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- }
- }
+ if(ima)
+ IMB_freeImBuf(ima);
/* restore color */
if(alpha != 0.0f)