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:
Diffstat (limited to 'source/blender/editors/screen/screendump.c')
-rw-r--r--source/blender/editors/screen/screendump.c151
1 files changed, 75 insertions, 76 deletions
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 22a1770412f..256df21b79a 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -78,18 +78,18 @@ typedef struct ScreenshotData {
/* get shot from frontbuffer */
static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy)
{
- wmWindow *win= CTX_wm_window(C);
- int x=0, y=0;
- unsigned int *dumprect= NULL;
-
- x= 0;
- y= 0;
- *dumpsx= win->sizex;
- *dumpsy= win->sizey;
+ wmWindow *win = CTX_wm_window(C);
+ int x = 0, y = 0;
+ unsigned int *dumprect = NULL;
+
+ x = 0;
+ y = 0;
+ *dumpsx = win->sizex;
+ *dumpsy = win->sizey;
if (*dumpsx && *dumpsy) {
- dumprect= MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
+ dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
glReadBuffer(GL_FRONT);
glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
glFinish();
@@ -108,17 +108,17 @@ static int screenshot_data_create(bContext *C, wmOperator *op)
/* do redraw so we don't show popups/menus */
WM_redraw_windows(C);
- dumprect= screenshot(C, &dumpsx, &dumpsy);
+ dumprect = screenshot(C, &dumpsx, &dumpsy);
if (dumprect) {
- ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot");
- ScrArea *sa= CTX_wm_area(C);
+ ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot");
+ ScrArea *sa = CTX_wm_area(C);
- scd->dumpsx= dumpsx;
- scd->dumpsy= dumpsy;
- scd->dumprect= dumprect;
+ scd->dumpsx = dumpsx;
+ scd->dumpsy = dumpsy;
+ scd->dumprect = dumprect;
if (sa) {
- scd->crop= sa->totrct;
+ scd->crop = sa->totrct;
}
BKE_imformat_defaults(&scd->im_format);
@@ -128,46 +128,46 @@ static int screenshot_data_create(bContext *C, wmOperator *op)
return TRUE;
}
else {
- op->customdata= NULL;
+ op->customdata = NULL;
return FALSE;
}
}
static void screenshot_data_free(wmOperator *op)
{
- ScreenshotData *scd= op->customdata;
+ ScreenshotData *scd = op->customdata;
if (scd) {
if (scd->dumprect)
MEM_freeN(scd->dumprect);
MEM_freeN(scd);
- op->customdata= NULL;
+ op->customdata = NULL;
}
}
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;
+ 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;
if (cropw > 0 && croph > 0) {
- for (y=0; y<croph; y++, to+=cropw, from+=ibuf->x)
- memmove(to, from, sizeof(unsigned int)*cropw);
+ for (y = 0; y < croph; y++, to += cropw, from += ibuf->x)
+ memmove(to, from, sizeof(unsigned int) * cropw);
- ibuf->x= cropw;
- ibuf->y= croph;
+ ibuf->x = cropw;
+ ibuf->y = croph;
}
}
static int screenshot_exec(bContext *C, wmOperator *op)
{
- ScreenshotData *scd= op->customdata;
+ ScreenshotData *scd = op->customdata;
if (scd == NULL) {
/* when running exec directly */
screenshot_data_create(C, op);
- scd= op->customdata;
+ scd = op->customdata;
}
if (scd) {
@@ -179,8 +179,8 @@ static int screenshot_exec(bContext *C, wmOperator *op)
BLI_path_abs(path, G.main->name);
/* operator ensures the extension */
- ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
- ibuf->rect= scd->dumprect;
+ ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
+ ibuf->rect = scd->dumprect;
/* crop to show only single editor */
if (!RNA_boolean_get(op->ptr, "full"))
@@ -190,7 +190,7 @@ static int screenshot_exec(bContext *C, wmOperator *op)
/* bw screenshot? - users will notice if it fails! */
IMB_color_to_bw(ibuf);
}
- BKE_write_ibuf(ibuf, path, &scd->im_format);
+ BKE_imbuf_write(ibuf, path, &scd->im_format);
IMB_freeImBuf(ibuf);
}
@@ -255,6 +255,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
{
ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */
ot->idname = "SCREEN_OT_screenshot";
+ ot->description = "Capture a picture of the active area or whole Blender window";
ot->invoke = screenshot_invoke;
ot->check = screenshot_check;
@@ -265,8 +266,8 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
ot->flag = 0;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
- RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
+ WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+ RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screenshot the whole Blender window");
}
/* *************** screenshot movie job ************************* */
@@ -284,7 +285,7 @@ typedef struct ScreenshotJob {
static void screenshot_freejob(void *sjv)
{
- ScreenshotJob *sj= sjv;
+ ScreenshotJob *sj = sjv;
if (sj->dumprect)
MEM_freeN(sj->dumprect);
@@ -296,15 +297,15 @@ static void screenshot_freejob(void *sjv)
/* called before redraw notifiers, copies a new dumprect */
static void screenshot_updatejob(void *sjv)
{
- ScreenshotJob *sj= sjv;
+ ScreenshotJob *sj = sjv;
unsigned int *dumprect;
- if (sj->dumprect==NULL) {
- dumprect= MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect");
+ if (sj->dumprect == NULL) {
+ 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;
+ sj->dumprect = dumprect;
}
}
@@ -312,13 +313,13 @@ static void screenshot_updatejob(void *sjv)
/* only this runs inside thread */
static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *UNUSED(progress))
{
- ScreenshotJob *sj= sjv;
- RenderData rd= sj->scene->r;
- bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype);
+ ScreenshotJob *sj = sjv;
+ RenderData rd = sj->scene->r;
+ bMovieHandle *mh = BKE_movie_handle_get(sj->scene->r.im_format.imtype);
/* we need this as local variables for renderdata */
- rd.frs_sec= U.scrcastfps;
- rd.frs_sec_base= 1.0f;
+ rd.frs_sec = U.scrcastfps;
+ rd.frs_sec_base = 1.0f;
if (BKE_imtype_is_movie(rd.im_format.imtype)) {
if (!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) {
@@ -327,20 +328,20 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
}
}
else
- mh= NULL;
+ mh = NULL;
- sj->stop= stop;
- sj->do_update= do_update;
+ sj->stop = stop;
+ sj->do_update = do_update;
- *do_update= 1; // wait for opengl rect
+ *do_update = 1; // wait for opengl rect
- while (*stop==0) {
+ while (*stop == 0) {
if (sj->dumprect) {
if (mh) {
if (mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect,
- sj->dumpsx, sj->dumpsy, &sj->reports))
+ sj->dumpsx, sj->dumpsy, &sj->reports))
{
BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra);
printf("Appended frame %d\n", rd.cfra);
@@ -350,16 +351,16 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
}
}
else {
- ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0);
+ ImBuf *ibuf = IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0);
char name[FILE_MAX];
int ok;
BKE_makepicstring(name, rd.pic, sj->bmain->name, rd.cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE);
- ibuf->rect= sj->dumprect;
- ok= BKE_write_ibuf(ibuf, name, &rd.im_format);
+ ibuf->rect = sj->dumprect;
+ ok = BKE_imbuf_write(ibuf, name, &rd.im_format);
- if (ok==0) {
+ if (ok == 0) {
printf("Write error: cannot save %s\n", name);
BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name);
break;
@@ -374,9 +375,9 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
}
MEM_freeN(sj->dumprect);
- sj->dumprect= NULL;
+ sj->dumprect = NULL;
- *do_update= 1;
+ *do_update = 1;
rd.cfra++;
@@ -393,38 +394,38 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
static int screencast_exec(bContext *C, wmOperator *op)
{
- bScreen *screen= CTX_wm_screen(C);
- wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0);
- ScreenshotJob *sj= MEM_callocN(sizeof(ScreenshotJob), "screenshot job");
+ bScreen *screen = CTX_wm_screen(C);
+ wmJob *steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0);
+ ScreenshotJob *sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job");
/* setup sj */
if (RNA_boolean_get(op->ptr, "full")) {
- wmWindow *win= CTX_wm_window(C);
- sj->x= 0;
- sj->y= 0;
- sj->dumpsx= win->sizex;
- sj->dumpsy= win->sizey;
+ 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;
+ 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;
}
- sj->bmain= CTX_data_main(C);
- sj->scene= CTX_data_scene(C);
+ sj->bmain = CTX_data_main(C);
+ sj->scene = CTX_data_scene(C);
BKE_reports_init(&sj->reports, RPT_PRINT);
/* setup job */
WM_jobs_customdata(steve, sj, screenshot_freejob);
- WM_jobs_timer(steve, 0.1, 0, NC_SCREEN|ND_SCREENCAST);
+ WM_jobs_timer(steve, 0.1, 0, NC_SCREEN | ND_SCREENCAST);
WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL);
WM_jobs_start(CTX_wm_manager(C), steve);
- WM_event_add_notifier(C, NC_SCREEN|ND_SCREENCAST, screen);
+ WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen);
return OPERATOR_FINISHED;
}
@@ -433,6 +434,7 @@ void SCREEN_OT_screencast(wmOperatorType *ot)
{
ot->name = "Make Screencast";
ot->idname = "SCREEN_OT_screencast";
+ ot->description = "Capture a video of the active area or whole Blender window";
ot->invoke = WM_operator_confirm;
ot->exec = screencast_exec;
@@ -441,8 +443,5 @@ void SCREEN_OT_screencast(wmOperatorType *ot)
ot->flag = 0;
RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH);
- RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
+ RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screencast the whole Blender window");
}
-
-
-