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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-06-04 14:55:05 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-06-04 14:55:05 +0400
commit0747e75cc604e73610427fcf8817a2c9eeb74bbc (patch)
tree685404fb3feaf08fac186945b0dbe3c3c05b77e7 /source/blender/blenkernel
parentefaeeaf15b4a5e1a404fbe51be922d1f245b5d65 (diff)
parent0f2b4d4dff0ee17933571cd2f572670ea2770c86 (diff)
Merging r47382 through r47398 from trunk into soc-2011-tomato
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_image.h5
-rw-r--r--source/blender/blenkernel/BKE_paint.h2
-rw-r--r--source/blender/blenkernel/intern/image.c80
-rw-r--r--source/blender/blenkernel/intern/paint.c49
4 files changed, 135 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 91e3e9edbf0..ac3daef77f7 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -44,6 +44,7 @@ struct anim;
struct Scene;
struct Object;
struct ImageFormatData;
+struct Main;
/* call from library */
void BKE_image_free(struct Image *me);
@@ -143,6 +144,9 @@ struct Image *BKE_image_add_from_imbuf(struct ImBuf *ibuf);
/* for reload, refresh, pack */
void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal);
+void BKE_image_walk_all_users(const struct Main *mainp, void *customdata,
+ void callback(struct Image *ima, struct ImageUser *iuser, void *customdata));
+
/* ensures an Image exists for viewing nodes or render */
struct Image *BKE_image_verify_viewer(int type, const char *name);
@@ -151,6 +155,7 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf);
/* called on frame change or before render */
void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
+void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr);
/* sets index offset for multilayer files */
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index b32b7145ff4..419fb4cedae 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -32,6 +32,7 @@
* \ingroup bke
*/
+struct bContext;
struct Brush;
struct MDisps;
struct MeshElemMap;
@@ -55,6 +56,7 @@ void free_paint(struct Paint *p);
void copy_paint(struct Paint *src, struct Paint *tar);
struct Paint *paint_get_active(struct Scene *sce);
+struct Paint *paint_get_active_from_context(const struct bContext *C);
struct Brush *paint_brush(struct Paint *paint);
void paint_brush_set(struct Paint *paint, struct Brush *br);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index a2b1fb10500..3748a474ddd 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -91,6 +91,14 @@
#include "BLO_sys_types.h" // for intptr_t support
+/* for image user iteration */
+#include "DNA_node_types.h"
+#include "DNA_space_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_view3d_types.h"
+
+#include "WM_api.h"
+
/* max int, to indicate we don't store sequences in ibuf */
#define IMA_NO_INDEX 0x7FEFEFEF
@@ -1814,6 +1822,65 @@ void BKE_image_assign_ibuf(Image *ima, ImBuf *ibuf)
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
}
+void BKE_image_walk_all_users(const Main *mainp, void *customdata,
+ void callback(Image *ima, ImageUser *iuser, void *customdata))
+{
+ wmWindowManager *wm;
+ wmWindow *win;
+ Tex *tex;
+
+ /* texture users */
+ for (tex = mainp->tex.first; tex; tex = tex->id.next) {
+ if (tex->type == TEX_IMAGE && tex->ima) {
+ if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+ callback(tex->ima, &tex->iuser, customdata);
+ }
+ }
+ }
+
+ /* image window, compo node users */
+ for (wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
+ for (win = wm->windows.first; win; win = win->next) {
+ ScrArea *sa;
+ for (sa = win->screen->areabase.first; sa; sa = sa->next) {
+ if (sa->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = sa->spacedata.first;
+ BGpic *bgpic;
+ for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
+ callback(bgpic->ima, &bgpic->iuser, customdata);
+ }
+ }
+ else if (sa->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = sa->spacedata.first;
+ callback(sima->image, &sima->iuser, customdata);
+ }
+ else if (sa->spacetype == SPACE_NODE) {
+ SpaceNode *snode = sa->spacedata.first;
+ if ((snode->treetype == NTREE_COMPOSIT) && (snode->nodetree)) {
+ bNode *node;
+ for (node = snode->nodetree->nodes.first; node; node = node->next) {
+ if (node->id && node->type == CMP_NODE_IMAGE) {
+ Image *ima = (Image *)node->id;
+ ImageUser *iuser = node->storage;
+ callback(ima, iuser, customdata);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+static void image_tag_frame_recalc(Image *ima, ImageUser *iuser, void *customdata)
+{
+ Image *changed_image = customdata;
+
+ if (ima == changed_image) {
+ iuser->flag |= IMA_NEED_FRAME_RECALC;
+ }
+}
+
void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
{
if (ima == NULL)
@@ -1847,6 +1914,9 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
ima->ok = 1;
if (iuser)
iuser->ok = 1;
+
+ BKE_image_walk_all_users(G.main, ima, image_tag_frame_recalc);
+
break;
case IMA_SIGNAL_RELOAD:
@@ -2669,6 +2739,15 @@ void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
if (iuser->ok == 0) iuser->ok = 1;
}
+void BKE_image_user_check_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
+{
+ if ((iuser->flag & IMA_ANIM_ALWAYS) || (iuser->flag & IMA_NEED_FRAME_RECALC)) {
+ BKE_image_user_frame_calc(iuser, cfra, fieldnr);
+
+ iuser->flag &= ~IMA_NEED_FRAME_RECALC;
+ }
+}
+
int BKE_image_has_alpha(struct Image *image)
{
ImBuf *ibuf;
@@ -2684,4 +2763,3 @@ int BKE_image_has_alpha(struct Image *image)
else
return 0;
}
-
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index c7f904755d9..f7e3e103e99 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -41,6 +41,7 @@
#include "BLI_utildefines.h"
#include "BKE_brush.h"
+#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_paint.h"
#include "BKE_subsurf.h"
@@ -83,6 +84,54 @@ Paint *paint_get_active(Scene *sce)
return NULL;
}
+Paint *paint_get_active_from_context(const bContext *C)
+{
+ Scene *sce = CTX_data_scene(C);
+
+ if (sce) {
+ ToolSettings *ts = sce->toolsettings;
+ Object *obact = NULL;
+
+ if (sce->basact && sce->basact->object)
+ obact = sce->basact->object;
+
+ if (CTX_wm_space_image(C) != NULL) {
+ if (obact->mode == OB_MODE_EDIT) {
+ if (ts->use_uv_sculpt)
+ return &ts->uvsculpt->paint;
+ else
+ return &ts->imapaint.paint;
+ }
+ else {
+ return &ts->imapaint.paint;
+ }
+ }
+ else if (obact) {
+ switch (obact->mode) {
+ case OB_MODE_SCULPT:
+ return &ts->sculpt->paint;
+ case OB_MODE_VERTEX_PAINT:
+ return &ts->vpaint->paint;
+ case OB_MODE_WEIGHT_PAINT:
+ return &ts->wpaint->paint;
+ case OB_MODE_TEXTURE_PAINT:
+ return &ts->imapaint.paint;
+ case OB_MODE_EDIT:
+ if (ts->use_uv_sculpt)
+ return &ts->uvsculpt->paint;
+ else
+ return &ts->imapaint.paint;
+ }
+ }
+ else {
+ /* default to image paint */
+ return &ts->imapaint.paint;
+ }
+ }
+
+ return NULL;
+}
+
Brush *paint_brush(Paint *p)
{
return p ? p->brush : NULL;