summaryrefslogtreecommitdiffstats
path: root/src/display/drawing.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2013-01-13 22:10:30 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2013-01-13 22:10:30 +0000
commitf591cdba110df5277fd1fee83b4b2d53efa03e3b (patch)
tree01e7435c5f6c5966ad8b613daa3c052a9f4ab48c /src/display/drawing.cpp
parentFix deprecated pointer grabbing in gimpcolorwheel (diff)
downloadinkscape-f591cdba110df5277fd1fee83b4b2d53efa03e3b.tar.gz
inkscape-f591cdba110df5277fd1fee83b4b2d53efa03e3b.zip
make grayscale viewmode color factors configurable.
(bzr r12022)
Diffstat (limited to 'src/display/drawing.cpp')
-rw-r--r--src/display/drawing.cpp29
1 files changed, 16 insertions, 13 deletions
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<gdouble> (grayscale_value_matrix, grayscale_value_matrix + 20 ))
, delta(0)
, _exact(false)
, _rendermode(RENDERMODE_NORMAL)
@@ -143,6 +151,12 @@ Drawing::setCacheBudget(size_t bytes)
}
void
+Drawing::setGrayscaleMatrix(gdouble value_matrix[20]) {
+ _grayscale_colormatrix = Filters::FilterColorMatrix::ColorMatrixMatrix(
+ std::vector<gdouble> (value_matrix, value_matrix + 20) );
+}
+
+void
Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset)
{
if (_root) {
@@ -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<gdouble> (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);