2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-01-07 17:25:17 +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.
|
2009-01-07 17:25:17 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
* Making screendumps.
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/screen/screendump.c
|
|
|
|
* \ingroup edscr
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-01-07 17:25:17 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-01-07 17:25:17 +00:00
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
2010-01-21 10:28:19 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2009-01-07 17:25:17 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_global.h"
|
2010-10-18 06:41:16 +00:00
|
|
|
#include "BKE_main.h"
|
2009-01-07 17:25:17 +00:00
|
|
|
#include "BKE_image.h"
|
2009-12-22 12:01:32 +00:00
|
|
|
#include "BKE_report.h"
|
2009-02-14 18:31:19 +00:00
|
|
|
#include "BKE_writeavi.h"
|
2009-01-07 17:25:17 +00:00
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
2009-01-07 17:25:17 +00:00
|
|
|
#include "WM_types.h"
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
|
|
#include "ED_screen_types.h"
|
|
|
|
|
|
|
|
#include "screen_intern.h"
|
2009-01-07 17:25:17 +00:00
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
typedef struct ScreenshotData {
|
|
|
|
unsigned int *dumprect;
|
|
|
|
int dumpsx, dumpsy;
|
2011-12-05 16:37:31 +00:00
|
|
|
rcti crop;
|
2009-02-14 16:43:02 +00:00
|
|
|
} ScreenshotData;
|
2009-01-07 17:25:17 +00:00
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
/* get shot from frontbuffer */
|
2011-12-05 16:37:31 +00:00
|
|
|
static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy)
|
2009-01-07 17:25:17 +00:00
|
|
|
{
|
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
int x=0, y=0;
|
2009-02-14 16:43:02 +00:00
|
|
|
unsigned int *dumprect= NULL;
|
2009-01-07 17:25:17 +00:00
|
|
|
|
2011-12-05 16:37:31 +00:00
|
|
|
x= 0;
|
|
|
|
y= 0;
|
|
|
|
*dumpsx= win->sizex;
|
|
|
|
*dumpsy= win->sizey;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
|
|
|
if (*dumpsx && *dumpsy) {
|
2009-01-07 17:25:17 +00:00
|
|
|
|
2010-03-06 18:21:57 +00:00
|
|
|
dumprect= MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
|
2009-01-07 17:25:17 +00:00
|
|
|
glReadBuffer(GL_FRONT);
|
2009-02-14 16:43:02 +00:00
|
|
|
glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
|
2009-01-07 17:25:17 +00:00
|
|
|
glFinish();
|
|
|
|
glReadBuffer(GL_BACK);
|
|
|
|
}
|
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
return dumprect;
|
|
|
|
}
|
|
|
|
|
2011-05-19 11:13:35 +00:00
|
|
|
/* call from both exec and invoke */
|
|
|
|
static int screenshot_data_create(bContext *C, wmOperator *op)
|
2009-02-14 16:43:02 +00:00
|
|
|
{
|
|
|
|
unsigned int *dumprect;
|
|
|
|
int dumpsx, dumpsy;
|
2011-12-05 16:37:31 +00:00
|
|
|
|
|
|
|
/* do redraw so we don't show popups/menus */
|
|
|
|
WM_redraw_windows(C);
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2011-12-05 16:37:31 +00:00
|
|
|
dumprect= screenshot(C, &dumpsx, &dumpsy);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (dumprect) {
|
2009-02-14 16:43:02 +00:00
|
|
|
ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot");
|
2011-12-05 16:37:31 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
2009-02-14 16:43:02 +00:00
|
|
|
|
|
|
|
scd->dumpsx= dumpsx;
|
|
|
|
scd->dumpsy= dumpsy;
|
|
|
|
scd->dumprect= dumprect;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa)
|
2011-12-05 16:37:31 +00:00
|
|
|
scd->crop= sa->totrct;
|
2009-02-14 16:43:02 +00:00
|
|
|
op->customdata= scd;
|
2011-12-05 16:37:31 +00:00
|
|
|
|
2011-05-19 11:13:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
op->customdata= NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void screenshot_data_free(wmOperator *op)
|
|
|
|
{
|
|
|
|
ScreenshotData *scd= op->customdata;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scd) {
|
|
|
|
if (scd->dumprect)
|
2011-05-19 11:13:35 +00:00
|
|
|
MEM_freeN(scd->dumprect);
|
|
|
|
MEM_freeN(scd);
|
|
|
|
op->customdata= NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-05 16:37:31 +00:00
|
|
|
static void screenshot_crop(ImBuf *ibuf, rcti crop)
|
|
|
|
{
|
|
|
|
unsigned int *to= ibuf->rect;
|
|
|
|
unsigned int *from= ibuf->rect + crop.ymin*ibuf->x + crop.xmin;
|
|
|
|
int y, cropw= crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cropw > 0 && croph > 0) {
|
|
|
|
for (y=0; y<croph; y++, to+=cropw, from+=ibuf->x)
|
2011-12-05 16:37:31 +00:00
|
|
|
memmove(to, from, sizeof(unsigned int)*cropw);
|
|
|
|
|
|
|
|
ibuf->x= cropw;
|
|
|
|
ibuf->y= croph;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-19 11:13:35 +00:00
|
|
|
static int screenshot_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
ScreenshotData *scd= op->customdata;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scd == NULL) {
|
2011-05-19 11:13:35 +00:00
|
|
|
/* when running exec directly */
|
|
|
|
screenshot_data_create(C, op);
|
|
|
|
scd= op->customdata;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scd) {
|
|
|
|
if (scd->dumprect) {
|
2011-05-19 11:13:35 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
ImBuf *ibuf;
|
|
|
|
char path[FILE_MAX];
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "filepath", path);
|
|
|
|
|
2011-10-19 23:10:54 +00:00
|
|
|
BLI_strncpy(G.ima, path, sizeof(G.ima));
|
2011-05-19 11:13:35 +00:00
|
|
|
BLI_path_abs(path, G.main->name);
|
|
|
|
|
|
|
|
/* BKE_add_image_extension() checks for if extension was already set */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->r.scemode & R_EXTENSION)
|
|
|
|
if (strlen(path)<FILE_MAX-5)
|
2011-11-21 20:19:58 +00:00
|
|
|
BKE_add_image_extension(path, scene->r.im_format.imtype);
|
2011-05-19 11:13:35 +00:00
|
|
|
|
|
|
|
ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
|
|
|
|
ibuf->rect= scd->dumprect;
|
|
|
|
|
2011-12-05 16:37:31 +00:00
|
|
|
/* crop to show only single editor */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!RNA_boolean_get(op->ptr, "full"))
|
2011-12-05 16:37:31 +00:00
|
|
|
screenshot_crop(ibuf, scd->crop);
|
|
|
|
|
2011-11-21 20:19:58 +00:00
|
|
|
BKE_write_ibuf(ibuf, path, &scene->r.im_format);
|
2011-05-19 11:13:35 +00:00
|
|
|
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
screenshot_data_free(op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (screenshot_data_create(C, op)) {
|
|
|
|
if (RNA_struct_property_is_set(op->ptr, "filepath"))
|
2009-02-14 16:43:02 +00:00
|
|
|
return screenshot_exec(C, op);
|
|
|
|
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(op->ptr, "filepath", G.ima);
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2009-02-18 13:29:54 +00:00
|
|
|
WM_event_add_fileselect(C, op);
|
2009-02-14 16:43:02 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2011-01-04 14:37:21 +00:00
|
|
|
static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
|
|
|
|
{
|
2011-05-19 11:13:35 +00:00
|
|
|
screenshot_data_free(op);
|
2011-01-04 14:37:21 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2009-02-14 16:43:02 +00:00
|
|
|
|
|
|
|
void SCREEN_OT_screenshot(wmOperatorType *ot)
|
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */
|
|
|
|
ot->idname = "SCREEN_OT_screenshot";
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = screenshot_invoke;
|
|
|
|
ot->exec = screenshot_exec;
|
|
|
|
ot->poll = WM_operator_winactive;
|
|
|
|
ot->cancel = screenshot_cancel;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-01-24 18:18:51 +00:00
|
|
|
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
|
2011-12-05 22:19:30 +00:00
|
|
|
RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
|
2009-02-14 16:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *************** screenshot movie job ************************* */
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
typedef struct ScreenshotJob {
|
2011-11-20 14:38:11 +00:00
|
|
|
Main *bmain;
|
2009-02-14 18:31:19 +00:00
|
|
|
Scene *scene;
|
2009-02-14 16:43:02 +00:00
|
|
|
unsigned int *dumprect;
|
2009-02-14 18:31:19 +00:00
|
|
|
int x, y, dumpsx, dumpsy;
|
2009-02-14 16:43:02 +00:00
|
|
|
short *stop;
|
|
|
|
short *do_update;
|
2009-12-22 12:01:32 +00:00
|
|
|
ReportList reports;
|
2009-02-14 16:43:02 +00:00
|
|
|
} ScreenshotJob;
|
|
|
|
|
|
|
|
|
|
|
|
static void screenshot_freejob(void *sjv)
|
|
|
|
{
|
|
|
|
ScreenshotJob *sj= sjv;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sj->dumprect)
|
2009-02-14 18:31:19 +00:00
|
|
|
MEM_freeN(sj->dumprect);
|
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
MEM_freeN(sj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* called before redraw notifiers, copies a new dumprect */
|
|
|
|
static void screenshot_updatejob(void *sjv)
|
|
|
|
{
|
|
|
|
ScreenshotJob *sj= sjv;
|
2009-02-14 18:31:19 +00:00
|
|
|
unsigned int *dumprect;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sj->dumprect==NULL) {
|
2009-02-14 18:31:19 +00:00
|
|
|
dumprect= MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect");
|
|
|
|
glReadPixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
|
|
|
|
glFinish();
|
|
|
|
|
|
|
|
sj->dumprect= dumprect;
|
|
|
|
}
|
2009-02-14 16:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* only this runs inside thread */
|
2010-10-14 12:24:08 +00:00
|
|
|
static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *UNUSED(progress))
|
2009-02-14 16:43:02 +00:00
|
|
|
{
|
|
|
|
ScreenshotJob *sj= sjv;
|
2009-02-14 18:31:19 +00:00
|
|
|
RenderData rd= sj->scene->r;
|
2011-11-21 20:19:58 +00:00
|
|
|
bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype);
|
2009-02-14 18:31:19 +00:00
|
|
|
|
|
|
|
/* we need this as local variables for renderdata */
|
2010-01-21 10:28:19 +00:00
|
|
|
rd.frs_sec= U.scrcastfps;
|
2009-02-14 18:31:19 +00:00
|
|
|
rd.frs_sec_base= 1.0f;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BKE_imtype_is_movie(rd.im_format.imtype)) {
|
|
|
|
if (!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) {
|
2009-12-22 12:01:32 +00:00
|
|
|
printf("screencast job stopped\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2009-02-14 18:31:19 +00:00
|
|
|
else
|
|
|
|
mh= NULL;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
|
|
|
sj->stop= stop;
|
|
|
|
sj->do_update= do_update;
|
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
*do_update= 1; // wait for opengl rect
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
while (*stop==0) {
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sj->dumprect) {
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mh) {
|
|
|
|
if (mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect,
|
2012-01-13 09:20:13 +00:00
|
|
|
sj->dumpsx, sj->dumpsy, &sj->reports))
|
|
|
|
{
|
2012-01-05 18:03:48 +00:00
|
|
|
BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra);
|
|
|
|
printf("Appended frame %d\n", rd.cfra);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-12-22 12:01:32 +00:00
|
|
|
break;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2009-02-14 18:31:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-11-21 20:19:58 +00:00
|
|
|
ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0);
|
2011-11-26 04:07:38 +00:00
|
|
|
char name[FILE_MAX];
|
2009-02-14 18:31:19 +00:00
|
|
|
int ok;
|
|
|
|
|
2012-01-05 18:03:48 +00:00
|
|
|
BKE_makepicstring(name, rd.pic, sj->bmain->name, rd.cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE);
|
2009-02-14 18:31:19 +00:00
|
|
|
|
|
|
|
ibuf->rect= sj->dumprect;
|
2011-11-21 20:19:58 +00:00
|
|
|
ok= BKE_write_ibuf(ibuf, name, &rd.im_format);
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ok==0) {
|
2009-02-14 18:31:19 +00:00
|
|
|
printf("Write error: cannot save %s\n", name);
|
2010-01-22 06:48:29 +00:00
|
|
|
BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name);
|
2009-02-14 18:31:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-01-22 06:48:29 +00:00
|
|
|
else {
|
|
|
|
printf("Saved file: %s\n", name);
|
|
|
|
BKE_reportf(&sj->reports, RPT_INFO, "Saved file: %s", name);
|
|
|
|
}
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* imbuf knows which rects are not part of ibuf */
|
2009-02-14 18:31:19 +00:00
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(sj->dumprect);
|
|
|
|
sj->dumprect= NULL;
|
|
|
|
|
|
|
|
*do_update= 1;
|
|
|
|
|
2012-01-05 18:03:48 +00:00
|
|
|
rd.cfra++;
|
2010-01-21 10:28:19 +00:00
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-21 10:28:19 +00:00
|
|
|
PIL_sleep_ms(U.scrcastwait);
|
2009-02-14 18:31:19 +00:00
|
|
|
}
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mh)
|
2009-02-14 18:31:19 +00:00
|
|
|
mh->end_movie();
|
2010-01-22 06:48:29 +00:00
|
|
|
|
|
|
|
BKE_report(&sj->reports, RPT_INFO, "Screencast job stopped");
|
2009-01-07 17:25:17 +00:00
|
|
|
}
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
static int screencast_exec(bContext *C, wmOperator *op)
|
2009-02-14 16:43:02 +00:00
|
|
|
{
|
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
2010-05-27 08:22:16 +00:00
|
|
|
wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0);
|
2009-02-14 16:43:02 +00:00
|
|
|
ScreenshotJob *sj= MEM_callocN(sizeof(ScreenshotJob), "screenshot job");
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
/* setup sj */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_boolean_get(op->ptr, "full")) {
|
2009-02-14 18:31:19 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
sj->x= 0;
|
|
|
|
sj->y= 0;
|
|
|
|
sj->dumpsx= win->sizex;
|
|
|
|
sj->dumpsy= win->sizey;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ScrArea *curarea= CTX_wm_area(C);
|
|
|
|
sj->x= curarea->totrct.xmin;
|
|
|
|
sj->y= curarea->totrct.ymin;
|
|
|
|
sj->dumpsx= curarea->totrct.xmax - sj->x;
|
|
|
|
sj->dumpsy= curarea->totrct.ymax - sj->y;
|
|
|
|
}
|
2011-11-20 14:38:11 +00:00
|
|
|
sj->bmain= CTX_data_main(C);
|
2009-02-14 16:43:02 +00:00
|
|
|
sj->scene= CTX_data_scene(C);
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_reports_init(&sj->reports, RPT_PRINT);
|
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
/* setup job */
|
|
|
|
WM_jobs_customdata(steve, sj, screenshot_freejob);
|
2009-02-18 13:29:54 +00:00
|
|
|
WM_jobs_timer(steve, 0.1, 0, NC_SCREEN|ND_SCREENCAST);
|
2010-04-15 10:28:32 +00:00
|
|
|
WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL);
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
WM_jobs_start(CTX_wm_manager(C), steve);
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2009-02-18 13:29:54 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|ND_SCREENCAST, screen);
|
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-02-14 16:43:02 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
void SCREEN_OT_screencast(wmOperatorType *ot)
|
2009-02-14 16:43:02 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Make Screencast";
|
|
|
|
ot->idname = "SCREEN_OT_screencast";
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_operator_confirm;
|
|
|
|
ot->exec = screencast_exec;
|
|
|
|
ot->poll = WM_operator_winactive;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH);
|
2009-02-14 16:43:02 +00:00
|
|
|
RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|