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:
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c45
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c221
5 files changed, 270 insertions, 9 deletions
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index dd5fbb92171..c1f7fc942e4 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -44,6 +44,7 @@ set(SRC
sequencer_ops.c
sequencer_scopes.c
sequencer_select.c
+ sequencer_view.c
space_sequencer.c
sequencer_intern.h
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 25514b3168b..d6a2b0a001e 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -811,6 +811,41 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val)
else special_seq_update = NULL;
}
+ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs)
+{
+ SeqRenderData context;
+ ImBuf *ibuf;
+ int rectx, recty;
+ float render_size = 0.0;
+ float proxy_size = 100.0;
+
+ render_size = sseq->render_size;
+ if (render_size == 0) {
+ render_size = scene->r.size;
+ }
+ else {
+ proxy_size = render_size;
+ }
+
+ if (render_size < 0) {
+ return NULL;
+ }
+
+ rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f;
+ recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
+
+ context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size);
+
+ if (special_seq_update)
+ ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update);
+ else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
+ ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown);
+ else
+ ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown);
+
+ return ibuf;
+}
+
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
{
struct Main *bmain = CTX_data_main(C);
@@ -824,7 +859,6 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
float col[3];
GLuint texid;
GLuint last_texid;
- SeqRenderData context;
render_size = sseq->render_size;
if (render_size == 0) {
@@ -865,14 +899,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (G.is_rendering)
return;
- context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size);
-
- if (special_seq_update)
- ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update);
- else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
- ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown);
- else
- ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown);
+ ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs);
if (ibuf == NULL)
return;
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 4ee9c6710bc..81ee9927cb6 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -44,6 +44,7 @@ struct ScrArea;
struct ARegion;
struct ARegionType;
struct Scene;
+struct Main;
/* space_sequencer.c */
struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
@@ -55,6 +56,8 @@ void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegi
void seq_reset_imageofs(struct SpaceSeq *sseq);
+struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs);
+
/* sequencer_edit.c */
struct View2D;
void seq_rectf(struct Sequence *seq, struct rctf *rectf);
@@ -181,5 +184,8 @@ void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot);
void SEQUENCER_OT_strip_modifier_remove(struct wmOperatorType *ot);
void SEQUENCER_OT_strip_modifier_move(struct wmOperatorType *ot);
+/* sequencer_view.c */
+void SEQUENCER_OT_sample(struct wmOperatorType *ot);
+
#endif /* __SEQUENCER_INTERN_H__ */
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 960ae502126..aa6bacf8836 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -118,6 +118,9 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_strip_modifier_add);
WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove);
WM_operatortype_append(SEQUENCER_OT_strip_modifier_move);
+
+ /* sequencer_view.h */
+ WM_operatortype_append(SEQUENCER_OT_sample);
}
@@ -335,6 +338,9 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
#endif
+
+ /* sample */
+ WM_keymap_add_item(keymap, "SEQUENCER_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0);
}
void ED_operatormacros_sequencer(void)
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
new file mode 100644
index 00000000000..fa39003bd55
--- /dev/null
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -0,0 +1,221 @@
+/*
+ * ***** 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,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation,
+ * Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+/** \file blender/editors/space_sequencer/sequencer_modifier.c
+ * \ingroup spseq
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "DNA_scene_types.h"
+
+#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_sequencer.h"
+#include "BKE_screen.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_image.h"
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "UI_view2d.h"
+
+/* own include */
+#include "sequencer_intern.h"
+
+/******************** sample backdrop operator ********************/
+
+typedef struct ImageSampleInfo {
+ ARegionType *art;
+ void *draw_handle;
+ int x, y;
+ int channels;
+
+ unsigned char col[4];
+ float colf[4];
+
+ unsigned char *colp;
+ float *colfp;
+
+ int draw;
+} ImageSampleInfo;
+
+static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
+{
+ Scene *scene = CTX_data_scene(C);
+ ImageSampleInfo *info = arg_info;
+
+ if (info->draw) {
+ ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+ info->x, info->y, info->col, info->colf, NULL, NULL);
+ }
+}
+
+static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C);
+ ARegion *ar = CTX_wm_region(C);
+ ImBuf *ibuf = sequencer_ibuf_get(bmain, scene, sseq, CFRA, 0);
+ ImageSampleInfo *info = op->customdata;
+ float fx, fy;
+
+ if (ibuf == NULL) {
+ IMB_freeImBuf(ibuf);
+ info->draw = 0;
+ return;
+ }
+
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
+
+ fx += (float) ibuf->x / 2.0f;
+ fy += (float) ibuf->y / 2.0f;
+
+ if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
+ float *fp;
+ unsigned char *cp;
+ int x = (int) fx, y = (int) fy;
+
+ info->x = x;
+ info->y = y;
+ info->draw = 1;
+ info->channels = ibuf->channels;
+
+ info->colp = NULL;
+ info->colfp = NULL;
+
+ if (ibuf->rect) {
+ cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+
+ info->col[0] = cp[0];
+ info->col[1] = cp[1];
+ info->col[2] = cp[2];
+ info->col[3] = cp[3];
+ info->colp = info->col;
+
+ info->colf[0] = (float)cp[0] / 255.0f;
+ info->colf[1] = (float)cp[1] / 255.0f;
+ info->colf[2] = (float)cp[2] / 255.0f;
+ info->colf[3] = (float)cp[3] / 255.0f;
+ info->colfp = info->colf;
+ }
+ if (ibuf->rect_float) {
+ fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
+
+ info->colf[0] = fp[0];
+ info->colf[1] = fp[1];
+ info->colf[2] = fp[2];
+ info->colf[3] = fp[3];
+ info->colfp = info->colf;
+ }
+ }
+ else {
+ info->draw = 0;
+ }
+
+ IMB_freeImBuf(ibuf);
+ ED_area_tag_redraw(CTX_wm_area(C));
+}
+
+static void sample_exit(bContext *C, wmOperator *op)
+{
+ ImageSampleInfo *info = op->customdata;
+
+ ED_region_draw_cb_exit(info->art, info->draw_handle);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ MEM_freeN(info);
+}
+
+static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ ImageSampleInfo *info;
+
+ info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
+ info->art = ar->type;
+ info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
+ op->customdata = info;
+
+ sample_apply(C, op, event);
+
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sample_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ switch (event->type) {
+ case LEFTMOUSE:
+ case RIGHTMOUSE: /* XXX hardcoded */
+ sample_exit(C, op);
+ return OPERATOR_CANCELLED;
+ case MOUSEMOVE:
+ sample_apply(C, op, event);
+ break;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sample_cancel(bContext *C, wmOperator *op)
+{
+ sample_exit(C, op);
+
+ return OPERATOR_CANCELLED;
+}
+
+int sample_poll(bContext *C)
+{
+ return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL;
+}
+
+void SEQUENCER_OT_sample(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Sample Color";
+ ot->idname = "SEQUENCER_OT_sample";
+ ot->description = "Use mouse to sample color in current frame";
+
+ /* api callbacks */
+ ot->invoke = sample_invoke;
+ ot->modal = sample_modal;
+ ot->cancel = sample_cancel;
+ ot->poll = sample_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_BLOCKING;
+}