[Bf-blender-cvs] [475aca05ab8] greasepencil-object: GPencil: Fix errors after merge and compiler warnings
Antonioya
noreply at git.blender.org
Fri Jul 19 15:51:19 CEST 2019
Commit: 475aca05ab8f7b79c3af95f00f0b95b7e9890ce8
Author: Antonioya
Date: Fri Jul 19 15:51:09 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rB475aca05ab8f7b79c3af95f00f0b95b7e9890ce8
GPencil: Fix errors after merge and compiler warnings
The BKE_text_write function parameter list changed.
Added some UNUSED_VARS to functions in development.
===================================================================
M source/blender/editors/gpencil/gpencil_svg.c
M source/blender/editors/io/io_svg.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_svg.c b/source/blender/editors/gpencil/gpencil_svg.c
index 494f38df299..46a0b5805bd 100644
--- a/source/blender/editors/gpencil/gpencil_svg.c
+++ b/source/blender/editors/gpencil/gpencil_svg.c
@@ -53,13 +53,13 @@
static int gpencil_export_svg_exec(bContext *C, wmOperator *op)
{
- Object* gpobj = CTX_data_active_object(C);
+ Object *gpobj = CTX_data_active_object(C);
bGPdata *gpd = gpobj->data;
- bGPDlayer* gpl;
+ bGPDlayer *gpl;
- for(gpl = gpd->layers.first; gpl; gpl = gpl->next){
- Text *ta = BKE_text_add(CTX_data_main(C),"exported_svg");
- ED_svg_data_from_gpencil(gpd,ta,gpl,CTX_data_scene(C)->r.cfra);
+ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ Text *ta = BKE_text_add(CTX_data_main(C), "exported_svg");
+ ED_svg_data_from_gpencil(gpd, ta, gpl, CTX_data_scene(C)->r.cfra);
}
return OPERATOR_FINISHED;
@@ -67,9 +67,9 @@ static int gpencil_export_svg_exec(bContext *C, wmOperator *op)
static bool gpencil_found(bContext *C)
{
- Object* o = CTX_data_active_object(C);
-
- if(o && o->type == OB_GPENCIL){
+ Object *o = CTX_data_active_object(C);
+
+ if (o && o->type == OB_GPENCIL) {
return true;
}
return false;
@@ -78,6 +78,7 @@ static bool gpencil_found(bContext *C)
void GPENCIL_OT_export_svg(wmOperatorType *ot)
{
PropertyRNA *prop;
+ UNUSED_VARS(prop);
/* identifiers */
ot->name = "Export to SVG";
@@ -94,4 +95,3 @@ void GPENCIL_OT_export_svg(wmOperatorType *ot)
/* properties */
/* Should have: facing, layer, visibility, file split... */
}
-
diff --git a/source/blender/editors/io/io_svg.c b/source/blender/editors/io/io_svg.c
index 9774fa792e1..61afd3d696c 100644
--- a/source/blender/editors/io/io_svg.c
+++ b/source/blender/editors/io/io_svg.c
@@ -40,127 +40,156 @@
#include "MEM_guardedalloc.h"
-static void write_svg_head(Text* ta){
- BKE_text_write(ta, NULL, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
- BKE_text_write(ta, NULL, "<svg width=\"10\" height=\"10\" viewBox=\"-5 -5 10 10\" "
- "xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
+static void write_svg_head(Text *ta)
+{
+ BKE_text_write(ta, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
+ BKE_text_write(ta,
+ "<svg width=\"10\" height=\"10\" viewBox=\"-5 -5 10 10\" "
+ "xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
}
-static void write_svg_end(Text* ta){
- BKE_text_write(ta, NULL, "</svg>");
+static void write_svg_end(Text *ta)
+{
+ BKE_text_write(ta, "</svg>");
}
-typedef int (svg_get_path_callback)(void* iterator, float* fill_rgba, float* stroke_rgba, float* stroke_width);
-typedef int (svg_get_node_callback)(void* iterator, float *x, float *y);
-
-#define FAC_255_COLOR3(color) ((int)(255*color[0])),((int)(255*color[1])),((int)(255*color[2]))
-
-static void write_paths_from_callback(void* iterator, Text* ta, svg_get_path_callback get_path, svg_get_node_callback get_node){
- int status;
- float fill_color[3], stroke_color[3], stroke_width;
- int fill_color_i[3], stroke_color_i[3];
- float x,y;
- char buf[128];
- int first_in;
- while(get_path(iterator,fill_color,stroke_color,&stroke_width)){
-
- /* beginning of a path item */
- BKE_text_write(ta, NULL, "<path d=\"");
-
- first_in = 1;
- while(get_node(iterator,&x,&y)){
- sprintf(buf,"%c %f %f\n",first_in?'M':'L',x,y); /* Should handle closed stroke as well. */
- BKE_text_write(ta, NULL, buf);
- first_in = 0;
- }
-
- CLAMP3(fill_color,0,1);
- CLAMP3(stroke_color,0,1);
-
- /* end the path */
- sprintf(buf,"\" fill=\"#%02X%02X%02X\" stroke=\"#%02X%02X%02X\" stroke-width=\"%f\" />\n",
- FAC_255_COLOR3(fill_color), FAC_255_COLOR3(stroke_color), stroke_width/1000.0f);
- BKE_text_write(ta, NULL, buf);
+typedef int(svg_get_path_callback)(void *iterator,
+ float *fill_rgba,
+ float *stroke_rgba,
+ float *stroke_width);
+typedef int(svg_get_node_callback)(void *iterator, float *x, float *y);
+
+#define FAC_255_COLOR3(color) \
+ ((int)(255 * color[0])), ((int)(255 * color[1])), ((int)(255 * color[2]))
+
+static void write_paths_from_callback(void *iterator,
+ Text *ta,
+ svg_get_path_callback get_path,
+ svg_get_node_callback get_node)
+{
+ int status;
+ float fill_color[3], stroke_color[3], stroke_width;
+ int fill_color_i[3], stroke_color_i[3];
+ UNUSED_VARS(status, stroke_color_i, fill_color_i);
+
+ float x, y;
+ char buf[128];
+ int first_in;
+ while (get_path(iterator, fill_color, stroke_color, &stroke_width)) {
+
+ /* beginning of a path item */
+ BKE_text_write(ta, "<path d=\"");
+
+ first_in = 1;
+ while (get_node(iterator, &x, &y)) {
+ sprintf(buf,
+ "%c %f %f\n",
+ first_in ? 'M' : 'L',
+ x,
+ y); /* Should handle closed stroke as well. */
+ BKE_text_write(ta, buf);
+ first_in = 0;
}
-
+
+ CLAMP3(fill_color, 0, 1);
+ CLAMP3(stroke_color, 0, 1);
+
+ /* end the path */
+ sprintf(buf,
+ "\" fill=\"#%02X%02X%02X\" stroke=\"#%02X%02X%02X\" stroke-width=\"%f\" />\n",
+ FAC_255_COLOR3(fill_color),
+ FAC_255_COLOR3(stroke_color),
+ stroke_width / 1000.0f);
+ BKE_text_write(ta, buf);
+ }
}
-typedef struct GPencilSVGIterator{
- bGPdata* gpd;
- bGPDlayer* layer;
- bGPDframe* frame;
- bGPDstroke* stroke;
- bGPDspoint* point;
- int point_i;
-}GPencilSVGIterator;
-
-static int svg_gpencil_get_path_callback(GPencilSVGIterator* iterator, float* fill_color, float* stroke_color, float* stroke_width){
- GPencilSVGIterator* sr = (GPencilSVGIterator*)iterator;
- if(!sr->stroke){
- if(!sr->frame->strokes.first){
- return 0;
- }
- sr->stroke = sr->frame->strokes.first;
- }else{
- sr->stroke = sr->stroke->next;
- if(!sr->stroke){
- return 0;
- }
+typedef struct GPencilSVGIterator {
+ bGPdata *gpd;
+ bGPDlayer *layer;
+ bGPDframe *frame;
+ bGPDstroke *stroke;
+ bGPDspoint *point;
+ int point_i;
+} GPencilSVGIterator;
+
+static int svg_gpencil_get_path_callback(GPencilSVGIterator *iterator,
+ float *fill_color,
+ float *stroke_color,
+ float *stroke_width)
+{
+ GPencilSVGIterator *sr = (GPencilSVGIterator *)iterator;
+ if (!sr->stroke) {
+ if (!sr->frame->strokes.first) {
+ return 0;
+ }
+ sr->stroke = sr->frame->strokes.first;
+ }
+ else {
+ sr->stroke = sr->stroke->next;
+ if (!sr->stroke) {
+ return 0;
}
- *stroke_width = sr->stroke->thickness;
-
- /* TODO: no material access yet */
- zero_v3(fill_color);
- zero_v3(stroke_color);
- return 1;
+ }
+ *stroke_width = sr->stroke->thickness;
+
+ /* TODO: no material access yet */
+ zero_v3(fill_color);
+ zero_v3(stroke_color);
+ return 1;
}
-static int svg_gpencil_get_node_callback(GPencilSVGIterator* iterator, float* x, float* y){
- GPencilSVGIterator* sr = (GPencilSVGIterator*)iterator;
- if(!sr->point){
- if(!sr->stroke->points){
- return 0;
- }
- sr->point = sr->stroke->points;
- sr->point_i = 0;
- }else{
- if(sr->point_i == sr->stroke->totpoints){
- return 0;
- }
+static int svg_gpencil_get_node_callback(GPencilSVGIterator *iterator, float *x, float *y)
+{
+ GPencilSVGIterator *sr = (GPencilSVGIterator *)iterator;
+ if (!sr->point) {
+ if (!sr->stroke->points) {
+ return 0;
+ }
+ sr->point = sr->stroke->points;
+ sr->point_i = 0;
+ }
+ else {
+ if (sr->point_i == sr->stroke->totpoints) {
+ return 0;
}
- *x = sr->point[sr->point_i].x;
- *y = sr->point[sr->point_i].y;
- sr->point_i++;
- return 1;
+ }
+ *x = sr->point[sr->point_i].x;
+ *y = sr->point[sr->point_i].y;
+ sr->point_i++;
+ return 1;
}
-bool ED_svg_data_from_gpencil(bGPdata* gpd, Text* ta, bGPDlayer* layer, int frame){
- if(!gpd || !ta || !gpd->layers.first){
- return false;
- }
+bool ED_svg_data_from_gpencil(bGPdata *gpd, Text *ta, bGPDlayer *layer, int frame)
+{
+ if (!gpd || !ta || !gpd->layers.first) {
+ return false;
+ }
- /* Init temp iterator */
- GPencilSVGIterator gsr = {0};
- gsr.gpd = gpd;
- if(layer){
- gsr.layer = layer;
- }else{
- gsr.layer = gpd->layers.first;
- }
- gsr.frame = BKE_gpencil_layer_getframe(gsr.layer,frame,GP_GETFRAME_USE_PREV);
+ /* Init temp iterator */
+ GPencilSVGIterator gsr = {0};
+ gsr.gpd = gpd;
+ if (layer) {
+ gsr.layer = layer;
+ }
+ else {
+ gsr.layer = gpd->layers.first;
+ }
+ gsr.frame = BKE_gpencil_layer_getframe(gsr.layer, frame, GP_GETFRAME_USE_PREV);
- if(!gsr.frame){
- return false;
- }
-
- /* Will cause nothing to be written into the text block.(Why?) */
- /* BKE_text_free_lines(ta); */
+ if (!gsr.frame) {
+ return false;
+ }
+
+ /* Will cause nothing to be written into the text block.(Why?) */
+ /* BKE_text_free_lines(ta); */
- write_svg_head(ta);
+ write_svg_head(ta);
- write_paths_from_callback(&gsr, ta, svg_gpencil_get_path_callback,svg_gpencil_get_node_callback);
+ write_paths_from_callback(
+ &gsr, ta, svg_gpencil_get_path_callback, svg_gpencil_get_node_callback);
- write_svg_end(ta);
+ write_svg_end(ta);
- return true;
+ return true;
}
More information about the Bf-blender-cvs
mailing list