style cleanup: follow style guide for formatting of if/for/while loops, and else...
[blender.git] / source / blender / editors / screen / screendump.c
index ca5616f35021e4fa777bd2058c34577dcb08621f..e12e6b0ef829f5d8b842ca4e945a134aaf9f932c 100644 (file)
@@ -106,14 +106,14 @@ static int screenshot_data_create(bContext *C, wmOperator *op)
        
        dumprect= screenshot(C, &dumpsx, &dumpsy);
 
-       if(dumprect) {
+       if (dumprect) {
                ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot");
                ScrArea *sa= CTX_wm_area(C);
                
                scd->dumpsx= dumpsx;
                scd->dumpsy= dumpsy;
                scd->dumprect= dumprect;
-               if(sa)
+               if (sa)
                        scd->crop= sa->totrct;
                op->customdata= scd;
 
@@ -129,8 +129,8 @@ static void screenshot_data_free(wmOperator *op)
 {
        ScreenshotData *scd= op->customdata;
 
-       if(scd) {
-               if(scd->dumprect)
+       if (scd) {
+               if (scd->dumprect)
                        MEM_freeN(scd->dumprect);
                MEM_freeN(scd);
                op->customdata= NULL;
@@ -143,8 +143,8 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
        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)
+       if (cropw > 0 && croph > 0) {
+               for (y=0; y<croph; y++, to+=cropw, from+=ibuf->x)
                        memmove(to, from, sizeof(unsigned int)*cropw);
 
                ibuf->x= cropw;
@@ -156,14 +156,14 @@ static int screenshot_exec(bContext *C, wmOperator *op)
 {
        ScreenshotData *scd= op->customdata;
 
-       if(scd == NULL) {
+       if (scd == NULL) {
                /* when running exec directly */
                screenshot_data_create(C, op);
                scd= op->customdata;
        }
 
-       if(scd) {
-               if(scd->dumprect) {
+       if (scd) {
+               if (scd->dumprect) {
                        Scene *scene= CTX_data_scene(C);
                        ImBuf *ibuf;
                        char path[FILE_MAX];
@@ -174,15 +174,15 @@ static int screenshot_exec(bContext *C, wmOperator *op)
                        BLI_path_abs(path, G.main->name);
 
                        /* BKE_add_image_extension() checks for if extension was already set */
-                       if(scene->r.scemode & R_EXTENSION)
-                               if(strlen(path)<FILE_MAX-5)
+                       if (scene->r.scemode & R_EXTENSION)
+                               if (strlen(path)<FILE_MAX-5)
                                        BKE_add_image_extension(path, scene->r.im_format.imtype);
 
                        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"))
+                       if (!RNA_boolean_get(op->ptr, "full"))
                                screenshot_crop(ibuf, scd->crop);
 
                        BKE_write_ibuf(ibuf, path, &scene->r.im_format);
@@ -197,8 +197,8 @@ static int screenshot_exec(bContext *C, wmOperator *op)
 
 static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
-       if(screenshot_data_create(C, op)) {
-               if(RNA_struct_property_is_set(op->ptr, "filepath"))
+       if (screenshot_data_create(C, op)) {
+               if (RNA_struct_property_is_set(op->ptr, "filepath"))
                        return screenshot_exec(C, op);
                
                RNA_string_set(op->ptr, "filepath", G.ima);
@@ -249,7 +249,7 @@ static void screenshot_freejob(void *sjv)
 {
        ScreenshotJob *sj= sjv;
        
-       if(sj->dumprect)
+       if (sj->dumprect)
                MEM_freeN(sj->dumprect);
        
        MEM_freeN(sj);
@@ -262,7 +262,7 @@ static void screenshot_updatejob(void *sjv)
        ScreenshotJob *sj= sjv;
        unsigned int *dumprect;
        
-       if(sj->dumprect==NULL) {
+       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();
@@ -283,8 +283,8 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
        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)) {
+       if (BKE_imtype_is_movie(rd.im_format.imtype)) {
+               if (!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) {
                        printf("screencast job stopped\n");
                        return;
                }
@@ -297,18 +297,20 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
        
        *do_update= 1; // wait for opengl rect
        
-       while(*stop==0) {
+       while (*stop==0) {
                
-               if(sj->dumprect) {
+               if (sj->dumprect) {
                        
-                       if(mh) {
-                               if(mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect,
+                       if (mh) {
+                               if (mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect,
                                                    sj->dumpsx, sj->dumpsy, &sj->reports))
                                {
                                        BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra);
                                        printf("Appended frame %d\n", rd.cfra);
-                               } else
+                               }
+                               else {
                                        break;
+                               }
                        }
                        else {
                                ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0);
@@ -320,7 +322,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
                                ibuf->rect= sj->dumprect;
                                ok= BKE_write_ibuf(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;
@@ -346,7 +348,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
                        PIL_sleep_ms(U.scrcastwait);
        }
        
-       if(mh)
+       if (mh)
                mh->end_movie();
 
        BKE_report(&sj->reports, RPT_INFO, "Screencast job stopped");
@@ -359,7 +361,7 @@ static int screencast_exec(bContext *C, wmOperator *op)
        ScreenshotJob *sj= MEM_callocN(sizeof(ScreenshotJob), "screenshot job");
 
        /* setup sj */
-       if(RNA_boolean_get(op->ptr, "full")) {
+       if (RNA_boolean_get(op->ptr, "full")) {
                wmWindow *win= CTX_wm_window(C);
                sj->x= 0;
                sj->y= 0;