[Bf-blender-cvs] [5e5496e6ea9] greasepencil-object: GP: Fill: Fix crasher when unable to create GPUOffScreen
Charlie Jolly
noreply at git.blender.org
Mon Jan 14 23:39:35 CET 2019
Commit: 5e5496e6ea940b82088165106968fbdfae2df6a4
Author: Charlie Jolly
Date: Mon Jan 14 22:39:01 2019 +0000
Branches: greasepencil-object
https://developer.blender.org/rB5e5496e6ea940b82088165106968fbdfae2df6a4
GP: Fill: Fix crasher when unable to create GPUOffScreen
===================================================================
M source/blender/editors/gpencil/gpencil_fill.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index e4ce6a4d469..23211009b36 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -284,13 +284,13 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
}
/* draw strokes in offscreen buffer */
-static void gp_render_offscreen(tGPDfill *tgpf)
+static bool gp_render_offscreen(tGPDfill *tgpf)
{
bool is_ortho = false;
float winmat[4][4];
if (!tgpf->gpd) {
- return;
+ return false;
}
/* set temporary new size */
@@ -318,6 +318,11 @@ static void gp_render_offscreen(tGPDfill *tgpf)
char err_out[256] = "unknown";
GPUOffScreen *offscreen = GPU_offscreen_create(tgpf->sizex, tgpf->sizey, 0, true, false, err_out);
+ if (offscreen == NULL) {
+ printf("GPencil - Fill - Unable to create fill buffer\n");
+ return false;
+ }
+
GPU_offscreen_bind(offscreen, true);
uint flag = IB_rect | IB_rectfloat;
ImBuf *ibuf = IMB_allocImBuf(tgpf->sizex, tgpf->sizey, 32, flag);
@@ -374,6 +379,8 @@ static void gp_render_offscreen(tGPDfill *tgpf)
/* switch back to window-system-provided framebuffer */
GPU_offscreen_unbind(offscreen, true);
GPU_offscreen_free(offscreen);
+
+ return true;
}
/* return pixel data (rgba) at index */
@@ -1233,25 +1240,27 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
tgpf->center[1] = event->mval[1];
/* render screen to temp image */
- gp_render_offscreen(tgpf);
+ if ( gp_render_offscreen(tgpf) ) {
+
+ /* apply boundary fill */
+ gpencil_boundaryfill_area(tgpf);
- /* apply boundary fill */
- gpencil_boundaryfill_area(tgpf);
+ /* clean borders to avoid infinite loops */
+ gpencil_clean_borders(tgpf);
- /* clean borders to avoid infinite loops */
- gpencil_clean_borders(tgpf);
+ /* analyze outline */
+ gpencil_get_outline_points(tgpf);
- /* analyze outline */
- gpencil_get_outline_points(tgpf);
+ /* create array of points from stack */
+ gpencil_points_from_stack(tgpf);
- /* create array of points from stack */
- gpencil_points_from_stack(tgpf);
+ /* create z-depth array for reproject */
+ gpencil_get_depth_array(tgpf);
- /* create z-depth array for reproject */
- gpencil_get_depth_array(tgpf);
+ /* create stroke and reproject */
+ gpencil_stroke_from_buffer(tgpf);
- /* create stroke and reproject */
- gpencil_stroke_from_buffer(tgpf);
+ }
/* restore size */
tgpf->ar->winx = (short)tgpf->bwinx;
More information about the Bf-blender-cvs
mailing list