From b6b77114796c597b4bd23063329bc65357761f19 Mon Sep 17 00:00:00 2001 From: Aviii06 Date: Wed, 13 Apr 2022 18:11:59 +0530 Subject: [PATCH] Move Pixbuf out of cairo_utils.h into it's on files. --- src/display/CMakeLists.txt | 1 + src/display/cairo-utils.h | 65 +--------------------------------- src/display/pixbuf.h | 72 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 64 deletions(-) create mode 100644 src/display/pixbuf.h diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 2c2c4f6f84..f4cbaa678a 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -101,6 +101,7 @@ set(display_SRC nr-light.h nr-style.h nr-svgfonts.h + pixbuf.h rendermode.h control/canvas-axonomgrid.h diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 0c7bd8a9a3..ae4230f49e 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -16,73 +16,10 @@ #include <2geom/forward.h> #include #include "style.h" - -struct SPColor; -typedef struct _GdkPixbuf GdkPixbuf; +#include "pixbuf.h" void ink_cairo_pixbuf_cleanup(unsigned char *, void *); -namespace Inkscape { - -/** Class to hold image data for raster images. - * Allows easy interoperation with GdkPixbuf and Cairo. */ -class Pixbuf { -public: - enum PixelFormat { - PF_CAIRO = 1, - PF_GDK = 2, - PF_LAST - }; - - explicit Pixbuf(cairo_surface_t *s); - explicit Pixbuf(GdkPixbuf *pb); - Pixbuf(Inkscape::Pixbuf const &other); - ~Pixbuf(); - - GdkPixbuf *getPixbufRaw(bool convert_format = true); - //Glib::RefPtr getPixbuf(bool convert_format = true); - - cairo_surface_t *getSurfaceRaw(bool convert_format = true); - Cairo::RefPtr getSurface(bool convert_format = true); - - int width() const; - int height() const; - int rowstride() const; - guchar const *pixels() const; - guchar *pixels(); - void markDirty(); - - bool hasMimeData() const; - guchar const *getMimeData(gsize &len, std::string &mimetype) const; - std::string const &originalPath() const { return _path; } - time_t modificationTime() const { return _mod_time; } - - PixelFormat pixelFormat() const { return _pixel_format; } - void ensurePixelFormat(PixelFormat fmt); - - static Pixbuf *create_from_data_uri(gchar const *uri, double svgdpi = 0); - static Pixbuf *create_from_file(std::string const &fn, double svgddpi = 0); - static Pixbuf *create_from_buffer(std::string const &, double svgddpi = 0, std::string const &fn = ""); - - private: - static Pixbuf *create_from_buffer(gchar *&&, gsize, double svgddpi = 0, std::string const &fn = ""); - static GdkPixbuf *apply_embedded_orientation(GdkPixbuf *buf); - - void _ensurePixelsARGB32(); - void _ensurePixelsPixbuf(); - void _forceAlpha(); - void _setMimeData(guchar *data, gsize len, Glib::ustring const &format); - - GdkPixbuf *_pixbuf; - cairo_surface_t *_surface; - time_t _mod_time; - std::string _path; - PixelFormat _pixel_format; - bool _cairo_store; -}; - -} // namespace Inkscape - // TODO: these declarations may not be needed in the header extern cairo_user_data_key_t ink_color_interpolation_key; diff --git a/src/display/pixbuf.h b/src/display/pixbuf.h new file mode 100644 index 0000000000..b75868e271 --- /dev/null +++ b/src/display/pixbuf.h @@ -0,0 +1,72 @@ +#ifndef PIXBUF_H +#define PIXBUF_H +#include <2geom/forward.h> +#include +#include "style.h" + + +struct SPColor; +typedef struct _GdkPixbuf GdkPixbuf; +namespace Inkscape { + +/** Class to hold image data for raster images. + * Allows easy interoperation with GdkPixbuf and Cairo. */ + +class Pixbuf { +public: + enum PixelFormat { + PF_CAIRO = 1, + PF_GDK = 2, + PF_LAST + }; + + explicit Pixbuf(cairo_surface_t *s); + explicit Pixbuf(GdkPixbuf *pb); + Pixbuf(Inkscape::Pixbuf const &other); + ~Pixbuf(); + + GdkPixbuf *getPixbufRaw(bool convert_format = true); + //Glib::RefPtr getPixbuf(bool convert_format = true); + + cairo_surface_t *getSurfaceRaw(bool convert_format = true); + Cairo::RefPtr getSurface(bool convert_format = true); + + int width() const; + int height() const; + int rowstride() const; + guchar const *pixels() const; + guchar *pixels(); + void markDirty(); + + bool hasMimeData() const; + guchar const *getMimeData(gsize &len, std::string &mimetype) const; + std::string const &originalPath() const { return _path; } + time_t modificationTime() const { return _mod_time; } + + PixelFormat pixelFormat() const { return _pixel_format; } + void ensurePixelFormat(PixelFormat fmt); + + static Pixbuf *create_from_data_uri(gchar const *uri, double svgdpi = 0); + static Pixbuf *create_from_file(std::string const &fn, double svgddpi = 0); + static Pixbuf *create_from_buffer(std::string const &, double svgddpi = 0, std::string const &fn = ""); + + private: + static Pixbuf *create_from_buffer(gchar *&&, gsize, double svgddpi = 0, std::string const &fn = ""); + static GdkPixbuf *apply_embedded_orientation(GdkPixbuf *buf); + + void _ensurePixelsARGB32(); + void _ensurePixelsPixbuf(); + void _forceAlpha(); + void _setMimeData(guchar *data, gsize len, Glib::ustring const &format); + + GdkPixbuf *_pixbuf; + cairo_surface_t *_surface; + time_t _mod_time; + std::string _path; + PixelFormat _pixel_format; + bool _cairo_store; +}; + +} // namespace Inkscape + +#endif //PIXBUF_H -- GitLab