• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

gr_CairoImage.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiWord
00003  * Copyright (C) 2008 Dominic Lachowicz
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
00019  */
00020 
00021 #ifndef GR_CAIROIMAGE_H
00022 #define GR_CAIROIMAGE_H
00023 
00024 #include <cairo.h>
00025 
00026 #include "gr_CairoGraphics.h"
00027 #include "ut_bytebuf.h"
00028 #include "gr_UnixImage.h"
00029 #include <librsvg/rsvg.h>
00030 
00031 // we need to add this define because of deprecations
00032 #define __RSVG_RSVG_H_INSIDE__
00033 #include <librsvg/rsvg-cairo.h>
00034 #undef __RSVG_RSVG_H_INSIDE__
00035 
00036 class GR_RSVGVectorImage : public GR_CairoVectorImage {
00037  public:
00038 
00039   GR_RSVGVectorImage(const char* name);
00040   virtual ~GR_RSVGVectorImage();
00041 
00042   virtual bool convertToBuffer(UT_ConstByteBufPtr & ppBB) const;
00043   virtual bool convertFromBuffer(const UT_ConstByteBufPtr & pBB,
00044                  const std::string& mimetype,
00045                  UT_sint32 iDisplayWidth,
00046                  UT_sint32 iDisplayHeight);
00047   virtual void cairoSetSource(cairo_t *cr);
00048   virtual void scaleImageTo(GR_Graphics * pG, const UT_Rect & rec);
00049 
00050   virtual bool            hasAlpha(void) const;
00051   virtual bool            isTransparentAt(UT_sint32 x, UT_sint32 y);
00052   virtual GR_Image *  createImageSegment(GR_Graphics *pG, const UT_Rect &rec);
00053 
00054  private:
00055   void reset();
00056   void setupScale(UT_sint32 w, UT_sint32 h);
00057   void createSurface(cairo_t* cairo);
00058   void createImageSurface();
00059   void renderToSurface(cairo_surface_t* surf);
00060   void renderToCairo(cairo_t *cr);
00061 
00062   UT_ByteBufPtr m_data;
00063   RsvgDimensionData m_size;
00064   cairo_t* m_graphics;
00065   cairo_surface_t* m_surface;
00066   cairo_surface_t* m_image_surface;
00067   RsvgHandle* m_svg;
00068   double m_scaleX;
00069   double m_scaleY;
00070   bool m_needsNewSurface;
00071   GR_UnixImage * m_rasterImage;
00072 };
00073 
00074 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1