svn merge ^/trunk/blender -r49177:49186
This commit is contained in:
@@ -54,6 +54,14 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/* Only for debugging:
|
||||
* store original buffer's name when doing MEM_dupallocN
|
||||
* helpful to profile issues with non-freed "dup_alloc" buffers,
|
||||
* but this introduces some overhead to memory header and makes
|
||||
* things slower a bit, so betterto keep disabled by default
|
||||
*/
|
||||
//#define DEBUG_MEMDUPLINAME
|
||||
|
||||
/* Only for debugging:
|
||||
* lets you count the allocations so as to find the allocator of unfreed memory
|
||||
* in situations where the leak is predictable */
|
||||
@@ -96,6 +104,10 @@ typedef struct MemHead {
|
||||
#ifdef DEBUG_MEMCOUNTER
|
||||
int _count;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MEMDUPLINAME
|
||||
int need_free_name, pad;
|
||||
#endif
|
||||
} MemHead;
|
||||
|
||||
typedef struct MemTail {
|
||||
@@ -243,13 +255,36 @@ void *MEM_dupallocN(void *vmemh)
|
||||
if (vmemh) {
|
||||
MemHead *memh = vmemh;
|
||||
memh--;
|
||||
|
||||
|
||||
#ifndef DEBUG_MEMDUPLINAME
|
||||
if (memh->mmap)
|
||||
newp = MEM_mapallocN(memh->len, "dupli_mapalloc");
|
||||
else
|
||||
newp = MEM_mallocN(memh->len, "dupli_alloc");
|
||||
|
||||
if (newp == NULL) return NULL;
|
||||
#else
|
||||
{
|
||||
MemHead *nmemh;
|
||||
char *name = malloc(strlen(memh->name) + 24);
|
||||
|
||||
if (memh->mmap) {
|
||||
sprintf(name, "%s %s", "dupli_mapalloc", memh->name);
|
||||
newp = MEM_mapallocN(memh->len, name);
|
||||
}
|
||||
else {
|
||||
sprintf(name, "%s %s", "dupli_alloc", memh->name);
|
||||
newp = MEM_mallocN(memh->len, name);
|
||||
}
|
||||
|
||||
if (newp == NULL) return NULL;
|
||||
|
||||
nmemh = newp;
|
||||
nmemh--;
|
||||
|
||||
nmemh->need_free_name = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
memcpy(newp, vmemh, memh->len);
|
||||
}
|
||||
@@ -289,6 +324,10 @@ static void make_memhead_header(MemHead *memh, size_t len, const char *str)
|
||||
memh->len = len;
|
||||
memh->mmap = 0;
|
||||
memh->tag2 = MEMTAG2;
|
||||
|
||||
#ifdef DEBUG_MEMDUPLINAME
|
||||
memh->need_free_name = 0;
|
||||
#endif
|
||||
|
||||
memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + len);
|
||||
memt->tag3 = MEMTAG3;
|
||||
@@ -733,6 +772,11 @@ static void rem_memblock(MemHead *memh)
|
||||
totblock--;
|
||||
mem_in_use -= memh->len;
|
||||
|
||||
#ifdef DEBUG_MEMDUPLINAME
|
||||
if (memh->need_free_name)
|
||||
free((char *) memh->name);
|
||||
#endif
|
||||
|
||||
if (memh->mmap) {
|
||||
mmap_in_use -= memh->len;
|
||||
if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail)))
|
||||
|
||||
@@ -101,7 +101,6 @@ def operator_value_is_undo(value):
|
||||
return (isinstance(id_data, bpy.types.ID) and
|
||||
(not isinstance(id_data, (bpy.types.WindowManager,
|
||||
bpy.types.Screen,
|
||||
bpy.types.Scene,
|
||||
bpy.types.Brush,
|
||||
))))
|
||||
|
||||
|
||||
@@ -1533,8 +1533,8 @@ void BKE_mask_unlink(Main *bmain, Mask *mask)
|
||||
if (sl->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sc = (SpaceClip *) sl;
|
||||
|
||||
if (sc->mask == mask)
|
||||
sc->mask = NULL;
|
||||
if (sc->mask_info.mask == mask)
|
||||
sc->mask_info.mask = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5342,7 +5342,8 @@ static void lib_link_screen(FileData *fd, Main *main)
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
sima->image = newlibadr_us(fd, sc->id.lib, sima->image);
|
||||
|
||||
sima->mask_info.mask = newlibadr_us(fd, sc->id.lib, sima->mask_info.mask);
|
||||
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
@@ -5428,7 +5429,7 @@ static void lib_link_screen(FileData *fd, Main *main)
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
|
||||
sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
|
||||
sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask);
|
||||
sclip->mask_info.mask = newlibadr_us(fd, sc->id.lib, sclip->mask_info.mask);
|
||||
|
||||
sclip->scopes.track_search = NULL;
|
||||
sclip->scopes.track_preview = NULL;
|
||||
@@ -5717,7 +5718,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
|
||||
sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
|
||||
sclip->mask = restore_pointer_by_name(newmain, (ID *)sclip->mask, 1);
|
||||
sclip->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sclip->mask_info.mask, 1);
|
||||
|
||||
sclip->scopes.ok = 0;
|
||||
}
|
||||
|
||||
@@ -35,13 +35,22 @@ struct wmKeyConfig;
|
||||
struct MaskLayer;
|
||||
struct MaskLayerShape;
|
||||
|
||||
/* mask_editor.c */
|
||||
/* mask_edit.c */
|
||||
void ED_mask_size(const struct bContext *C, int *width, int *height);
|
||||
void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy);
|
||||
|
||||
void ED_operatortypes_mask(void);
|
||||
void ED_keymap_mask(struct wmKeyConfig *keyconf);
|
||||
void ED_operatormacros_mask(void);
|
||||
|
||||
/* mask_draw.c */
|
||||
void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type);
|
||||
void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar,
|
||||
const char draw_flag, const char draw_type,
|
||||
int width, int height,
|
||||
const short do_scale_applied, const short do_post_draw,
|
||||
float stabmat[4][4],
|
||||
const bContext *C);
|
||||
|
||||
/* mask_shapekey.c */
|
||||
void ED_mask_layer_shape_auto_key(struct MaskLayer *masklay, const int frame);
|
||||
|
||||
@@ -32,17 +32,21 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_mask.h"
|
||||
|
||||
#include "DNA_mask_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_object_types.h" /* SELECT */
|
||||
|
||||
#include "ED_mask.h" /* own include */
|
||||
#include "ED_space_api.h"
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "mask_intern.h" /* own include */
|
||||
|
||||
@@ -462,3 +466,73 @@ void ED_mask_draw(const bContext *C,
|
||||
|
||||
draw_masklays(mask, draw_flag, draw_type, width, height);
|
||||
}
|
||||
|
||||
/* sets up the opengl context.
|
||||
* width, height are to match the values from ED_mask_size() */
|
||||
void ED_mask_draw_region(Mask *mask, ARegion *ar,
|
||||
const char draw_flag, const char draw_type,
|
||||
int width, int height,
|
||||
const short do_scale_applied, const short do_post_draw,
|
||||
float stabmat[4][4], /* optional - only used by clip */
|
||||
const bContext *C /* optional - only used when do_post_draw is set */
|
||||
)
|
||||
{
|
||||
struct View2D *v2d = &ar->v2d;
|
||||
|
||||
int x, y;
|
||||
int w, h;
|
||||
float zoomx, zoomy;
|
||||
|
||||
/* frame image */
|
||||
float maxdim;
|
||||
float xofs, yofs;
|
||||
|
||||
/* find window pixel coordinates of origin */
|
||||
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
|
||||
|
||||
w = v2d->tot.xmax - v2d->tot.xmin;
|
||||
h = v2d->tot.ymax - v2d->tot.ymin;
|
||||
|
||||
zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin));
|
||||
zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin));
|
||||
|
||||
if (do_scale_applied) {
|
||||
zoomx /= width;
|
||||
zoomy /= height;
|
||||
}
|
||||
|
||||
x += v2d->tot.xmin * zoomx;
|
||||
y += v2d->tot.ymin * zoomy;
|
||||
|
||||
/* frame the image */
|
||||
maxdim = maxf(w, h);
|
||||
if (w == h) {
|
||||
xofs = yofs = 0;
|
||||
}
|
||||
else if (w < h) {
|
||||
xofs = ((h - w) / -2.0f) * zoomx;
|
||||
yofs = 0.0f;
|
||||
}
|
||||
else { /* (width > height) */
|
||||
xofs = 0.0f;
|
||||
yofs = ((w - h) / -2.0f) * zoomy;
|
||||
}
|
||||
|
||||
/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
|
||||
glPushMatrix();
|
||||
glTranslatef(x + xofs, y + yofs, 0);
|
||||
glScalef(maxdim * zoomx, maxdim * zoomy, 0);
|
||||
|
||||
if (stabmat) {
|
||||
glMultMatrixf(stabmat);
|
||||
}
|
||||
|
||||
/* draw! */
|
||||
draw_masklays(mask, draw_flag, draw_type, width, height);
|
||||
|
||||
if (do_post_draw) {
|
||||
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_mask.h" /* own include */
|
||||
#include "ED_image.h"
|
||||
#include "ED_object.h" /* ED_keymap_proportional_maskmode only */
|
||||
#include "ED_clip.h"
|
||||
#include "ED_sequencer.h"
|
||||
@@ -143,15 +144,25 @@ void ED_mask_size(const bContext *C, int *width, int *height)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacedata.first) {
|
||||
if (sa->spacetype == SPACE_CLIP) {
|
||||
ED_space_clip_get_size(C, width, height);
|
||||
return;
|
||||
}
|
||||
else if (sa->spacetype == SPACE_SEQ) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
*width = (scene->r.size * scene->r.xsch) / 100;
|
||||
*height = (scene->r.size * scene->r.ysch) / 100;
|
||||
return;
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
ED_space_clip_get_size(C, width, height);
|
||||
return;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
*width = (scene->r.size * scene->r.xsch) / 100;
|
||||
*height = (scene->r.size * scene->r.ysch) / 100;
|
||||
return;
|
||||
}
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
ED_space_image_size(sima, width, height);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,6 @@ void ED_mask_select_flush_all(struct Mask *mask);
|
||||
int ED_maskedit_poll(struct bContext *C);
|
||||
int ED_maskedit_mask_poll(struct bContext *C);
|
||||
|
||||
void ED_mask_size(const struct bContext *C, int *width, int *height);
|
||||
void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy);
|
||||
|
||||
void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley);
|
||||
void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);
|
||||
|
||||
|
||||
@@ -2836,18 +2836,14 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh
|
||||
BMO_op_callf(bm_old, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
|
||||
"delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES);
|
||||
|
||||
/* clean up any loose edges */
|
||||
/* deselect loose data - this used to get deleted */
|
||||
BM_ITER_MESH (e, &iter, bm_old, BM_EDGES_OF_MESH) {
|
||||
if (BM_edge_is_wire(e)) {
|
||||
BM_edge_kill(bm_old, e);
|
||||
}
|
||||
BM_edge_select_set(bm_old, e, FALSE);
|
||||
}
|
||||
|
||||
/* clean up any loose verts */
|
||||
BM_ITER_MESH (v, &iter, bm_old, BM_VERTS_OF_MESH) {
|
||||
if (BM_vert_edge_count(v) == 0) {
|
||||
BM_vert_kill(bm_old, v);
|
||||
}
|
||||
BM_vert_select_set(bm_old, v, FALSE);
|
||||
}
|
||||
|
||||
BM_mesh_normals_update(bm_new, FALSE);
|
||||
|
||||
@@ -1956,8 +1956,8 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
if (sc) {
|
||||
if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask) {
|
||||
MaskLayer *masklay = BKE_mask_layer_active(sc->mask);
|
||||
if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
|
||||
MaskLayer *masklay = BKE_mask_layer_active(sc->mask_info.mask);
|
||||
mask_to_keylist(&ads, masklay, &keys);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,8 +199,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
|
||||
clip_draw_curfra_label(sc, x, 8.0f);
|
||||
|
||||
/* movie clip animation */
|
||||
if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask) {
|
||||
MaskLayer *masklay = BKE_mask_layer_active(sc->mask);
|
||||
if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
|
||||
MaskLayer *masklay = BKE_mask_layer_active(sc->mask_info.mask);
|
||||
if (masklay) {
|
||||
MaskLayerShape *masklay_shape;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ int ED_space_clip_maskedit_mask_poll(bContext *C)
|
||||
if (clip) {
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
return sc->mask != NULL;
|
||||
return sc->mask_info.mask != NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,14 +509,14 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
|
||||
|
||||
Mask *ED_space_clip_get_mask(SpaceClip *sc)
|
||||
{
|
||||
return sc->mask;
|
||||
return sc->mask_info.mask;
|
||||
}
|
||||
|
||||
void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask)
|
||||
{
|
||||
sc->mask = mask;
|
||||
sc->mask_info.mask = mask;
|
||||
|
||||
if (sc->mask && sc->mask->id.us == 0) {
|
||||
if (sc->mask_info.mask && sc->mask_info.mask->id.us == 0) {
|
||||
sc->clip->id.us = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -772,8 +772,8 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
|
||||
return TRUE;
|
||||
}
|
||||
else if (CTX_data_equals(member, "edit_mask")) {
|
||||
if (sc->mask)
|
||||
CTX_data_id_pointer_set(result, &sc->mask->id);
|
||||
if (sc->mask_info.mask)
|
||||
CTX_data_id_pointer_set(result, &sc->mask_info.mask->id);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1083,50 +1083,6 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
}
|
||||
|
||||
static void clip_main_area_draw_mask(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
int x, y;
|
||||
int width, height;
|
||||
float zoomx, zoomy;
|
||||
|
||||
/* frame image */
|
||||
float maxdim;
|
||||
float xofs, yofs;
|
||||
|
||||
/* find window pixel coordinates of origin */
|
||||
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
|
||||
|
||||
ED_space_clip_get_size(C, &width, &height);
|
||||
ED_space_clip_get_zoom(C, &zoomx, &zoomy);
|
||||
|
||||
/* frame the image */
|
||||
maxdim = maxf(width, height);
|
||||
if (width == height) {
|
||||
xofs = yofs = 0;
|
||||
}
|
||||
else if (width < height) {
|
||||
xofs = ((height - width) / -2.0f) * zoomx;
|
||||
yofs = 0.0f;
|
||||
}
|
||||
else { /* (width > height) */
|
||||
xofs = 0.0f;
|
||||
yofs = ((width - height) / -2.0f) * zoomy;
|
||||
}
|
||||
|
||||
/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
|
||||
glPushMatrix();
|
||||
glTranslatef(x + xofs, y + yofs, 0);
|
||||
glScalef(maxdim * zoomx, maxdim * zoomy, 0);
|
||||
glMultMatrixf(sc->stabmat);
|
||||
|
||||
ED_mask_draw(C, sc->mask_draw_flag, sc->mask_draw_type);
|
||||
|
||||
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
static void clip_main_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
@@ -1164,7 +1120,19 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
|
||||
clip_draw_main(C, ar);
|
||||
|
||||
if (sc->mode == SC_MODE_MASKEDIT) {
|
||||
clip_main_area_draw_mask(C, ar);
|
||||
|
||||
Mask *mask = CTX_data_edit_mask(C);
|
||||
if (mask) {
|
||||
int width, height;
|
||||
ED_mask_size(C, &width, &height);
|
||||
ED_mask_draw_region(mask, ar,
|
||||
sc->mask_info.draw_flag, sc->mask_info.draw_type,
|
||||
width, height,
|
||||
TRUE, TRUE,
|
||||
sc->stabmat, C);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Grease Pencil */
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_mask_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
@@ -53,10 +54,12 @@
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_tessmesh.h"
|
||||
#include "BKE_sequencer.h"
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
#include "ED_mask.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
@@ -585,7 +588,6 @@ static void image_dropboxes(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -698,7 +700,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
}
|
||||
}
|
||||
|
||||
const char *image_context_dir[] = {"edit_image", NULL};
|
||||
const char *image_context_dir[] = {"edit_image", "edit_mask", NULL};
|
||||
|
||||
static int image_context(const bContext *C, const char *member, bContextDataResult *result)
|
||||
{
|
||||
@@ -711,7 +713,14 @@ static int image_context(const bContext *C, const char *member, bContextDataResu
|
||||
CTX_data_id_pointer_set(result, (ID *)ED_space_image(sima));
|
||||
return 1;
|
||||
}
|
||||
|
||||
else if (CTX_data_equals(member, "edit_mask")) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Mask *mask = BKE_sequencer_mask_get(scene); /* XXX */
|
||||
if (mask) {
|
||||
CTX_data_id_pointer_set(result, &mask->id);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -820,7 +829,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
/* we set view2d from own zoom and offset each time */
|
||||
image_main_area_set_view2d(sima, ar);
|
||||
|
||||
|
||||
/* we draw image in pixelspace */
|
||||
draw_image_main(C, ar);
|
||||
|
||||
@@ -841,6 +850,19 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
|
||||
/* draw Grease Pencil - screen space only */
|
||||
draw_image_grease_pencil((bContext *)C, 0);
|
||||
|
||||
{
|
||||
Mask *mask = BKE_sequencer_mask_get(scene); /* XXX */
|
||||
if (mask) {
|
||||
int width, height;
|
||||
ED_mask_size(C, &width, &height);
|
||||
ED_mask_draw_region(mask, ar,
|
||||
0, 0, /* TODO */
|
||||
width, height,
|
||||
TRUE, FALSE,
|
||||
NULL, C);
|
||||
}
|
||||
}
|
||||
|
||||
/* scrollers? */
|
||||
#if 0
|
||||
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
|
||||
@@ -802,61 +802,6 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val)
|
||||
else special_seq_update = NULL;
|
||||
}
|
||||
|
||||
static void sequencer_main_area_draw_mask(const bContext *C, Scene *scene, ARegion *ar)
|
||||
{
|
||||
Mask *mask = BKE_sequencer_mask_get(scene);
|
||||
|
||||
if (mask) {
|
||||
struct View2D *v2d = &ar->v2d;
|
||||
|
||||
int x, y;
|
||||
int width, height;
|
||||
float zoomx, zoomy;
|
||||
|
||||
/* frame image */
|
||||
float maxdim;
|
||||
float xofs, yofs;
|
||||
|
||||
/* find window pixel coordinates of origin */
|
||||
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
|
||||
|
||||
width = v2d->tot.xmax - v2d->tot.xmin;
|
||||
height = v2d->tot.ymax - v2d->tot.ymin;
|
||||
|
||||
zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin));
|
||||
zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin));
|
||||
|
||||
x += v2d->tot.xmin * zoomx;
|
||||
y += v2d->tot.ymin * zoomy;
|
||||
|
||||
/* frame the image */
|
||||
maxdim = maxf(width, height);
|
||||
if (width == height) {
|
||||
xofs = yofs = 0;
|
||||
}
|
||||
else if (width < height) {
|
||||
xofs = ((height - width) / -2.0f) * zoomx;
|
||||
yofs = 0.0f;
|
||||
}
|
||||
else { /* (width > height) */
|
||||
xofs = 0.0f;
|
||||
yofs = ((width - height) / -2.0f) * zoomy;
|
||||
}
|
||||
|
||||
/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
|
||||
glPushMatrix();
|
||||
glTranslatef(x + xofs, y + yofs, 0);
|
||||
glScalef(maxdim * zoomx, maxdim * zoomy, 0);
|
||||
|
||||
ED_mask_draw((bContext *)C, 0, 0); // sc->mask_draw_flag, sc->mask_draw_type
|
||||
|
||||
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
|
||||
{
|
||||
struct Main *bmain = CTX_data_main(C);
|
||||
@@ -1064,7 +1009,17 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
|
||||
|
||||
//if (sc->mode == SC_MODE_MASKEDIT) {
|
||||
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
|
||||
sequencer_main_area_draw_mask(C, scene, ar);
|
||||
Mask *mask = BKE_sequencer_mask_get(scene);
|
||||
|
||||
if (mask) {
|
||||
int width, height;
|
||||
ED_mask_size(C, &width, &height);
|
||||
ED_mask_draw_region(mask, ar,
|
||||
0, 0, /* TODO */
|
||||
width, height,
|
||||
FALSE, TRUE,
|
||||
NULL, C);
|
||||
}
|
||||
}
|
||||
|
||||
if (cache_handle)
|
||||
|
||||
@@ -516,6 +516,15 @@ typedef enum eSpaceSeq_Proxy_RenderSize {
|
||||
SEQ_PROXY_RENDER_SIZE_FULL = 100
|
||||
} eSpaceSeq_Proxy_RenderSize;
|
||||
|
||||
typedef struct MaskSpaceInfo
|
||||
{
|
||||
/* **** mask editing **** */
|
||||
struct Mask *mask;
|
||||
/* draw options */
|
||||
char draw_flag;
|
||||
char draw_type;
|
||||
char pad3[6];
|
||||
} MaskSpaceInfo;
|
||||
|
||||
/* File Selector ========================================== */
|
||||
|
||||
@@ -693,6 +702,8 @@ typedef struct SpaceImage {
|
||||
char dt_uvstretch;
|
||||
char around;
|
||||
|
||||
MaskSpaceInfo mask_info;
|
||||
|
||||
/* **** color management **** */
|
||||
ColorManagedViewSettings view_settings;
|
||||
} SpaceImage;
|
||||
@@ -1021,12 +1032,7 @@ typedef struct SpaceClip {
|
||||
|
||||
int around, pad4; /* pivot point for transforms */
|
||||
|
||||
/* **** mask editing **** */
|
||||
struct Mask *mask;
|
||||
/* draw options */
|
||||
char mask_draw_flag;
|
||||
char mask_draw_type;
|
||||
char pad3[6];
|
||||
MaskSpaceInfo mask_info;
|
||||
|
||||
/* **** color management **** */
|
||||
ColorManagedViewSettings view_settings;
|
||||
|
||||
@@ -1104,6 +1104,31 @@ static void rna_def_space(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Type", "Space data type");
|
||||
}
|
||||
|
||||
/* for all spaces that use a mask */
|
||||
void mask_space_info(StructRNA *srna, int noteflag, const char *mask_set_func)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "mask_info.mask");
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Mask", "Mask displayed and edited in this space");
|
||||
RNA_def_property_pointer_funcs(prop, NULL, mask_set_func, NULL, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
|
||||
|
||||
/* mask drawing */
|
||||
prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "mask_info.draw_type");
|
||||
RNA_def_property_enum_items(prop, dt_uv_items);
|
||||
RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for mask splines");
|
||||
RNA_def_property_update(prop, noteflag, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_mask_smooth", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "mask_info.draw_flag", MASK_DRAWFLAG_SMOOTH);
|
||||
RNA_def_property_ui_text(prop, "Draw Smooth Splines", "");
|
||||
RNA_def_property_update(prop, noteflag, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_space_image_uv(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@@ -1221,6 +1246,9 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
|
||||
RNA_def_property_enum_items(prop, pivot_items);
|
||||
RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
|
||||
/* mask */
|
||||
mask_space_info(srna, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_space_outliner(BlenderRNA *brna)
|
||||
@@ -3080,24 +3108,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
|
||||
|
||||
/* mask */
|
||||
prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Mask", "Mask displayed and edited in this space");
|
||||
RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceClipEditor_mask_set", NULL, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
|
||||
|
||||
/* mask drawing */
|
||||
prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "mask_draw_type");
|
||||
RNA_def_property_enum_items(prop, dt_uv_items);
|
||||
RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for mask splines");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_mask_smooth", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "mask_draw_flag", MASK_DRAWFLAG_SMOOTH);
|
||||
RNA_def_property_ui_text(prop, "Draw Smooth Splines", "");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
|
||||
|
||||
mask_space_info(srna, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_mask_set");
|
||||
|
||||
/* mode */
|
||||
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
|
||||
|
||||
Reference in New Issue
Block a user