2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-11-25 18:27:41 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-25 18:27:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2008-12-16 13:19:02 +00:00
|
|
|
* Contributors: Blender Foundation, full recode
|
2008-11-25 18:27:41 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/interface/interface_icons.c
|
|
|
|
* \ingroup edinterface
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifndef WIN32
|
2012-04-15 07:54:07 +00:00
|
|
|
# include <unistd.h>
|
2008-11-25 18:27:41 +00:00
|
|
|
#else
|
2012-04-15 07:54:07 +00:00
|
|
|
# include <io.h>
|
|
|
|
# include <direct.h>
|
|
|
|
# include "BLI_winstuff.h"
|
|
|
|
#endif
|
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-10-19 14:03:02 +00:00
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2010-07-26 04:00:09 +00:00
|
|
|
#include "DNA_brush_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2011-01-16 18:33:08 +00:00
|
|
|
#include "DNA_space_types.h"
|
2010-07-26 04:00:09 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_enum_types.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2009-09-28 18:33:45 +00:00
|
|
|
#include "BKE_context.h"
|
2010-01-22 06:48:29 +00:00
|
|
|
#include "BKE_global.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
#include "BKE_icons.h"
|
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
2010-09-30 18:35:54 +00:00
|
|
|
#include "BIF_glutil.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2009-06-25 15:41:27 +00:00
|
|
|
#include "ED_datafiles.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "ED_render.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2009-06-25 15:41:27 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_interface_icons.h"
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
#include "interface_intern.h"
|
2009-06-25 15:41:27 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define ICON_IMAGE_W 600
|
|
|
|
#define ICON_IMAGE_H 640
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define ICON_GRID_COLS 26
|
|
|
|
#define ICON_GRID_ROWS 30
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define ICON_GRID_MARGIN 5
|
|
|
|
#define ICON_GRID_W 16
|
|
|
|
#define ICON_GRID_H 16
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
typedef struct IconImage {
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
unsigned int *rect;
|
|
|
|
} IconImage;
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define ICON_TYPE_PREVIEW 0
|
|
|
|
#define ICON_TYPE_TEXTURE 1
|
|
|
|
#define ICON_TYPE_BUFFER 2
|
|
|
|
#define ICON_TYPE_VECTOR 3
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
typedef struct DrawInfo {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
int type;
|
|
|
|
|
|
|
|
union {
|
|
|
|
/* type specific data */
|
|
|
|
struct {
|
|
|
|
VectorDrawFunc func;
|
|
|
|
} vector;
|
|
|
|
struct {
|
2012-03-30 01:51:25 +00:00
|
|
|
IconImage *image;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
} buffer;
|
|
|
|
struct {
|
|
|
|
int x, y, w, h;
|
|
|
|
} texture;
|
|
|
|
} data;
|
|
|
|
} DrawInfo;
|
|
|
|
|
|
|
|
typedef struct IconTexture {
|
|
|
|
GLuint id;
|
2008-11-25 18:27:41 +00:00
|
|
|
int w;
|
|
|
|
int h;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
float invw;
|
|
|
|
float invh;
|
|
|
|
} IconTexture;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
/* ******************* STATIC LOCAL VARS ******************* */
|
|
|
|
/* static here to cache results of icon directory scan, so it's not
|
|
|
|
* scanning the filesystem each time the menu is drawn */
|
2011-04-03 10:04:16 +00:00
|
|
|
static struct ListBase iconfilelist = {NULL, NULL};
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
static IconTexture icongltex = {0, 0, 0, 0.0f, 0.0f};
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
/* **************************************************** */
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
Icon *new_icon = NULL;
|
|
|
|
IconImage *iimg = NULL;
|
|
|
|
DrawInfo *di;
|
|
|
|
int y = 0;
|
2009-01-06 14:42:54 +00:00
|
|
|
int imgsize = 0;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
new_icon = MEM_callocN(sizeof(Icon), "texicon");
|
|
|
|
|
2011-04-03 10:04:16 +00:00
|
|
|
new_icon->obj = NULL; /* icon is not for library object */
|
2008-11-25 18:27:41 +00:00
|
|
|
new_icon->type = 0;
|
|
|
|
|
|
|
|
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
|
2012-03-30 01:51:25 +00:00
|
|
|
di->type = type;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type == ICON_TYPE_TEXTURE) {
|
2012-03-30 01:51:25 +00:00
|
|
|
di->data.texture.x = xofs;
|
|
|
|
di->data.texture.y = yofs;
|
|
|
|
di->data.texture.w = size;
|
|
|
|
di->data.texture.h = size;
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == ICON_TYPE_BUFFER) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
iimg = MEM_mallocN(sizeof(IconImage), "icon_img");
|
2012-03-30 01:51:25 +00:00
|
|
|
iimg->rect = MEM_mallocN(size * size * sizeof(unsigned int), "icon_rect");
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
iimg->w = size;
|
|
|
|
iimg->h = size;
|
|
|
|
|
|
|
|
/* Here we store the rect in the icon - same as before */
|
|
|
|
imgsize = bbuf->x;
|
2012-03-30 01:51:25 +00:00
|
|
|
for (y = 0; y < size; y++) {
|
|
|
|
memcpy(&iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
di->data.buffer.image = iimg;
|
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
new_icon->drawinfo_free = UI_icons_free_drawinfo;
|
2008-11-25 18:27:41 +00:00
|
|
|
new_icon->drawinfo = di;
|
|
|
|
|
|
|
|
BKE_icon_set(icon_id, new_icon);
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
Icon *new_icon = NULL;
|
2012-03-30 01:51:25 +00:00
|
|
|
DrawInfo *di;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
new_icon = MEM_callocN(sizeof(Icon), "texicon");
|
|
|
|
|
2011-04-03 10:04:16 +00:00
|
|
|
new_icon->obj = NULL; /* icon is not for library object */
|
2008-11-25 18:27:41 +00:00
|
|
|
new_icon->type = 0;
|
|
|
|
|
|
|
|
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
|
2012-03-30 01:51:25 +00:00
|
|
|
di->type = ICON_TYPE_VECTOR;
|
2012-02-23 02:23:42 +00:00
|
|
|
di->data.vector.func = drawFunc;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2011-04-03 10:04:16 +00:00
|
|
|
new_icon->drawinfo_free = NULL;
|
2008-11-25 18:27:41 +00:00
|
|
|
new_icon->drawinfo = di;
|
|
|
|
|
|
|
|
BKE_icon_set(icon_id, new_icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vector Icon Drawing Routines */
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
/* Utilities */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
static void viconutil_set_point(GLint pt[2], int x, int y)
|
|
|
|
{
|
|
|
|
pt[0] = x;
|
|
|
|
pt[1] = y;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static void viconutil_draw_tri(GLint(*pts)[2])
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
glVertex2iv(pts[0]);
|
|
|
|
glVertex2iv(pts[1]);
|
|
|
|
glVertex2iv(pts[2]);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static void viconutil_draw_lineloop(GLint(*pts)[2], int numPoints)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
glBegin(GL_LINE_LOOP);
|
2012-03-30 01:51:25 +00:00
|
|
|
for (i = 0; i < numPoints; i++) {
|
2008-11-25 18:27:41 +00:00
|
|
|
glVertex2iv(pts[i]);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static void viconutil_draw_lineloop_smooth(GLint(*pts)[2], int numPoints)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
viconutil_draw_lineloop(pts, numPoints);
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static void viconutil_draw_points(GLint(*pts)[2], int numPoints, int pointSize)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
2012-03-30 01:51:25 +00:00
|
|
|
for (i = 0; i < numPoints; i++) {
|
2008-11-25 18:27:41 +00:00
|
|
|
int x = pts[i][0], y = pts[i][1];
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2i(x - pointSize, y - pointSize);
|
|
|
|
glVertex2i(x + pointSize, y - pointSize);
|
|
|
|
glVertex2i(x + pointSize, y + pointSize);
|
|
|
|
glVertex2i(x - pointSize, y + pointSize);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
/* Drawing functions */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
static void vicon_x_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
x += 3;
|
|
|
|
y += 3;
|
|
|
|
w -= 6;
|
|
|
|
h -= 6;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
glEnable(GL_LINE_SMOOTH);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glLineWidth(2.5);
|
|
|
|
|
|
|
|
glColor4f(0.0, 0.0, 0.0, alpha);
|
|
|
|
glBegin(GL_LINES);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2i(x, y);
|
|
|
|
glVertex2i(x + w, y + h);
|
|
|
|
glVertex2i(x + w, y);
|
|
|
|
glVertex2i(x, y + h);
|
2008-11-25 18:27:41 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
glDisable(GL_LINE_SMOOTH);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_view3d_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int cx = x + w / 2;
|
|
|
|
int cy = y + h / 2;
|
|
|
|
int d = MAX2(2, h / 3);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glColor4f(0.5, 0.5, 0.5, alpha);
|
|
|
|
glBegin(GL_LINES);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2i(x, cy - d);
|
|
|
|
glVertex2i(x + w, cy - d);
|
|
|
|
glVertex2i(x, cy + d);
|
|
|
|
glVertex2i(x + w, cy + d);
|
|
|
|
|
|
|
|
glVertex2i(cx - d, y);
|
|
|
|
glVertex2i(cx - d, y + h);
|
|
|
|
glVertex2i(cx + d, y);
|
|
|
|
glVertex2i(cx + d, y + h);
|
2008-11-25 18:27:41 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glColor4f(0.0, 0.0, 0.0, alpha);
|
|
|
|
glBegin(GL_LINES);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2i(x, cy);
|
|
|
|
glVertex2i(x + w, cy);
|
|
|
|
glVertex2i(cx, y);
|
|
|
|
glVertex2i(cx, y + h);
|
2008-11-25 18:27:41 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_edit_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
GLint pts[4][2];
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
viconutil_set_point(pts[0], x + 3, y + 3);
|
|
|
|
viconutil_set_point(pts[1], x + w - 3, y + 3);
|
|
|
|
viconutil_set_point(pts[2], x + w - 3, y + h - 3);
|
|
|
|
viconutil_set_point(pts[3], x + 3, y + h - 3);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glColor4f(0.0, 0.0, 0.0, alpha);
|
|
|
|
viconutil_draw_lineloop(pts, 4);
|
|
|
|
|
|
|
|
glColor3f(1, 1, 0.0);
|
|
|
|
viconutil_draw_points(pts, 4, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_editmode_hlt_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
GLint pts[3][2];
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
viconutil_set_point(pts[0], x + w / 2, y + h - 2);
|
|
|
|
viconutil_set_point(pts[1], x + 3, y + 4);
|
|
|
|
viconutil_set_point(pts[2], x + w - 3, y + 4);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glColor4f(0.5, 0.5, 0.5, alpha);
|
|
|
|
viconutil_draw_tri(pts);
|
|
|
|
|
|
|
|
glColor4f(0.0, 0.0, 0.0, 1);
|
|
|
|
viconutil_draw_lineloop_smooth(pts, 3);
|
|
|
|
|
|
|
|
glColor3f(1, 1, 0.0);
|
|
|
|
viconutil_draw_points(pts, 3, 1);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(alpha))
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
GLint pts[3][2];
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
viconutil_set_point(pts[0], x + w / 2, y + h - 2);
|
|
|
|
viconutil_set_point(pts[1], x + 3, y + 4);
|
|
|
|
viconutil_set_point(pts[2], x + w - 3, y + 4);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, 1);
|
2008-11-25 18:27:41 +00:00
|
|
|
viconutil_draw_lineloop_smooth(pts, 3);
|
|
|
|
|
2012-06-17 09:58:26 +00:00
|
|
|
glColor3f(0.9f, 0.9f, 0.9f);
|
2008-11-25 18:27:41 +00:00
|
|
|
viconutil_draw_points(pts, 3, 1);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
GLint pts[3][2];
|
2012-03-30 01:51:25 +00:00
|
|
|
int cx = x + w / 2;
|
|
|
|
int cy = y + w / 2;
|
|
|
|
int d = w / 3, d2 = w / 5;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
viconutil_set_point(pts[0], cx - d2, cy + d);
|
|
|
|
viconutil_set_point(pts[1], cx - d2, cy - d);
|
|
|
|
viconutil_set_point(pts[2], cx + d2, cy);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(GL_TRIANGLES);
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.8f, 0.8f, 0.8f, alpha);
|
2008-11-25 18:27:41 +00:00
|
|
|
glVertex2iv(pts[0]);
|
|
|
|
glVertex2iv(pts[1]);
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.3f, 0.3f, 0.3f, alpha);
|
2008-11-25 18:27:41 +00:00
|
|
|
glVertex2iv(pts[2]);
|
|
|
|
glEnd();
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, 1);
|
2008-11-25 18:27:41 +00:00
|
|
|
viconutil_draw_lineloop_smooth(pts, 3);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
|
2009-07-08 15:34:41 +00:00
|
|
|
{
|
|
|
|
GLint pts[3][2];
|
2012-03-30 01:51:25 +00:00
|
|
|
int cx = x + w / 2 - 4;
|
|
|
|
int cy = y + w / 2;
|
|
|
|
int d = w / 5, d2 = w / 7;
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
viconutil_set_point(pts[0], cx - d2, cy + d);
|
|
|
|
viconutil_set_point(pts[1], cx - d2, cy - d);
|
|
|
|
viconutil_set_point(pts[2], cx + d2, cy);
|
2009-07-08 15:34:41 +00:00
|
|
|
|
|
|
|
glColor4f(0.2f, 0.2f, 0.2f, alpha);
|
|
|
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
glVertex2iv(pts[0]);
|
|
|
|
glVertex2iv(pts[1]);
|
|
|
|
glVertex2iv(pts[2]);
|
|
|
|
glEnd();
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), float alpha)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
GLint pts[3][2];
|
2012-03-30 01:51:25 +00:00
|
|
|
int cx = x + w / 2;
|
|
|
|
int cy = y + w / 2;
|
|
|
|
int d = w / 3, d2 = w / 5;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
viconutil_set_point(pts[0], cx + d, cy + d2);
|
|
|
|
viconutil_set_point(pts[1], cx - d, cy + d2);
|
|
|
|
viconutil_set_point(pts[2], cx, cy - d2);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(GL_TRIANGLES);
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.8f, 0.8f, 0.8f, alpha);
|
2008-11-25 18:27:41 +00:00
|
|
|
glVertex2iv(pts[0]);
|
|
|
|
glVertex2iv(pts[1]);
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.3f, 0.3f, 0.3f, alpha);
|
2008-11-25 18:27:41 +00:00
|
|
|
glVertex2iv(pts[2]);
|
|
|
|
glEnd();
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, 1);
|
2008-11-25 18:27:41 +00:00
|
|
|
viconutil_draw_lineloop_smooth(pts, 3);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int d = -2;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
glLineWidth(1);
|
|
|
|
glColor3f(0.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
|
|
|
|
glVertex2i(x + w / 2, y + h / 2 - d + 1);
|
|
|
|
glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
|
2008-11-25 18:27:41 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha))
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int d = 2;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
glLineWidth(1);
|
|
|
|
glColor3f(0.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
|
|
|
|
glVertex2i(x + w / 2, y + h / 2 - d - 1);
|
|
|
|
glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
|
2008-11-25 18:27:41 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
}
|
|
|
|
|
2011-06-05 07:55:18 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
2010-12-03 12:30:59 +00:00
|
|
|
static void init_brush_icons(void)
|
2010-07-25 22:23:40 +00:00
|
|
|
{
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define INIT_BRUSH_ICON(icon_id, name) \
|
|
|
|
{ \
|
|
|
|
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \
|
|
|
|
datatoc_ ##name## _png_size, \
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
IB_rect, NULL, "<brush icon>"); \
|
2012-03-30 01:51:25 +00:00
|
|
|
def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
|
|
|
|
IMB_freeImBuf(bbuf); \
|
|
|
|
} (void)0
|
|
|
|
/* end INIT_BRUSH_ICON */
|
2010-07-25 22:23:40 +00:00
|
|
|
|
|
|
|
ImBuf *bbuf;
|
|
|
|
const int w = 96;
|
|
|
|
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_ADD, add);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_BLOB, blob);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_BLUR, blur);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_CLAY, clay);
|
2012-03-18 11:44:14 +00:00
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_CLAY_STRIPS, claystrips);
|
2010-07-25 22:23:40 +00:00
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_CLONE, clone);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_CREASE, crease);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_DARKEN, darken);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SCULPT_DRAW, draw);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_FILL, fill);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_FLATTEN, flatten);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_GRAB, grab);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_LIGHTEN, lighten);
|
2012-05-10 20:35:12 +00:00
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_MASK, mask);
|
2010-07-25 22:23:40 +00:00
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_MULTIPLY, multiply);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_PINCH, pinch);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SCRAPE, scrape);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SMEAR, smear);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SMOOTH, smooth);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SNAKE_HOOK, snake_hook);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SOFTEN, soften);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_SUBTRACT, subtract);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_TEXDRAW, texdraw);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_THUMB, thumb);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_VERTEXDRAW, vertexdraw);
|
|
|
|
|
|
|
|
#undef INIT_BRUSH_ICON
|
|
|
|
}
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static void init_internal_icons(void)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
ImBuf *bbuf = NULL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
int x, y, icontype;
|
2011-11-26 04:07:38 +00:00
|
|
|
char iconfilestr[FILE_MAX];
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
|
|
|
|
char *icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
|
2011-03-15 22:24:47 +00:00
|
|
|
if (icondir) {
|
|
|
|
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL); /* if the image is missing bbuf will just be NULL */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
|
2011-03-15 22:24:47 +00:00
|
|
|
printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
|
|
|
|
IMB_freeImBuf(bbuf);
|
2012-03-30 01:51:25 +00:00
|
|
|
bbuf = NULL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2011-10-21 08:16:15 +00:00
|
|
|
else {
|
|
|
|
printf("%s: 'icons' data path not found, continuing\n", __func__);
|
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
if (bbuf == NULL)
|
2012-05-17 07:59:25 +00:00
|
|
|
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons_png,
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
datatoc_blender_icons_png_size, IB_rect, NULL, "<blender icons>");
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bbuf) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* free existing texture if any */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icongltex.id) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glDeleteTextures(1, &icongltex.id);
|
2012-03-30 01:51:25 +00:00
|
|
|
icongltex.id = 0;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we only use a texture for cards with non-power of two */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_non_power_of_two_support()) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glGenTextures(1, &icongltex.id);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icongltex.id) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
icongltex.w = bbuf->x;
|
|
|
|
icongltex.h = bbuf->y;
|
2012-03-30 01:51:25 +00:00
|
|
|
icongltex.invw = 1.0f / bbuf->x;
|
|
|
|
icongltex.invh = 1.0f / bbuf->y;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bbuf->x, bbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, bbuf->rect);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (glGetError() == GL_OUT_OF_MEMORY) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glDeleteTextures(1, &icongltex.id);
|
2012-03-30 01:51:25 +00:00
|
|
|
icongltex.id = 0;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icongltex.id)
|
2012-03-30 01:51:25 +00:00
|
|
|
icontype = ICON_TYPE_TEXTURE;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
icontype = ICON_TYPE_BUFFER;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bbuf) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (y = 0; y < ICON_GRID_ROWS; y++) {
|
|
|
|
for (x = 0; x < ICON_GRID_COLS; x++) {
|
|
|
|
def_internal_icon(bbuf, BIFICONID_FIRST + y * ICON_GRID_COLS + x,
|
|
|
|
x * (ICON_GRID_W + ICON_GRID_MARGIN) + ICON_GRID_MARGIN,
|
|
|
|
y * (ICON_GRID_H + ICON_GRID_MARGIN) + ICON_GRID_MARGIN, ICON_GRID_W,
|
|
|
|
icontype);
|
2010-04-15 10:28:32 +00:00
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 10:23:53 +00:00
|
|
|
def_internal_vicon(VICO_VIEW3D_VEC, vicon_view3d_draw);
|
|
|
|
def_internal_vicon(VICO_EDIT_VEC, vicon_edit_draw);
|
|
|
|
def_internal_vicon(VICO_EDITMODE_DEHLT, vicon_editmode_dehlt_draw);
|
|
|
|
def_internal_vicon(VICO_EDITMODE_HLT, vicon_editmode_hlt_draw);
|
|
|
|
def_internal_vicon(VICO_DISCLOSURE_TRI_RIGHT_VEC, vicon_disclosure_tri_right_draw);
|
|
|
|
def_internal_vicon(VICO_DISCLOSURE_TRI_DOWN_VEC, vicon_disclosure_tri_down_draw);
|
|
|
|
def_internal_vicon(VICO_MOVE_UP_VEC, vicon_move_up_draw);
|
|
|
|
def_internal_vicon(VICO_MOVE_DOWN_VEC, vicon_move_down_draw);
|
|
|
|
def_internal_vicon(VICO_X_VEC, vicon_x_draw);
|
|
|
|
def_internal_vicon(VICO_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
IMB_freeImBuf(bbuf);
|
|
|
|
}
|
2012-08-19 10:41:27 +00:00
|
|
|
#endif /* WITH_HEADLESS */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
static void init_iconfile_list(struct ListBase *list)
|
|
|
|
{
|
|
|
|
IconFile *ifile;
|
|
|
|
struct direntry *dir;
|
|
|
|
int restoredir = 1; /* restore to current directory */
|
2012-03-30 01:51:25 +00:00
|
|
|
int totfile, i, index = 1;
|
2011-03-15 22:24:47 +00:00
|
|
|
const char *icondir;
|
2008-11-25 18:27:41 +00:00
|
|
|
char olddir[FILE_MAX];
|
2010-07-04 15:35:23 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
list->first = list->last = NULL;
|
2011-03-15 22:24:47 +00:00
|
|
|
icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
|
2010-07-04 15:35:23 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icondir == NULL)
|
2008-11-25 18:27:41 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-22 15:35:49 +00:00
|
|
|
/* since BLI_dir_contents changes the current working directory, restore it
|
2012-03-03 16:31:46 +00:00
|
|
|
* back to old value afterwards */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!BLI_current_working_dir(olddir, sizeof(olddir)))
|
2008-11-25 18:27:41 +00:00
|
|
|
restoredir = 0;
|
2011-10-22 15:35:49 +00:00
|
|
|
totfile = BLI_dir_contents(icondir, &dir);
|
2010-04-24 10:08:07 +00:00
|
|
|
if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (i = 0; i < totfile; i++) {
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((dir[i].type & S_IFREG)) {
|
2008-11-25 18:27:41 +00:00
|
|
|
char *filename = dir[i].relname;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BLI_testextensie(filename, ".png")) {
|
2011-03-15 22:24:47 +00:00
|
|
|
/* loading all icons on file start is overkill & slows startup
|
|
|
|
* its possible they change size after blender load anyway. */
|
|
|
|
#if 0
|
|
|
|
int ifilex, ifiley;
|
2012-03-30 01:51:25 +00:00
|
|
|
char iconfilestr[FILE_MAX + 16]; /* allow 256 chars for file+dir */
|
|
|
|
ImBuf *bbuf = NULL;
|
2008-11-25 18:27:41 +00:00
|
|
|
/* check to see if the image is the right size, continue if not */
|
|
|
|
/* copying strings here should go ok, assuming that we never get back
|
2012-03-03 16:31:46 +00:00
|
|
|
* a complete path to file longer than 256 chars */
|
2011-03-15 22:24:47 +00:00
|
|
|
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, filename);
|
2012-03-30 01:51:25 +00:00
|
|
|
bbuf = IMB_loadiffname(iconfilestr, IB_rect);
|
2010-10-07 10:04:07 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bbuf) {
|
2010-10-07 10:04:07 +00:00
|
|
|
ifilex = bbuf->x;
|
|
|
|
ifiley = bbuf->y;
|
|
|
|
IMB_freeImBuf(bbuf);
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
ifilex = ifiley = 0;
|
2010-10-07 10:04:07 +00:00
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2010-10-07 10:04:07 +00:00
|
|
|
/* bad size or failed to load */
|
2011-03-15 22:24:47 +00:00
|
|
|
if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H)) {
|
|
|
|
printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
|
2008-11-25 18:27:41 +00:00
|
|
|
continue;
|
2011-03-15 22:24:47 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
#endif /* removed */
|
2010-10-07 10:04:07 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
/* found a potential icon file, so make an entry for it in the cache list */
|
|
|
|
ifile = MEM_callocN(sizeof(IconFile), "IconFile");
|
|
|
|
|
|
|
|
BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
|
|
|
|
ifile->index = index;
|
|
|
|
|
|
|
|
BLI_addtail(list, ifile);
|
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-22 15:35:49 +00:00
|
|
|
/* free temporary direntry structure that's been created by BLI_dir_contents() */
|
2012-03-30 01:51:25 +00:00
|
|
|
i = totfile - 1;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (; i >= 0; i--) {
|
2008-11-25 18:27:41 +00:00
|
|
|
MEM_freeN(dir[i].relname);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
MEM_freeN(dir[i].path);
|
2012-01-21 22:00:40 +00:00
|
|
|
if (dir[i].string) {
|
|
|
|
MEM_freeN(dir[i].string);
|
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
free(dir);
|
2012-03-30 01:51:25 +00:00
|
|
|
dir = NULL;
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void free_iconfile_list(struct ListBase *list)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
IconFile *ifile = NULL, *next_ifile = NULL;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (ifile = list->first; ifile; ifile = next_ifile) {
|
2008-11-25 18:27:41 +00:00
|
|
|
next_ifile = ifile->next;
|
|
|
|
BLI_freelinkN(list, ifile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
int UI_iconfile_get_index(const char *filename)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
IconFile *ifile;
|
2012-03-30 01:51:25 +00:00
|
|
|
ListBase *list = &(iconfilelist);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (ifile = list->first; ifile; ifile = ifile->next) {
|
2011-04-06 06:03:48 +00:00
|
|
|
if (BLI_path_cmp(filename, ifile->filename) == 0) {
|
2008-11-25 18:27:41 +00:00
|
|
|
return ifile->index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
ListBase *UI_iconfile_list(void)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ListBase *list = &(iconfilelist);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-13 15:02:21 +00:00
|
|
|
void UI_icons_free(void)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2011-06-05 07:55:18 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icongltex.id) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glDeleteTextures(1, &icongltex.id);
|
2012-03-30 01:51:25 +00:00
|
|
|
icongltex.id = 0;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
free_iconfile_list(&iconfilelist);
|
|
|
|
BKE_icons_free();
|
2011-06-05 07:55:18 +00:00
|
|
|
#endif
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
void UI_icons_free_drawinfo(void *drawinfo)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
DrawInfo *di = drawinfo;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (di) {
|
|
|
|
if (di->type == ICON_TYPE_BUFFER) {
|
|
|
|
if (di->data.buffer.image) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
MEM_freeN(di->data.buffer.image->rect);
|
|
|
|
MEM_freeN(di->data.buffer.image);
|
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
MEM_freeN(di);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static DrawInfo *icon_create_drawinfo(void)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
DrawInfo *di = NULL;
|
|
|
|
|
|
|
|
di = MEM_callocN(sizeof(DrawInfo), "di_icon");
|
2012-03-30 01:51:25 +00:00
|
|
|
di->type = ICON_TYPE_PREVIEW;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
return di;
|
|
|
|
}
|
|
|
|
|
2011-08-05 10:45:32 +00:00
|
|
|
/* note!, returns unscaled by DPI, may need to multiply result by UI_DPI_ICON_FAC */
|
2008-11-25 19:23:54 +00:00
|
|
|
int UI_icon_get_width(int icon_id)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
Icon *icon = NULL;
|
|
|
|
DrawInfo *di = NULL;
|
|
|
|
|
|
|
|
icon = BKE_icon_get(icon_id);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icon == NULL) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2011-09-27 17:04:38 +00:00
|
|
|
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
2008-11-25 18:27:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
di = (DrawInfo *)icon->drawinfo;
|
|
|
|
if (!di) {
|
|
|
|
di = icon_create_drawinfo();
|
|
|
|
icon->drawinfo = di;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (di)
|
2009-11-10 03:48:02 +00:00
|
|
|
return ICON_DEFAULT_WIDTH;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
int UI_icon_get_height(int icon_id)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
Icon *icon = NULL;
|
|
|
|
DrawInfo *di = NULL;
|
|
|
|
|
|
|
|
icon = BKE_icon_get(icon_id);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icon == NULL) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2011-09-27 17:04:38 +00:00
|
|
|
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
2008-11-25 18:27:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
di = (DrawInfo *)icon->drawinfo;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
if (!di) {
|
|
|
|
di = icon_create_drawinfo();
|
|
|
|
icon->drawinfo = di;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (di)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return ICON_DEFAULT_HEIGHT;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
void UI_icons_init(int first_dyn_id)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2011-06-05 07:55:18 +00:00
|
|
|
#ifdef WITH_HEADLESS
|
|
|
|
(void)first_dyn_id;
|
|
|
|
#else
|
2008-11-25 18:27:41 +00:00
|
|
|
init_iconfile_list(&iconfilelist);
|
|
|
|
BKE_icons_init(first_dyn_id);
|
|
|
|
init_internal_icons();
|
2010-07-25 22:23:40 +00:00
|
|
|
init_brush_icons();
|
2011-06-05 07:55:18 +00:00
|
|
|
#endif
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
/* Render size for preview images and icons
|
|
|
|
*/
|
|
|
|
static int preview_render_size(enum eIconSizes size)
|
2008-12-11 19:35:27 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
switch (size) {
|
2012-03-30 01:51:25 +00:00
|
|
|
case ICON_SIZE_ICON: return 32;
|
2011-05-16 18:37:54 +00:00
|
|
|
case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT;
|
2008-12-11 19:35:27 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
/* Create rect for the icon
|
|
|
|
*/
|
2012-03-30 01:51:25 +00:00
|
|
|
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
unsigned int render_size = preview_render_size(size);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
if (!prv_img) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2011-09-27 17:04:38 +00:00
|
|
|
printf("%s, error: requested preview image does not exist", __func__);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2012-09-14 06:17:14 +00:00
|
|
|
else if (!prv_img->rect[size]) {
|
2011-05-16 18:37:54 +00:00
|
|
|
prv_img->w[size] = render_size;
|
|
|
|
prv_img->h[size] = render_size;
|
|
|
|
prv_img->changed[size] = 1;
|
|
|
|
prv_img->changed_timestamp[size] = 0;
|
2012-03-30 01:51:25 +00:00
|
|
|
prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(unsigned int), "prv_rect");
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only called when icon has changed */
|
2008-11-25 19:23:54 +00:00
|
|
|
/* only call with valid pointer from UI_icon_draw */
|
2012-03-30 01:51:25 +00:00
|
|
|
static void icon_set_image(bContext *C, ID *id, PreviewImage *prv_img, enum eIconSizes size)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
|
|
|
if (!prv_img) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2011-09-27 17:04:38 +00:00
|
|
|
printf("%s: no preview image for this ID: %s\n", __func__, id->name);
|
2008-11-25 18:27:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_create_rect(prv_img, size);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
ED_preview_icon_job(C, prv_img, id, prv_img->rect[size],
|
2012-03-30 01:51:25 +00:00
|
|
|
prv_img->w[size], prv_img->h[size]);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 16:21:42 +00:00
|
|
|
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, const float rgb[3], short is_preview)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ImBuf *ima = NULL;
|
2010-10-17 09:01:12 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (w <= 0 || h <= 0 || w > 2000 || h > 2000) {
|
2011-09-27 17:04:38 +00:00
|
|
|
printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
|
2011-01-09 15:12:08 +00:00
|
|
|
BLI_assert(!"invalid icon size");
|
2010-10-17 09:01:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* modulate color */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (alpha != 1.0f)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glPixelTransferf(GL_ALPHA_SCALE, alpha);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rgb) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glPixelTransferf(GL_RED_SCALE, rgb[0]);
|
|
|
|
glPixelTransferf(GL_GREEN_SCALE, rgb[1]);
|
|
|
|
glPixelTransferf(GL_BLUE_SCALE, rgb[2]);
|
|
|
|
}
|
|
|
|
|
2010-10-17 09:01:12 +00:00
|
|
|
/* rect contains image in 'rendersize', we only scale if needed */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (rw != w && rh != h) {
|
2010-10-17 09:01:12 +00:00
|
|
|
/* first allocate imbuf for scaling and copy preview into it */
|
|
|
|
ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
|
2012-03-30 01:51:25 +00:00
|
|
|
memcpy(ima->rect, rect, rw * rh * sizeof(unsigned int));
|
2010-10-17 09:01:12 +00:00
|
|
|
IMB_scaleImBuf(ima, w, h); /* scale it */
|
2012-03-30 01:51:25 +00:00
|
|
|
rect = ima->rect;
|
2010-10-17 09:01:12 +00:00
|
|
|
}
|
2010-10-16 05:12:31 +00:00
|
|
|
|
2010-10-18 00:25:32 +00:00
|
|
|
/* draw */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (is_preview) {
|
2010-10-18 00:25:32 +00:00
|
|
|
glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, rect);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glRasterPos2f(x, y);
|
|
|
|
glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
|
|
|
|
}
|
2010-10-16 05:12:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima)
|
2010-10-17 09:01:12 +00:00
|
|
|
IMB_freeImBuf(ima);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* restore color */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (alpha != 0.0f)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rgb) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glPixelTransferf(GL_RED_SCALE, 1.0f);
|
|
|
|
glPixelTransferf(GL_GREEN_SCALE, 1.0f);
|
|
|
|
glPixelTransferf(GL_BLUE_SCALE, 1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-21 16:21:42 +00:00
|
|
|
static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy,
|
|
|
|
int UNUSED(iw), int ih, float alpha, const float rgb[3])
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
|
|
|
float x1, x2, y1, y2;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
else glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
x1 = ix * icongltex.invw;
|
|
|
|
x2 = (ix + ih) * icongltex.invw;
|
|
|
|
y1 = iy * icongltex.invh;
|
|
|
|
y2 = (iy + ih) * icongltex.invh;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
glTexCoord2f(x1, y1);
|
|
|
|
glVertex2f(x, y);
|
|
|
|
|
|
|
|
glTexCoord2f(x2, y1);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2f(x + w, y);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
glTexCoord2f(x2, y2);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2f(x + w, y + h);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
glTexCoord2f(x1, y2);
|
2012-03-30 01:51:25 +00:00
|
|
|
glVertex2f(x, y + h);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
/* Drawing size for preview images */
|
|
|
|
static int get_draw_size(enum eIconSizes size)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
switch (size) {
|
|
|
|
case ICON_SIZE_ICON: return ICON_DEFAULT_HEIGHT;
|
|
|
|
case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT;
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-21 16:21:42 +00:00
|
|
|
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, const float rgb[3],
|
|
|
|
enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
2008-11-25 18:27:41 +00:00
|
|
|
Icon *icon = NULL;
|
|
|
|
DrawInfo *di = NULL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
IconImage *iimg;
|
2012-03-30 01:51:25 +00:00
|
|
|
float fdraw_size = is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
int w, h;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
icon = BKE_icon_get(icon_id);
|
2011-11-19 20:57:53 +00:00
|
|
|
alpha *= btheme->tui.icon_alpha;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icon == NULL) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2011-09-27 17:04:38 +00:00
|
|
|
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
2008-11-25 18:27:41 +00:00
|
|
|
return;
|
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
di = (DrawInfo *)icon->drawinfo;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
if (!di) {
|
|
|
|
di = icon_create_drawinfo();
|
|
|
|
|
|
|
|
icon->drawinfo = di;
|
2008-11-25 19:23:54 +00:00
|
|
|
icon->drawinfo_free = UI_icons_free_drawinfo;
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* scale width and height according to aspect */
|
2012-03-30 01:51:25 +00:00
|
|
|
w = (int)(fdraw_size / aspect + 0.5f);
|
|
|
|
h = (int)(fdraw_size / aspect + 0.5f);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (di->type == ICON_TYPE_VECTOR) {
|
2008-11-25 18:27:41 +00:00
|
|
|
/* vector icons use the uiBlock transformation, they are not drawn
|
2012-03-03 16:31:46 +00:00
|
|
|
* with untransformed coordinates like the other icons */
|
2011-02-18 06:07:41 +00:00
|
|
|
di->data.vector.func((int)x, (int)y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (di->type == ICON_TYPE_TEXTURE) {
|
2011-03-13 17:20:52 +00:00
|
|
|
icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y,
|
2012-03-30 01:51:25 +00:00
|
|
|
di->data.texture.w, di->data.texture.h, alpha, rgb);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (di->type == ICON_TYPE_BUFFER) {
|
2008-11-25 18:27:41 +00:00
|
|
|
/* it is a builtin icon */
|
2012-03-30 01:51:25 +00:00
|
|
|
iimg = di->data.buffer.image;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (!iimg->rect) return; /* something has gone wrong! */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2010-10-16 05:12:31 +00:00
|
|
|
icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (di->type == ICON_TYPE_PREVIEW) {
|
2012-03-30 01:51:25 +00:00
|
|
|
PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pi) {
|
2009-06-25 15:41:27 +00:00
|
|
|
/* no create icon on this level in code */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (!pi->rect[size]) return; /* something has gone wrong! */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* preview images use premul alpha ... */
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], 1.0f, NULL, is_preview);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-17 16:06:32 +00:00
|
|
|
static void ui_id_preview_image_render_size(bContext *C, ID *id, PreviewImage *pi, int size)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
if ((pi->changed[size] || !pi->rect[size])) { /* changed only ever set by dynamic icons */
|
2012-02-17 16:06:32 +00:00
|
|
|
/* create the rect if necessary */
|
|
|
|
icon_set_image(C, id, pi, size);
|
|
|
|
|
|
|
|
pi->changed[size] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-19 17:10:05 +00:00
|
|
|
static void ui_id_icon_render(bContext *C, ID *id, int big)
|
|
|
|
{
|
2012-02-17 16:06:32 +00:00
|
|
|
PreviewImage *pi = BKE_previewimg_get(id);
|
|
|
|
|
|
|
|
if (pi) {
|
|
|
|
if (big)
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW); /* bigger preview size */
|
2012-02-17 16:06:32 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON); /* icon size */
|
2011-01-19 17:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_id_brush_render(bContext *C, ID *id)
|
2009-06-25 15:41:27 +00:00
|
|
|
{
|
|
|
|
PreviewImage *pi = BKE_previewimg_get(id);
|
2011-09-30 15:22:13 +00:00
|
|
|
enum eIconSizes i;
|
2011-01-19 17:10:05 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!pi)
|
2011-01-18 04:08:01 +00:00
|
|
|
return;
|
2011-01-19 17:10:05 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i = 0; i < NUM_ICON_SIZES; i++) {
|
2011-01-19 17:10:05 +00:00
|
|
|
/* check if rect needs to be created; changed
|
2012-03-03 16:31:46 +00:00
|
|
|
* only set by dynamic icons */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((pi->changed[i] || !pi->rect[i])) {
|
2011-01-18 04:32:41 +00:00
|
|
|
icon_set_image(C, id, pi, i);
|
2011-01-18 04:08:01 +00:00
|
|
|
pi->changed[i] = 0;
|
2009-06-25 15:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-19 17:10:05 +00:00
|
|
|
|
|
|
|
static int ui_id_brush_get_icon(bContext *C, ID *id)
|
2010-07-26 04:00:09 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Brush *br = (Brush *)id;
|
2010-07-26 04:00:09 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (br->flag & BRUSH_CUSTOM_ICON) {
|
2010-07-26 04:00:09 +00:00
|
|
|
BKE_icon_getid(id);
|
2011-01-19 17:10:05 +00:00
|
|
|
ui_id_brush_render(C, id);
|
2010-07-26 04:00:09 +00:00
|
|
|
}
|
2010-12-14 01:19:51 +00:00
|
|
|
else {
|
2010-07-26 04:00:09 +00:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2011-01-16 18:33:08 +00:00
|
|
|
SpaceImage *sima;
|
|
|
|
EnumPropertyItem *items = NULL;
|
2010-12-14 01:19:51 +00:00
|
|
|
int tool, mode = 0;
|
|
|
|
|
2011-01-16 18:33:08 +00:00
|
|
|
/* XXX: this is not nice, should probably make brushes
|
2012-03-03 16:31:46 +00:00
|
|
|
* be strictly in one paint mode only to avoid
|
|
|
|
* checking various context stuff here */
|
2010-12-14 01:19:51 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_wm_view3d(C) && ob) {
|
|
|
|
if (ob->mode & OB_MODE_SCULPT)
|
2010-12-14 01:19:51 +00:00
|
|
|
mode = OB_MODE_SCULPT;
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
|
2010-12-14 01:19:51 +00:00
|
|
|
mode = OB_MODE_VERTEX_PAINT;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ob->mode & OB_MODE_TEXTURE_PAINT)
|
2010-12-14 01:19:51 +00:00
|
|
|
mode = OB_MODE_TEXTURE_PAINT;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ((sima = CTX_wm_space_image(C)) &&
|
2012-07-25 11:25:10 +00:00
|
|
|
(sima->mode == SI_MODE_PAINT))
|
2012-03-30 01:51:25 +00:00
|
|
|
{
|
2011-01-16 18:33:08 +00:00
|
|
|
mode = OB_MODE_TEXTURE_PAINT;
|
|
|
|
}
|
2010-12-14 01:19:51 +00:00
|
|
|
|
|
|
|
/* reset the icon */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mode == OB_MODE_SCULPT) {
|
2010-07-26 04:00:09 +00:00
|
|
|
items = brush_sculpt_tool_items;
|
|
|
|
tool = br->sculpt_tool;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mode == OB_MODE_VERTEX_PAINT) {
|
2011-04-01 04:22:30 +00:00
|
|
|
items = brush_vertex_tool_items;
|
2010-07-26 04:00:09 +00:00
|
|
|
tool = br->vertexpaint_tool;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mode == OB_MODE_TEXTURE_PAINT) {
|
2011-04-01 04:22:30 +00:00
|
|
|
items = brush_image_tool_items;
|
2010-07-26 04:00:09 +00:00
|
|
|
tool = br->imagepaint_tool;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id))
|
2010-12-14 01:19:51 +00:00
|
|
|
id->icon_id = 0;
|
2010-07-26 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return id->icon_id;
|
|
|
|
}
|
|
|
|
|
2011-01-19 17:10:05 +00:00
|
|
|
int ui_id_icon_get(bContext *C, ID *id, int big)
|
2009-06-27 01:15:31 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int iconid = 0;
|
2009-06-27 01:15:31 +00:00
|
|
|
|
|
|
|
/* icon */
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (GS(id->name)) {
|
2010-07-26 04:00:09 +00:00
|
|
|
case ID_BR:
|
2012-03-30 01:51:25 +00:00
|
|
|
iconid = ui_id_brush_get_icon(C, id);
|
2010-07-26 04:00:09 +00:00
|
|
|
break;
|
2009-06-27 01:15:31 +00:00
|
|
|
case ID_MA: /* fall through */
|
|
|
|
case ID_TE: /* fall through */
|
|
|
|
case ID_IM: /* fall through */
|
|
|
|
case ID_WO: /* fall through */
|
|
|
|
case ID_LA: /* fall through */
|
2012-03-30 01:51:25 +00:00
|
|
|
iconid = BKE_icon_getid(id);
|
2009-06-27 01:15:31 +00:00
|
|
|
/* checks if not exists, or changed */
|
2011-01-19 17:10:05 +00:00
|
|
|
ui_id_icon_render(C, id, big);
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-06-25 15:41:27 +00:00
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
return iconid;
|
|
|
|
}
|
2009-06-25 15:41:27 +00:00
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
static void icon_draw_at_size(float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, int nocreate)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
int draw_size = get_draw_size(size);
|
|
|
|
icon_draw_size(x, y, icon_id, aspect, alpha, NULL, size, draw_size, nocreate, FALSE);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void UI_icon_draw_aspect(float x, float y, int icon_id, float aspect, float alpha)
|
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, 0);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2012-04-04 01:02:15 +00:00
|
|
|
void UI_icon_draw_aspect_color(float x, float y, int icon_id, float aspect, const float rgb[3])
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
int draw_size = get_draw_size(ICON_SIZE_ICON);
|
|
|
|
icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, FALSE, FALSE);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
void UI_icon_draw(float x, float y, int icon_id)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
UI_icon_draw_aspect(x, y, icon_id, 1.0f, 1.0f);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, ICON_SIZE_ICON, size, TRUE, FALSE);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
2010-01-03 08:37:18 +00:00
|
|
|
void UI_icon_draw_preview(float x, float y, int icon_id)
|
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_draw_at_size(x, y, icon_id, 1.0f, 1.0f, ICON_SIZE_PREVIEW, 0);
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect)
|
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_draw_at_size(x, y, icon_id, aspect, 1.0f, ICON_SIZE_PREVIEW, 0);
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspect, int size)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, ICON_SIZE_PREVIEW, size, FALSE, TRUE);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|