Author: Carlos Lopez <[email protected]>
Date: Tue Oct 23 18:44:27 2012 +0200
CairoSurface: Now get_cairo_surface would return NULL in case cs_ is null
instead of assert(0). Added get_cairo_image_surface to obtain the mapped image
surface and added is_mapped that returns true when cs_image_ is not NULL.
Modify unmap_cairo_image to restore cs_image_ to NULL once unmapped.
---
synfig-core/src/synfig/surface.cpp | 25 +++++++++++++++++++++----
synfig-core/src/synfig/surface.h | 5 +++++
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/synfig-core/src/synfig/surface.cpp
b/synfig-core/src/synfig/surface.cpp
index edca9cc..722dfa4 100644
--- a/synfig-core/src/synfig/surface.cpp
+++ b/synfig-core/src/synfig/surface.cpp
@@ -333,13 +333,25 @@ CairoSurface::set_cairo_surface(cairo_surface_t *cs)
}
}
-cairo_surface_t*
+cairo_surface_t*
CairoSurface::get_cairo_surface()const
{
- assert(cs_);
- return cairo_surface_reference(cs_);
+ if(cs_==NULL)
+ return NULL;
+ else
+ return cairo_surface_reference(cs_);
+}
+
+cairo_surface_t*
+CairoSurface::get_cairo_image_surface()const
+{
+ if(cs_image_==NULL)
+ return NULL;
+ else
+ return cairo_surface_reference(cs_image_);
}
+
bool
CairoSurface::map_cairo_image()
{
@@ -386,6 +398,7 @@ CairoSurface::unmap_cairo_image()
cairo_surface_mark_dirty(cs_image_);
// this will destroy cs_image_
cairo_surface_unmap_image(cs_, cs_image_);
+ cs_image_=NULL;
#else
assert(false); // Old versions of cairo are not supported
#endif
@@ -398,6 +411,10 @@ CairoSurface::unmap_cairo_image()
}
-
+bool
+CairoSurface::is_mapped()const
+{
+ return (cs_image_!=NULL);
+}
diff --git a/synfig-core/src/synfig/surface.h b/synfig-core/src/synfig/surface.h
index de14107..4650a22 100644
--- a/synfig-core/src/synfig/surface.h
+++ b/synfig-core/src/synfig/surface.h
@@ -167,6 +167,9 @@ public:
// Returns an increased reference pointer of the surface. The receiver
is responsible
// of destroy the surface once referenced.
cairo_surface_t* get_cairo_surface()const;
+ // Returns an increased reference pointer of the image surface. The
receiver is responsible
+ // of destroy the surface once referenced.
+ cairo_surface_t* get_cairo_image_surface()const;
// Maps cs_ to cs_image_ and extract the *data to etl::surface::data
for further modifications
// It will flush any remaining painting operation to the cs_
// returns true on success or false if something failed
@@ -174,6 +177,8 @@ public:
// Unmap the cs_image_ to cs_ after external modification has been done
via *data
// It will mark cs_ as dirty
void unmap_cairo_image();
+ // Returns true if the cairo_surface_t* cs_ is mapped on cs_image_
+ bool is_mapped()const;
}; // END of class Surface
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl