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:
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc39
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_export_pdf.hh2
2 files changed, 28 insertions, 13 deletions
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
index 9b2dc6d12a3..11278a3ccd7 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
@@ -69,7 +69,6 @@ GpencilExporterPDF::GpencilExporterPDF(const char *filename, const GpencilIOPara
pdf_ = nullptr;
page_ = nullptr;
- gstate_ = nullptr;
}
bool GpencilExporterPDF::new_document()
@@ -169,15 +168,27 @@ void GpencilExporterPDF::export_gpencil_layers()
if (!ED_gpencil_stroke_material_visible(ob, gps)) {
continue;
}
- /* Duplicate the stroke to apply any layer thickness change. */
- bGPDstroke *gps_duplicate = BKE_gpencil_stroke_duplicate(gps, true, false);
- MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob,
- gps_duplicate->mat_nr + 1);
+ /* Skip invisible lines. */
+ const float fill_opacity = fill_color_[3] * gpl->opacity;
+ const float stroke_opacity = stroke_color_[3] * stroke_average_opacity_get() *
+ gpl->opacity;
+ if ((fill_opacity < GPENCIL_ALPHA_OPACITY_THRESH) &&
+ (stroke_opacity < GPENCIL_ALPHA_OPACITY_THRESH)) {
+ continue;
+ }
+ MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
const bool is_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) &&
(gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
const bool is_fill = ((gp_style->flag & GP_MATERIAL_FILL_SHOW) &&
(gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
+
+ if ((!is_stroke) && (!is_fill)) {
+ continue;
+ }
+
+ /* Duplicate the stroke to apply any layer thickness change. */
+ bGPDstroke *gps_duplicate = BKE_gpencil_stroke_duplicate(gps, true, false);
prepare_stroke_export_colors(ob, gps_duplicate);
/* Apply layer thickness change. */
@@ -283,29 +294,35 @@ void GpencilExporterPDF::color_set(bGPDlayer *gpl, const bool do_fill)
{
const float fill_opacity = fill_color_[3] * gpl->opacity;
const float stroke_opacity = stroke_color_[3] * stroke_average_opacity_get() * gpl->opacity;
+ const bool need_state = (do_fill && fill_opacity < 1.0f) || (stroke_opacity < 1.0f);
HPDF_Page_GSave(page_);
- gstate_ = HPDF_CreateExtGState(pdf_);
+ HPDF_ExtGState gstate = (need_state) ? HPDF_CreateExtGState(pdf_) : nullptr;
float col[3];
if (do_fill) {
interp_v3_v3v3(col, fill_color_, gpl->tintcolor, gpl->tintcolor[3]);
linearrgb_to_srgb_v3_v3(col, col);
CLAMP3(col, 0.0f, 1.0f);
-
- HPDF_ExtGState_SetAlphaFill(gstate_, clamp_f(fill_opacity, 0.0f, 1.0f));
HPDF_Page_SetRGBFill(page_, col[0], col[1], col[2]);
+ if (gstate) {
+ HPDF_ExtGState_SetAlphaFill(gstate, clamp_f(fill_opacity, 0.0f, 1.0f));
+ }
}
else {
interp_v3_v3v3(col, stroke_color_, gpl->tintcolor, gpl->tintcolor[3]);
linearrgb_to_srgb_v3_v3(col, col);
CLAMP3(col, 0.0f, 1.0f);
- HPDF_ExtGState_SetAlphaFill(gstate_, clamp_f(stroke_opacity, 0.0f, 1.0f));
- HPDF_ExtGState_SetAlphaStroke(gstate_, clamp_f(stroke_opacity, 0.0f, 1.0f));
HPDF_Page_SetRGBFill(page_, col[0], col[1], col[2]);
HPDF_Page_SetRGBStroke(page_, col[0], col[1], col[2]);
+ if (gstate) {
+ HPDF_ExtGState_SetAlphaFill(gstate, clamp_f(stroke_opacity, 0.0f, 1.0f));
+ HPDF_ExtGState_SetAlphaStroke(gstate, clamp_f(stroke_opacity, 0.0f, 1.0f));
+ }
+ }
+ if (gstate) {
+ HPDF_Page_SetExtGState(page_, gstate);
}
- HPDF_Page_SetExtGState(page_, gstate_);
}
} // namespace blender::io::gpencil
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.hh b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.hh
index 20970151344..89d97f79783 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.hh
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.hh
@@ -49,8 +49,6 @@ class GpencilExporterPDF : public GpencilExporter {
HPDF_Doc pdf_;
/* PDF page. */
HPDF_Page page_;
- /* State. */
- HPDF_ExtGState gstate_;
bool create_document();
bool add_page();