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>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2017-02-12 01:56:08 -05:00
|
|
|
#include "GPU_draw.h"
|
2016-11-18 16:04:25 +01:00
|
|
|
#include "GPU_immediate.h"
|
2009-10-19 14:03:02 +00:00
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2013-03-05 03:44:47 +00:00
|
|
|
#include "BLI_fileops_types.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2010-07-26 04:00:09 +00:00
|
|
|
#include "DNA_brush_types.h"
|
2016-03-14 00:56:52 +13:00
|
|
|
#include "DNA_curve_types.h"
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
#include "DNA_dynamicpaint_types.h"
|
2010-07-26 04:00:09 +00:00
|
|
|
#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"
|
2014-11-23 14:37:13 +01:00
|
|
|
#include "BKE_appdir.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
2015-05-11 16:29:12 +02:00
|
|
|
#include "IMB_thumbs.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2010-09-30 18:35:54 +00:00
|
|
|
#include "BIF_glutil.h"
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2018-02-06 17:28:00 +11:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
2009-06-25 15:41:27 +00:00
|
|
|
#include "ED_datafiles.h"
|
2016-03-14 00:56:52 +13:00
|
|
|
#include "ED_keyframes_draw.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
|
|
|
|
2013-04-08 05:01:35 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
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-12-18 15:10:54 +00:00
|
|
|
#define ICON_GRID_MARGIN 10
|
|
|
|
#define ICON_GRID_W 32
|
|
|
|
#define ICON_GRID_H 32
|
2013-04-08 05:01:35 +00:00
|
|
|
#endif /* WITH_HEADLESS */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
typedef struct IconImage {
|
|
|
|
int w;
|
|
|
|
int h;
|
2013-01-22 11:18:41 +00:00
|
|
|
unsigned int *rect;
|
|
|
|
unsigned char *datatoc_rect;
|
|
|
|
int datatoc_size;
|
2008-11-25 18:27:41 +00:00
|
|
|
} 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
|
|
|
|
|
|
|
/* **************************************************** */
|
|
|
|
|
2013-02-01 08:24:18 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
static DrawInfo *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;
|
|
|
|
|
|
|
|
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 */
|
2012-10-21 05:46:41 +00:00
|
|
|
new_icon->type = 0;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
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) {
|
2013-01-22 11:18:41 +00:00
|
|
|
iimg = MEM_callocN(sizeof(IconImage), "icon_img");
|
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;
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
/* icon buffers can get initialized runtime now, via datatoc */
|
|
|
|
if (bbuf) {
|
|
|
|
int y, imgsize;
|
|
|
|
|
|
|
|
iimg->rect = MEM_mallocN(size * size * sizeof(unsigned int), "icon_rect");
|
|
|
|
|
|
|
|
/* Here we store the rect in the icon - same as before */
|
|
|
|
if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0)
|
|
|
|
memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
|
|
|
|
else {
|
|
|
|
/* this code assumes square images */
|
|
|
|
imgsize = bbuf->x;
|
|
|
|
for (y = 0; y < size; y++) {
|
2013-01-28 12:57:56 +00:00
|
|
|
memcpy(&iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
|
2013-01-22 11:18: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);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
return di;
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
2017-02-11 00:24:59 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4f(0.2f, 0.2f, 0.2f, alpha);
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRIS, 3);
|
2017-02-11 00:24:59 -05:00
|
|
|
immVertex2iv(pos, pts[0]);
|
|
|
|
immVertex2iv(pos, pts[1]);
|
|
|
|
immVertex2iv(pos, pts[2]);
|
|
|
|
immEnd();
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immUnbindProgram();
|
2009-07-08 15:34:41 +00:00
|
|
|
}
|
|
|
|
|
2016-03-14 00:56:52 +13:00
|
|
|
static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, short key_type)
|
|
|
|
{
|
|
|
|
/* init dummy theme state for Action Editor - where these colors are defined
|
|
|
|
* (since we're doing this offscreen, free from any particular space_id)
|
|
|
|
*/
|
|
|
|
struct bThemeState theme_state;
|
|
|
|
|
|
|
|
UI_Theme_Store(&theme_state);
|
|
|
|
UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
/* the "x" and "y" given are the bottom-left coordinates of the icon,
|
|
|
|
* while the draw_keyframe_shape() function needs the midpoint for
|
|
|
|
* the keyframe
|
|
|
|
*/
|
2017-02-11 00:24:59 -05:00
|
|
|
int xco = x + w / 2;
|
|
|
|
int yco = y + h / 2;
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
|
|
|
unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
2017-02-11 00:24:59 -05:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
2017-02-12 01:56:08 -05:00
|
|
|
GPU_enable_program_point_size();
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_POINTS, 1);
|
2017-02-28 01:21:27 -05:00
|
|
|
|
2016-03-14 00:56:52 +13:00
|
|
|
/* draw keyframe
|
2017-02-28 01:21:27 -05:00
|
|
|
* - size: 0.6 * h (found out experimentally... dunno why!)
|
2016-03-14 00:56:52 +13:00
|
|
|
* - sel: true (so that "keyframe" state shows the iconic yellow icon)
|
|
|
|
*/
|
2017-02-28 01:21:27 -05:00
|
|
|
draw_keyframe_shape(xco, yco, 0.6f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha,
|
2017-02-11 00:24:59 -05:00
|
|
|
pos_id, size_id, color_id, outline_color_id);
|
|
|
|
|
|
|
|
immEnd();
|
2017-02-12 01:56:08 -05:00
|
|
|
GPU_disable_program_point_size();
|
2017-02-11 00:24:59 -05:00
|
|
|
immUnbindProgram();
|
|
|
|
|
2016-03-14 00:56:52 +13:00
|
|
|
UI_Theme_Restore(&theme_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_keytype_keyframe_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_KEYFRAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_keytype_breakdown_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_BREAKDOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_keytype_extreme_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_EXTREME);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_JITTER);
|
|
|
|
}
|
|
|
|
|
2016-07-07 23:37:15 +12:00
|
|
|
static void vicon_keytype_moving_hold_draw(int x, int y, int w, int h, float alpha)
|
|
|
|
{
|
|
|
|
vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_MOVEHOLD);
|
|
|
|
}
|
|
|
|
|
2016-05-19 03:25:00 +12:00
|
|
|
static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha))
|
|
|
|
{
|
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
ThemeWireColor *cs = &btheme->tarm[index];
|
2017-02-11 00:24:59 -05:00
|
|
|
|
2016-05-19 03:25:00 +12:00
|
|
|
/* Draw three bands of color: One per color
|
|
|
|
* x-----a-----b-----c
|
|
|
|
* | N | S | A |
|
|
|
|
* x-----a-----b-----c
|
|
|
|
*/
|
|
|
|
const int a = x + w / 3;
|
|
|
|
const int b = x + w / 3 * 2;
|
|
|
|
const int c = x + w;
|
2017-02-11 00:24:59 -05:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
2017-02-11 00:24:59 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
2016-05-19 03:25:00 +12:00
|
|
|
/* XXX: Include alpha into this... */
|
|
|
|
/* normal */
|
2017-02-11 00:24:59 -05:00
|
|
|
immUniformColor3ubv((unsigned char *)cs->solid);
|
|
|
|
immRecti(pos, x, y, a, y + h);
|
|
|
|
|
2016-05-19 03:25:00 +12:00
|
|
|
/* selected */
|
2017-02-11 00:24:59 -05:00
|
|
|
immUniformColor3ubv((unsigned char *)cs->select);
|
|
|
|
immRecti(pos, a, y, b, y + h);
|
|
|
|
|
2016-05-19 03:25:00 +12:00
|
|
|
/* active */
|
2017-02-11 00:24:59 -05:00
|
|
|
immUniformColor3ubv((unsigned char *)cs->active);
|
|
|
|
immRecti(pos, b, y, c, y + h);
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2016-05-19 03:25:00 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DEF_VICON_COLORSET_DRAW_NTH(prefix, index) \
|
|
|
|
static void vicon_colorset_draw_##prefix(int x, int y, int w, int h, float alpha) \
|
|
|
|
{ \
|
|
|
|
vicon_colorset_draw(index, x, y, w, h, alpha); \
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(01, 0)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(02, 1)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(03, 2)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(04, 3)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(05, 4)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(06, 5)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(07, 6)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(08, 7)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(09, 8)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(10, 9)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(11, 10)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(12, 11)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(13, 12)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(14, 13)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(15, 14)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(16, 15)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(17, 16)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(18, 17)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(19, 18)
|
|
|
|
DEF_VICON_COLORSET_DRAW_NTH(20, 19)
|
|
|
|
|
|
|
|
#undef DEF_VICON_COLORSET_DRAW_NTH
|
|
|
|
|
2011-06-05 07:55:18 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
2013-02-01 08:24:18 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static void init_brush_icons(void)
|
2010-07-25 22:23:40 +00:00
|
|
|
{
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
#define INIT_BRUSH_ICON(icon_id, name) \
|
|
|
|
{ \
|
2014-04-20 22:05:05 +10:00
|
|
|
unsigned char *rect = (unsigned char *)datatoc_ ##name## _png; \
|
|
|
|
int size = datatoc_ ##name## _png_size; \
|
|
|
|
DrawInfo *di; \
|
2013-01-22 11:18:41 +00:00
|
|
|
\
|
2014-04-20 22:05:05 +10:00
|
|
|
di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
|
|
|
|
di->data.buffer.image->datatoc_rect = rect; \
|
|
|
|
di->data.buffer.image->datatoc_size = size; \
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
/* end INIT_BRUSH_ICON */
|
2010-07-25 22:23:40 +00:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
const int w = 96; /* warning, brush size hardcoded in C, but it gets scaled */
|
2010-07-25 22:23:40 +00:00
|
|
|
|
|
|
|
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);
|
2014-07-21 12:02:05 +02:00
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_TEXFILL, texfill);
|
|
|
|
INIT_BRUSH_ICON(ICON_BRUSH_TEXMASK, texmask);
|
2010-07-25 22:23:40 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
static void icon_verify_datatoc(IconImage *iimg)
|
|
|
|
{
|
|
|
|
/* if it has own rect, things are all OK */
|
|
|
|
if (iimg->rect)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (iimg->datatoc_rect) {
|
|
|
|
ImBuf *bbuf = IMB_ibImageFromMemory(iimg->datatoc_rect,
|
2013-01-22 13:35:02 +00:00
|
|
|
iimg->datatoc_size, IB_rect, NULL, "<matcap icon>");
|
2013-01-22 11:18:41 +00:00
|
|
|
/* w and h were set on initialize */
|
|
|
|
if (bbuf->x != iimg->h && bbuf->y != iimg->w)
|
2013-02-05 16:16:07 +00:00
|
|
|
IMB_scaleImBuf(bbuf, iimg->w, iimg->h);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
iimg->rect = bbuf->rect;
|
|
|
|
bbuf->rect = NULL;
|
|
|
|
IMB_freeImBuf(bbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_matcap_icons(void)
|
|
|
|
{
|
|
|
|
/* dynamic allocation now, tucking datatoc pointers in DrawInfo */
|
2013-01-22 13:35:02 +00:00
|
|
|
#define INIT_MATCAP_ICON(icon_id, name) \
|
|
|
|
{ \
|
|
|
|
unsigned char *rect = (unsigned char *)datatoc_ ##name## _jpg; \
|
|
|
|
int size = datatoc_ ##name## _jpg_size; \
|
|
|
|
DrawInfo *di; \
|
|
|
|
\
|
2013-02-05 16:16:07 +00:00
|
|
|
di = def_internal_icon(NULL, icon_id, 0, 0, 96, ICON_TYPE_BUFFER); \
|
2013-01-22 13:35:02 +00:00
|
|
|
di->data.buffer.image->datatoc_rect = rect; \
|
|
|
|
di->data.buffer.image->datatoc_size = size; \
|
|
|
|
} (void)0
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_01, mc01);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_02, mc02);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_03, mc03);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_04, mc04);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_05, mc05);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_06, mc06);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_07, mc07);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_08, mc08);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_09, mc09);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_10, mc10);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_11, mc11);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_12, mc12);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_13, mc13);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_14, mc14);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_15, mc15);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_16, mc16);
|
2013-02-05 16:16:07 +00:00
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_17, mc17);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_18, mc18);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_19, mc19);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_20, mc20);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_21, mc21);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_22, mc22);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_23, mc23);
|
|
|
|
INIT_MATCAP_ICON(ICON_MATCAP_24, mc24);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
#undef INIT_MATCAP_ICON
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static void init_internal_icons(void)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-12-18 19:35:54 +00:00
|
|
|
// bTheme *btheme = UI_GetTheme();
|
|
|
|
ImBuf *b16buf = NULL, *b32buf = 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;
|
2012-12-18 19:35:54 +00:00
|
|
|
|
|
|
|
#if 0 // temp disabled
|
2012-03-30 01:51:25 +00:00
|
|
|
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
|
2014-11-23 15:54:29 +01:00
|
|
|
char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
|
2012-12-18 19:35:54 +00:00
|
|
|
char iconfilestr[FILE_MAX];
|
|
|
|
|
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-12-18 19:35:54 +00:00
|
|
|
#endif
|
|
|
|
if (b16buf == NULL)
|
|
|
|
b16buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons16_png,
|
2014-04-20 22:05:05 +10:00
|
|
|
datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>");
|
2012-12-19 10:12:58 +00:00
|
|
|
if (b16buf)
|
|
|
|
IMB_premultiply_alpha(b16buf);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-12-18 19:35:54 +00:00
|
|
|
if (b32buf == NULL)
|
|
|
|
b32buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons32_png,
|
2014-04-20 22:05:05 +10:00
|
|
|
datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
|
2012-12-19 10:12:58 +00:00
|
|
|
if (b32buf)
|
|
|
|
IMB_premultiply_alpha(b32buf);
|
2012-12-18 19:35:54 +00:00
|
|
|
|
|
|
|
if (b16buf && b32buf) {
|
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
|
|
|
}
|
|
|
|
|
2016-10-17 02:36:51 -04:00
|
|
|
#if 0 /* should be a compile-time check (if needed at all) */
|
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 */
|
2015-12-06 21:41:21 +01:00
|
|
|
if (GPU_full_non_power_of_two_support()) {
|
2016-10-17 02:36:51 -04:00
|
|
|
#else
|
|
|
|
{
|
|
|
|
#endif
|
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) {
|
2012-12-18 19:35:54 +00:00
|
|
|
int level = 2;
|
|
|
|
|
|
|
|
icongltex.w = b32buf->x;
|
|
|
|
icongltex.h = b32buf->y;
|
|
|
|
icongltex.invw = 1.0f / b32buf->x;
|
|
|
|
icongltex.invh = 1.0f / b32buf->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);
|
2012-12-18 19:35:54 +00:00
|
|
|
|
2015-12-08 01:19:08 -05:00
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, b32buf->x, b32buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b32buf->rect);
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, b16buf->x, b16buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b16buf->rect);
|
2012-12-18 19:35:54 +00:00
|
|
|
|
|
|
|
while (b16buf->x > 1) {
|
2012-12-28 10:38:07 +00:00
|
|
|
ImBuf *nbuf = IMB_onehalf(b16buf);
|
2015-12-08 01:19:08 -05:00
|
|
|
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, nbuf->x, nbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nbuf->rect);
|
2012-12-18 19:35:54 +00:00
|
|
|
level++;
|
2012-12-28 10:38:07 +00:00
|
|
|
IMB_freeImBuf(b16buf);
|
|
|
|
b16buf = nbuf;
|
2012-12-18 19:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
2013-01-03 13:19:16 +00:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
2012-12-18 19:35: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
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-12-28 10:38:07 +00:00
|
|
|
if (b32buf) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (y = 0; y < ICON_GRID_ROWS; y++) {
|
|
|
|
for (x = 0; x < ICON_GRID_COLS; x++) {
|
2012-12-18 19:35:54 +00:00
|
|
|
def_internal_icon(b32buf, BIFICONID_FIRST + y * ICON_GRID_COLS + x,
|
2012-03-30 01:51:25 +00:00
|
|
|
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_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw);
|
2016-03-14 00:56:52 +13:00
|
|
|
|
|
|
|
def_internal_vicon(VICO_KEYTYPE_KEYFRAME_VEC, vicon_keytype_keyframe_draw);
|
|
|
|
def_internal_vicon(VICO_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw);
|
|
|
|
def_internal_vicon(VICO_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw);
|
|
|
|
def_internal_vicon(VICO_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw);
|
2016-07-07 23:37:15 +12:00
|
|
|
def_internal_vicon(VICO_KEYTYPE_MOVING_HOLD_VEC, vicon_keytype_moving_hold_draw);
|
2016-05-19 03:25:00 +12:00
|
|
|
|
|
|
|
def_internal_vicon(VICO_COLORSET_01_VEC, vicon_colorset_draw_01);
|
|
|
|
def_internal_vicon(VICO_COLORSET_02_VEC, vicon_colorset_draw_02);
|
|
|
|
def_internal_vicon(VICO_COLORSET_03_VEC, vicon_colorset_draw_03);
|
|
|
|
def_internal_vicon(VICO_COLORSET_04_VEC, vicon_colorset_draw_04);
|
|
|
|
def_internal_vicon(VICO_COLORSET_05_VEC, vicon_colorset_draw_05);
|
|
|
|
def_internal_vicon(VICO_COLORSET_06_VEC, vicon_colorset_draw_06);
|
|
|
|
def_internal_vicon(VICO_COLORSET_07_VEC, vicon_colorset_draw_07);
|
|
|
|
def_internal_vicon(VICO_COLORSET_08_VEC, vicon_colorset_draw_08);
|
|
|
|
def_internal_vicon(VICO_COLORSET_09_VEC, vicon_colorset_draw_09);
|
|
|
|
def_internal_vicon(VICO_COLORSET_10_VEC, vicon_colorset_draw_10);
|
|
|
|
def_internal_vicon(VICO_COLORSET_11_VEC, vicon_colorset_draw_11);
|
|
|
|
def_internal_vicon(VICO_COLORSET_12_VEC, vicon_colorset_draw_12);
|
|
|
|
def_internal_vicon(VICO_COLORSET_13_VEC, vicon_colorset_draw_13);
|
|
|
|
def_internal_vicon(VICO_COLORSET_14_VEC, vicon_colorset_draw_14);
|
|
|
|
def_internal_vicon(VICO_COLORSET_15_VEC, vicon_colorset_draw_15);
|
|
|
|
def_internal_vicon(VICO_COLORSET_16_VEC, vicon_colorset_draw_16);
|
|
|
|
def_internal_vicon(VICO_COLORSET_17_VEC, vicon_colorset_draw_17);
|
|
|
|
def_internal_vicon(VICO_COLORSET_18_VEC, vicon_colorset_draw_18);
|
|
|
|
def_internal_vicon(VICO_COLORSET_19_VEC, vicon_colorset_draw_19);
|
|
|
|
def_internal_vicon(VICO_COLORSET_20_VEC, vicon_colorset_draw_20);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-12-18 19:35:54 +00:00
|
|
|
IMB_freeImBuf(b16buf);
|
|
|
|
IMB_freeImBuf(b32buf);
|
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
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;
|
2012-03-30 01:51:25 +00:00
|
|
|
int totfile, i, index = 1;
|
2011-03-15 22:24:47 +00:00
|
|
|
const char *icondir;
|
2010-07-04 15:35:23 +00:00
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(list);
|
2014-11-23 15:54:29 +01:00
|
|
|
icondir = BKE_appdir_folder_id(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;
|
|
|
|
|
2015-01-03 12:27:40 +01:00
|
|
|
totfile = BLI_filelist_dir_contents(icondir, &dir);
|
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)) {
|
2014-04-27 00:22:49 +10:00
|
|
|
const char *filename = dir[i].relname;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-05 03:44:47 +00:00
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
BLI_filelist_free(dir, totfile);
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 08:24:18 +00:00
|
|
|
#endif /* WITH_HEADLESS */
|
|
|
|
|
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) {
|
2013-01-22 11:18:41 +00:00
|
|
|
if (di->data.buffer.image->rect)
|
|
|
|
MEM_freeN(di->data.buffer.image->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
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* note!, returns unscaled by DPI */
|
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
|
|
|
{
|
|
|
|
BKE_icons_init(first_dyn_id);
|
2015-05-16 06:18:04 +10:00
|
|
|
#ifndef WITH_HEADLESS
|
|
|
|
init_iconfile_list(&iconfilelist);
|
2008-11-25 18:27:41 +00:00
|
|
|
init_internal_icons();
|
2010-07-25 22:23:40 +00:00
|
|
|
init_brush_icons();
|
2013-01-22 11:18:41 +00:00
|
|
|
init_matcap_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
|
|
|
|
*/
|
2015-08-10 17:26:37 +02:00
|
|
|
int UI_preview_render_size(enum eIconSizes size)
|
2008-12-11 19:35:27 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
switch (size) {
|
2015-05-11 16:29:12 +02:00
|
|
|
case ICON_SIZE_ICON:
|
|
|
|
return ICON_RENDER_DEFAULT_HEIGHT;
|
|
|
|
case ICON_SIZE_PREVIEW:
|
|
|
|
return PREVIEW_RENDER_DEFAULT_HEIGHT;
|
|
|
|
default:
|
|
|
|
return 0;
|
2008-12-11 19:35:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-08-10 17:26:37 +02:00
|
|
|
unsigned int render_size = UI_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;
|
2015-05-11 16:29:12 +02:00
|
|
|
prv_img->flag[size] |= PRV_CHANGED;
|
2011-05-16 18:37:54 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-12 21:08:38 +02:00
|
|
|
static void ui_id_preview_image_render_size(
|
|
|
|
const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job);
|
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
|
|
|
|
{
|
|
|
|
Icon *icon = BKE_icon_get(icon_id);
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
DrawInfo *di = (DrawInfo *)icon->drawinfo;
|
|
|
|
|
|
|
|
if (!di) {
|
|
|
|
di = icon_create_drawinfo();
|
|
|
|
|
|
|
|
icon->drawinfo = di;
|
|
|
|
icon->drawinfo_free = UI_icons_free_drawinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (di) {
|
2016-07-12 21:08:38 +02:00
|
|
|
switch (di->type) {
|
|
|
|
case ICON_TYPE_PREVIEW:
|
|
|
|
{
|
|
|
|
ID *id = (icon->type != 0) ? icon->obj : NULL;
|
|
|
|
PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
|
2016-12-01 16:43:57 +01:00
|
|
|
/* Using jobs for screen previews crashes due to offscreen rendering.
|
|
|
|
* XXX would be nicer if PreviewImage could store if it supports jobs */
|
|
|
|
const bool use_jobs = !id || (GS(id->name) != ID_SCR);
|
2016-07-12 21:08:38 +02:00
|
|
|
|
|
|
|
if (prv) {
|
|
|
|
const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON;
|
|
|
|
|
2016-10-27 09:51:10 +02:00
|
|
|
if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) {
|
2016-12-01 16:43:57 +01:00
|
|
|
ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs);
|
2016-07-12 21:08:38 +02:00
|
|
|
}
|
2015-05-11 16:29:12 +02:00
|
|
|
}
|
2016-07-19 10:23:51 +10:00
|
|
|
break;
|
2015-05-11 16:29:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 */
|
2015-01-12 14:44:54 +01:00
|
|
|
static void icon_set_image(
|
|
|
|
const bContext *C, Scene *scene, ID *id, PreviewImage *prv_img, enum eIconSizes size, const bool use_job)
|
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;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
if (prv_img->flag[size] & PRV_USER_EDITED) {
|
|
|
|
/* user-edited preview, do not auto-update! */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
icon_create_rect(prv_img, size);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2015-01-07 12:31:25 +01:00
|
|
|
if (use_job) {
|
|
|
|
/* Job (background) version */
|
|
|
|
ED_preview_icon_job(C, prv_img, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]);
|
|
|
|
}
|
|
|
|
else {
|
2015-01-12 14:44:54 +01:00
|
|
|
if (!scene) {
|
|
|
|
scene = CTX_data_scene(C);
|
|
|
|
}
|
2015-01-07 12:31:25 +01:00
|
|
|
/* Immediate version */
|
2015-06-07 21:33:48 +02:00
|
|
|
ED_preview_icon_render(CTX_data_main(C), scene, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]);
|
2015-01-07 12:31:25 +01:00
|
|
|
}
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
PreviewImage *UI_icon_to_preview(int icon_id)
|
|
|
|
{
|
|
|
|
Icon *icon = BKE_icon_get(icon_id);
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
DrawInfo *di = (DrawInfo *)icon->drawinfo;
|
2015-05-11 16:29:12 +02:00
|
|
|
if (di) {
|
|
|
|
if (di->type == ICON_TYPE_PREVIEW) {
|
|
|
|
PreviewImage *prv = (icon->type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
if (prv) {
|
|
|
|
return BKE_previewimg_copy(prv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (di->data.buffer.image) {
|
|
|
|
ImBuf *bbuf;
|
|
|
|
|
|
|
|
bbuf = IMB_ibImageFromMemory(di->data.buffer.image->datatoc_rect, di->data.buffer.image->datatoc_size,
|
|
|
|
IB_rect, NULL, __func__);
|
|
|
|
if (bbuf) {
|
|
|
|
PreviewImage *prv = BKE_previewimg_create();
|
|
|
|
|
|
|
|
prv->rect[0] = bbuf->rect;
|
|
|
|
|
|
|
|
prv->w[0] = bbuf->x;
|
|
|
|
prv->h[0] = bbuf->y;
|
|
|
|
|
|
|
|
bbuf->rect = NULL;
|
|
|
|
IMB_freeImBuf(bbuf);
|
|
|
|
|
|
|
|
return prv;
|
|
|
|
}
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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,
|
2017-02-25 15:23:27 +01:00
|
|
|
unsigned int *rect, float alpha, const float rgb[3], const bool UNUSED(is_preview))
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ImBuf *ima = NULL;
|
2015-05-11 16:29:12 +02:00
|
|
|
int draw_w = w;
|
|
|
|
int draw_h = h;
|
|
|
|
int draw_x = x;
|
|
|
|
int draw_y = y;
|
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 */
|
2017-02-24 01:21:02 +01:00
|
|
|
float col[4] = {1.0f, 1.0f, 1.0f, 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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rgb) {
|
2017-02-24 01:21:02 +01:00
|
|
|
col[0] = rgb[0];
|
|
|
|
col[1] = rgb[1];
|
|
|
|
col[2] = rgb[2];
|
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-17 09:01:12 +00:00
|
|
|
/* rect contains image in 'rendersize', we only scale if needed */
|
2015-05-11 16:29:12 +02:00
|
|
|
if (rw != w || rh != h) {
|
|
|
|
/* preserve aspect ratio and center */
|
|
|
|
if (rw > rh) {
|
|
|
|
draw_w = w;
|
|
|
|
draw_h = (int)(((float)rh / (float)rw) * (float)w);
|
|
|
|
draw_y += (h - draw_h) / 2;
|
|
|
|
}
|
|
|
|
else if (rw < rh) {
|
|
|
|
draw_w = (int)(((float)rw / (float)rh) * (float)h);
|
|
|
|
draw_h = h;
|
|
|
|
draw_x += (w - draw_w) / 2;
|
|
|
|
}
|
|
|
|
/* if the image is squared, the draw_ initialization values are good */
|
|
|
|
|
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));
|
2015-05-11 16:29:12 +02:00
|
|
|
IMB_scaleImBuf(ima, draw_w, draw_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 */
|
2017-04-11 16:30:00 +02:00
|
|
|
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
|
|
|
immDrawPixelsTex(&state, draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect,
|
2017-02-28 15:22:43 -05:00
|
|
|
1.0f, 1.0f, col);
|
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
|
|
|
}
|
|
|
|
|
2015-05-05 03:13:47 +10: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-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
|
|
|
|
2016-11-18 16:04:25 +01:00
|
|
|
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
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
|
|
|
|
2016-11-18 16:04:25 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
|
2017-02-11 00:24:59 -05:00
|
|
|
if (rgb) immUniformColor3fvAlpha(rgb, alpha);
|
|
|
|
else immUniformColor4f(alpha, alpha, alpha, 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
|
|
|
|
2016-11-18 16:04:25 +01:00
|
|
|
immUniform1i("image", 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
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRI_STRIP, 4);
|
2016-11-18 16:04:25 +01:00
|
|
|
immAttrib2f(texCoord, x1, y2);
|
|
|
|
immVertex2f(pos, x, y + h);
|
|
|
|
|
|
|
|
immAttrib2f(texCoord, x1, y1);
|
|
|
|
immVertex2f(pos, x, y);
|
|
|
|
|
|
|
|
immAttrib2f(texCoord, x2, y2);
|
|
|
|
immVertex2f(pos, x + w, y + h);
|
|
|
|
|
|
|
|
immAttrib2f(texCoord, x2, y1);
|
|
|
|
immVertex2f(pos, x + w, y);
|
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
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, 0);
|
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) {
|
2015-05-11 16:29:12 +02:00
|
|
|
case ICON_SIZE_ICON:
|
|
|
|
return ICON_DEFAULT_HEIGHT;
|
|
|
|
case ICON_SIZE_PREVIEW:
|
|
|
|
return PREVIEW_DEFAULT_HEIGHT;
|
|
|
|
default:
|
|
|
|
return 0;
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
|
2015-05-05 03:13:47 +10: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, const bool UNUSED(nocreate), const bool 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-12-19 09:13:06 +00:00
|
|
|
const float fdraw_size = (float)draw_size;
|
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();
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
icon->drawinfo = di;
|
|
|
|
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 */
|
2013-01-13 18:21:47 +00:00
|
|
|
di->data.vector.func((int)x, (int)y, w, h, 1.0f);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (di->type == ICON_TYPE_TEXTURE) {
|
2012-12-19 10:12:58 +00:00
|
|
|
/* texture image use premul alpha for correct scaling */
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
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);
|
2012-12-19 10:12:58 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_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
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (di->type == ICON_TYPE_BUFFER) {
|
2012-10-21 05:46:41 +00:00
|
|
|
/* it is a builtin icon */
|
2012-03-30 01:51:25 +00:00
|
|
|
iimg = di->data.buffer.image;
|
2013-02-01 08:24:18 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
2013-01-22 11:18:41 +00:00
|
|
|
icon_verify_datatoc(iimg);
|
2013-02-01 08:24:18 +00:00
|
|
|
#endif
|
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
|
|
|
|
2014-04-27 23:38:21 +03:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
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);
|
2012-12-19 10:12:58 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (di->type == ICON_TYPE_PREVIEW) {
|
2015-05-11 16:29:12 +02:00
|
|
|
PreviewImage *pi = (icon->type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2012-10-21 05:46:41 +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 ... */
|
2015-11-24 02:34:54 -05:00
|
|
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
2015-06-22 16:51:22 +10:00
|
|
|
|
2015-05-24 18:35:14 +02:00
|
|
|
icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-12 14:44:54 +01:00
|
|
|
static void ui_id_preview_image_render_size(
|
|
|
|
const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job)
|
2012-02-17 16:06:32 +00:00
|
|
|
{
|
2015-05-11 16:29:12 +02:00
|
|
|
if (((pi->flag[size] & PRV_CHANGED) || !pi->rect[size])) { /* changed only ever set by dynamic icons */
|
2012-02-17 16:06:32 +00:00
|
|
|
/* create the rect if necessary */
|
2015-01-12 14:44:54 +01:00
|
|
|
icon_set_image(C, scene, id, pi, size, use_job);
|
2012-02-17 16:06:32 +00:00
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
pi->flag[size] &= ~PRV_CHANGED;
|
2012-02-17 16:06:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-12 14:44:54 +01:00
|
|
|
void UI_id_icon_render(const bContext *C, Scene *scene, ID *id, const bool big, const bool use_job)
|
2011-01-19 17:10:05 +00:00
|
|
|
{
|
2015-05-11 16:29:12 +02:00
|
|
|
PreviewImage *pi = BKE_previewimg_id_ensure(id);
|
2012-02-17 16:06:32 +00:00
|
|
|
|
|
|
|
if (pi) {
|
|
|
|
if (big)
|
2015-01-12 14:44:54 +01:00
|
|
|
ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_PREVIEW, use_job); /* bigger preview size */
|
2012-02-17 16:06:32 +00:00
|
|
|
else
|
2015-01-12 14:44:54 +01:00
|
|
|
ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_ICON, use_job); /* icon size */
|
2011-01-19 17:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 16:43:57 +01:00
|
|
|
static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
|
2009-06-25 15:41:27 +00:00
|
|
|
{
|
2015-05-11 16:29:12 +02:00
|
|
|
PreviewImage *pi = BKE_previewimg_id_ensure(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 */
|
2015-05-11 16:29:12 +02:00
|
|
|
if (((pi->flag[i] & PRV_CHANGED) || !pi->rect[i])) {
|
2016-12-01 16:43:57 +01:00
|
|
|
icon_set_image(C, NULL, id, pi, i, use_jobs);
|
2015-05-11 16:29:12 +02:00
|
|
|
pi->flag[i] &= ~PRV_CHANGED;
|
2009-06-25 15:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-19 17:10:05 +00:00
|
|
|
|
2015-01-01 23:26:03 +11:00
|
|
|
static int ui_id_brush_get_icon(const 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) {
|
2015-05-11 16:29:12 +02:00
|
|
|
BKE_icon_id_ensure(id);
|
2016-12-01 16:43:57 +01:00
|
|
|
ui_id_icon_render(C, id, true);
|
2010-07-26 04:00:09 +00:00
|
|
|
}
|
2010-12-14 01:19:51 +00:00
|
|
|
else {
|
2018-02-06 17:28:00 +11:00
|
|
|
EvaluationContext eval_ctx;
|
|
|
|
CTX_data_eval_ctx(C, &eval_ctx);
|
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;
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *items = NULL;
|
2016-04-30 04:04:18 +10:00
|
|
|
int tool = PAINT_TOOL_DRAW, mode = 0;
|
2010-12-14 01:19:51 +00:00
|
|
|
|
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) {
|
2018-02-06 17:28:00 +11:00
|
|
|
if (eval_ctx.object_mode & OB_MODE_SCULPT)
|
2010-12-14 01:19:51 +00:00
|
|
|
mode = OB_MODE_SCULPT;
|
2018-02-06 17:28:00 +11:00
|
|
|
else if (eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
|
2010-12-14 01:19:51 +00:00
|
|
|
mode = OB_MODE_VERTEX_PAINT;
|
2018-02-06 17:28:00 +11:00
|
|
|
else if (eval_ctx.object_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) {
|
2015-11-23 13:49:52 +11:00
|
|
|
items = rna_enum_brush_sculpt_tool_items;
|
2010-07-26 04:00:09 +00:00
|
|
|
tool = br->sculpt_tool;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mode == OB_MODE_VERTEX_PAINT) {
|
2015-11-23 13:49:52 +11:00
|
|
|
items = rna_enum_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) {
|
2015-11-23 13:49:52 +11:00
|
|
|
items = rna_enum_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;
|
|
|
|
}
|
|
|
|
|
2016-12-01 16:43:57 +01:00
|
|
|
static int ui_id_screen_get_icon(const bContext *C, ID *id)
|
|
|
|
{
|
|
|
|
BKE_icon_id_ensure(id);
|
|
|
|
/* Don't use jobs here, offscreen rendering doesn't like this and crashes. */
|
|
|
|
ui_id_icon_render(C, id, false);
|
|
|
|
|
|
|
|
return id->icon_id;
|
|
|
|
}
|
|
|
|
|
2015-01-01 23:26:03 +11:00
|
|
|
int ui_id_icon_get(const bContext *C, ID *id, const bool 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 */
|
2015-05-11 16:29:12 +02:00
|
|
|
iconid = BKE_icon_id_ensure(id);
|
2009-06-27 01:15:31 +00:00
|
|
|
/* checks if not exists, or changed */
|
2015-01-12 14:44:54 +01:00
|
|
|
UI_id_icon_render(C, NULL, id, big, true);
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
2016-12-01 16:43:57 +01:00
|
|
|
case ID_SCR:
|
|
|
|
iconid = ui_id_screen_get_icon(C, id);
|
|
|
|
break;
|
2009-06-27 01:15:31 +00:00
|
|
|
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
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
{
|
|
|
|
ID *id = NULL;
|
|
|
|
|
|
|
|
if (!ptr->data)
|
|
|
|
return rnaicon;
|
|
|
|
|
|
|
|
/* try ID, material, texture or dynapaint slot */
|
|
|
|
if (RNA_struct_is_ID(ptr->type)) {
|
|
|
|
id = ptr->id.data;
|
|
|
|
}
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) {
|
|
|
|
id = RNA_pointer_get(ptr, "material").data;
|
|
|
|
}
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_TextureSlot)) {
|
|
|
|
id = RNA_pointer_get(ptr, "texture").data;
|
|
|
|
}
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) {
|
|
|
|
DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
|
|
|
|
|
|
|
|
if (surface->format == MOD_DPAINT_SURFACE_F_PTEX)
|
|
|
|
return ICON_TEXTURE_SHADED;
|
|
|
|
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX)
|
|
|
|
return ICON_OUTLINER_DATA_MESH;
|
|
|
|
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
|
|
|
|
return ICON_FILE_IMAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get icon from ID */
|
|
|
|
if (id) {
|
|
|
|
int icon = ui_id_icon_get(C, id, big);
|
|
|
|
|
|
|
|
return icon ? icon : rnaicon;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rnaicon;
|
|
|
|
}
|
|
|
|
|
2015-08-10 17:26:37 +02:00
|
|
|
int UI_idcode_icon_get(const int idcode)
|
|
|
|
{
|
|
|
|
switch (idcode) {
|
|
|
|
case ID_AC:
|
|
|
|
return ICON_ANIM_DATA;
|
|
|
|
case ID_AR:
|
|
|
|
return ICON_ARMATURE_DATA;
|
|
|
|
case ID_BR:
|
|
|
|
return ICON_BRUSH_DATA;
|
|
|
|
case ID_CA:
|
|
|
|
return ICON_CAMERA_DATA;
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
case ID_CF:
|
|
|
|
return ICON_FILE;
|
2015-08-10 17:26:37 +02:00
|
|
|
case ID_CU:
|
|
|
|
return ICON_CURVE_DATA;
|
|
|
|
case ID_GD:
|
|
|
|
return ICON_GREASEPENCIL;
|
|
|
|
case ID_GR:
|
|
|
|
return ICON_GROUP;
|
|
|
|
case ID_IM:
|
|
|
|
return ICON_IMAGE_DATA;
|
|
|
|
case ID_LA:
|
|
|
|
return ICON_LAMP_DATA;
|
|
|
|
case ID_LS:
|
|
|
|
return ICON_LINE_DATA;
|
|
|
|
case ID_LT:
|
|
|
|
return ICON_LATTICE_DATA;
|
|
|
|
case ID_MA:
|
|
|
|
return ICON_MATERIAL_DATA;
|
|
|
|
case ID_MB:
|
|
|
|
return ICON_META_DATA;
|
|
|
|
case ID_MC:
|
|
|
|
return ICON_CLIP;
|
|
|
|
case ID_ME:
|
|
|
|
return ICON_MESH_DATA;
|
|
|
|
case ID_MSK:
|
|
|
|
return ICON_MOD_MASK; /* TODO! this would need its own icon! */
|
|
|
|
case ID_NT:
|
|
|
|
return ICON_NODETREE;
|
|
|
|
case ID_OB:
|
|
|
|
return ICON_OBJECT_DATA;
|
2016-12-28 17:30:58 +01:00
|
|
|
case ID_PA:
|
|
|
|
return ICON_PARTICLE_DATA;
|
2015-08-10 17:26:37 +02:00
|
|
|
case ID_PAL:
|
|
|
|
return ICON_COLOR; /* TODO! this would need its own icon! */
|
|
|
|
case ID_PC:
|
|
|
|
return ICON_CURVE_BEZCURVE; /* TODO! this would need its own icon! */
|
2017-06-12 20:59:54 +10:00
|
|
|
case ID_LP:
|
2017-06-06 22:47:41 +02:00
|
|
|
return ICON_RADIO;
|
2015-08-10 17:26:37 +02:00
|
|
|
case ID_SCE:
|
|
|
|
return ICON_SCENE_DATA;
|
|
|
|
case ID_SPK:
|
|
|
|
return ICON_SPEAKER;
|
|
|
|
case ID_SO:
|
|
|
|
return ICON_SOUND;
|
|
|
|
case ID_TE:
|
|
|
|
return ICON_TEXTURE_DATA;
|
|
|
|
case ID_TXT:
|
|
|
|
return ICON_TEXT;
|
|
|
|
case ID_VF:
|
|
|
|
return ICON_FONT_DATA;
|
|
|
|
case ID_WO:
|
|
|
|
return ICON_WORLD_DATA;
|
|
|
|
default:
|
|
|
|
return ICON_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:13:47 +10:00
|
|
|
static void icon_draw_at_size(
|
|
|
|
float x, float y, int icon_id, float aspect, float alpha,
|
|
|
|
enum eIconSizes size, const bool nocreate)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2011-05-16 18:37:54 +00:00
|
|
|
int draw_size = get_draw_size(size);
|
2014-01-04 17:16:19 +11:00
|
|
|
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);
|
2014-01-04 17:16:19 +11:00
|
|
|
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
|
|
|
}
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* draws icon with dpi scale factor */
|
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
|
|
|
{
|
2012-12-13 01:21:12 +00:00
|
|
|
UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_FAC, 1.0f);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|
2017-02-22 16:02:43 +01:00
|
|
|
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
|
|
|
|
{
|
|
|
|
UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_FAC, 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
|
|
|
void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2014-01-04 17:16:19 +11: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
|
|
|
}
|
|
|
|
|
2015-05-25 22:06:25 +02:00
|
|
|
void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspect, float alpha, int size)
|
2008-11-25 18:27:41 +00:00
|
|
|
{
|
2015-05-25 22:06:25 +02:00
|
|
|
icon_draw_size(x, y, icon_id, aspect, alpha, NULL, ICON_SIZE_PREVIEW, size, false, true);
|
2008-11-25 18:27:41 +00:00
|
|
|
}
|
|
|
|
|