From cfe9c94712a2ff6849b123672e51b603f20e76ae Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 10 Jan 2013 23:30:09 -0800 Subject: Warning and dead code cleanup. (bzr r12014) --- src/display/cairo-utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/display') diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index d240545eb..e88c6d4e8 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -87,7 +87,10 @@ public: * Only the address of the structure is used, it is never initialized. See: * http://www.cairographics.org/manual/cairo-Types.html#cairo-user-data-key-t */ +// TODO fixme check this usage. A static here in a header file is probably not doing what was intended: static cairo_user_data_key_t ci_key; + + SPColorInterpolation get_cairo_surface_ci(cairo_surface_t *surface); void set_cairo_surface_ci(cairo_surface_t *surface, SPColorInterpolation cif); void copy_cairo_surface_ci(cairo_surface_t *in, cairo_surface_t *out); -- cgit v1.2.3 From f591cdba110df5277fd1fee83b4b2d53efa03e3b Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Jan 2013 23:10:30 +0100 Subject: make grayscale viewmode color factors configurable. (bzr r12022) --- src/display/drawing.cpp | 29 ++++++++++++++++------------- src/display/drawing.h | 5 ++++- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src/display') diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 171cc014f..ed56b1617 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -16,16 +16,24 @@ #include "nr-filter-types.h" //grayscale colormode: -#include "nr-filter-colormatrix.h" #include "cairo-templates.h" #include "drawing-context.h" namespace Inkscape { +// hardcoded grayscale color matrix values as default +static const gdouble grayscale_value_matrix[20] = { + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0 , 0 , 0 , 1, 0 +}; + Drawing::Drawing(SPCanvasArena *arena) : _root(NULL) , outlinecolor(0x000000ff) + , _grayscale_colormatrix(std::vector (grayscale_value_matrix, grayscale_value_matrix + 20 )) , delta(0) , _exact(false) , _rendermode(RENDERMODE_NORMAL) @@ -142,6 +150,12 @@ Drawing::setCacheBudget(size_t bytes) _pickItemsForCaching(); } +void +Drawing::setGrayscaleMatrix(gdouble value_matrix[20]) { + _grayscale_colormatrix = Filters::FilterColorMatrix::ColorMatrixMatrix( + std::vector (value_matrix, value_matrix + 20) ); +} + void Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { @@ -152,17 +166,6 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl _pickItemsForCaching(); } -// hardcoded grayscale color matrix values. could be turned into preference settings in future. -static const gdouble grayscale_value_matrix[] = { - 0.21, 0.72, 0.072, 0, 0, - 0.21, 0.72, 0.072, 0, 0, - 0.21, 0.72, 0.072, 0, 0, - 0 , 0 , 0 , 1, 0 -}; -static Filters::FilterColorMatrix::ColorMatrixMatrix grayscale_colormatrix( - std::vector (grayscale_value_matrix, grayscale_value_matrix + sizeof(grayscale_value_matrix) / sizeof(grayscale_value_matrix[0]) ) -); - void Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { @@ -174,7 +177,7 @@ Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) // apply grayscale filter on top of everything cairo_surface_t *input = ct.rawTarget(); cairo_surface_t *out = ink_cairo_surface_create_identical(input); - ink_cairo_surface_filter(input, out, grayscale_colormatrix); + ink_cairo_surface_filter(input, out, _grayscale_colormatrix); Geom::Point origin = ct.targetLogicalBounds().min(); ct.setSource(out, origin[Geom::X], origin[Geom::Y]); ct.setOperator(CAIRO_OPERATOR_SOURCE); diff --git a/src/display/drawing.h b/src/display/drawing.h index 8154f0783..74ab57fae 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -20,7 +20,7 @@ #include <2geom/rect.h> #include "display/drawing-item.h" #include "display/rendermode.h" - +#include "nr-filter-colormatrix.h" typedef struct _SPCanvasArena SPCanvasArena; @@ -65,6 +65,8 @@ public: OutlineColors const &colors() const { return _colors; } + void setGrayscaleMatrix(gdouble value_matrix[20]); + void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = DrawingItem::STATE_ALL, unsigned reset = 0); void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags); @@ -97,6 +99,7 @@ private: size_t _cache_budget; ///< maximum allowed size of cache OutlineColors _colors; + Filters::FilterColorMatrix::ColorMatrixMatrix _grayscale_colormatrix; SPCanvasArena *_canvasarena; // may be NULL is this arena is not the screen // but used for export etc. -- cgit v1.2.3 From ef52cc4c2b2bde5f8f2f29db5bff8990691993b2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 17 Jan 2013 21:07:10 +0100 Subject: const (bzr r12040) --- src/display/canvas-grid.cpp | 8 ++++---- src/display/canvas-grid.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/display') diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 329b621ae..5fd38a473 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -183,19 +183,19 @@ CanvasGrid::~CanvasGrid() } const char * -CanvasGrid::getName() +CanvasGrid::getName() const { return _(grid_name[gridtype]); } const char * -CanvasGrid::getSVGName() +CanvasGrid::getSVGName() const { return grid_svgname[gridtype]; } GridType -CanvasGrid::getGridType() +CanvasGrid::getGridType() const { return gridtype; } @@ -369,7 +369,7 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc (static_cast(data))->onReprAttrChanged(repr, key, oldval, newval, is_interactive); } -bool CanvasGrid::isEnabled() +bool CanvasGrid::isEnabled() const { if (snapper == NULL) { return false; diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index bba9b7e95..7eaef407f 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -61,9 +61,9 @@ public: virtual ~CanvasGrid(); // TODO: see effect.h and effect.cpp from live_effects how to link enums to SVGname to typename properly. (johan) - const char * getName(); - const char * getSVGName(); - GridType getGridType(); + const char * getName() const; + const char * getSVGName() const; + GridType getGridType() const; static const char * getName(GridType type); static const char * getSVGName(GridType type); static GridType getGridTypeFromSVGName(const char * typestr); @@ -97,8 +97,8 @@ public: static void on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data); - bool isVisible() { return (isEnabled() &&visible); }; - bool isEnabled(); + bool isVisible() const { return (isEnabled() &&visible); }; + bool isEnabled() const; protected: CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type); -- cgit v1.2.3 From 194e1e43f247e2364aeff6126ea3b1db4b5deaf2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 17 Jan 2013 21:48:17 +0100 Subject: fix warning (bzr r12041) --- src/display/drawing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index ed56b1617..c192e4565 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -33,7 +33,6 @@ static const gdouble grayscale_value_matrix[20] = { Drawing::Drawing(SPCanvasArena *arena) : _root(NULL) , outlinecolor(0x000000ff) - , _grayscale_colormatrix(std::vector (grayscale_value_matrix, grayscale_value_matrix + 20 )) , delta(0) , _exact(false) , _rendermode(RENDERMODE_NORMAL) @@ -42,6 +41,7 @@ Drawing::Drawing(SPCanvasArena *arena) , _filter_quality(Filters::FILTER_QUALITY_BEST) , _cache_score_threshold(50000.0) , _cache_budget(0) + , _grayscale_colormatrix(std::vector (grayscale_value_matrix, grayscale_value_matrix + 20 )) , _canvasarena(arena) { -- cgit v1.2.3