Author: Carlos Lopez <[email protected]>
Date: Sun Mar 10 17:35:23 2013 +0100
Use start_frame and end_frame for the Target_Cairo_Tile class instead of the
obtain surface and put surface. The pure virtual member add_tile would take
care of each rendered tile instead of put surface.
---
synfig-core/src/synfig/target_cairo.cpp | 2 +-
synfig-core/src/synfig/target_cairo_tile.cpp | 52 ++++++-------------------
synfig-core/src/synfig/target_cairo_tile.h | 14 ++++---
3 files changed, 22 insertions(+), 46 deletions(-)
diff --git a/synfig-core/src/synfig/target_cairo.cpp
b/synfig-core/src/synfig/target_cairo.cpp
index 4dae633..b7e2a38 100644
--- a/synfig-core/src/synfig/target_cairo.cpp
+++ b/synfig-core/src/synfig/target_cairo.cpp
@@ -142,7 +142,7 @@ synfig::Target_Cairo::render(ProgressCallback *cb)
if(!context.accelerated_cairorender(surface,quality,desc,cb))
{
// For some reason, the accelerated
renderer failed.
- if(cb)cb->error(_("Accelerated Renderer
Failure"));
+ if(cb)cb->error(_("Frame Renderer
Failure"));
return false;
}
else
diff --git a/synfig-core/src/synfig/target_cairo_tile.cpp
b/synfig-core/src/synfig/target_cairo_tile.cpp
index a120d2b..fc2bf7f 100644
--- a/synfig-core/src/synfig/target_cairo_tile.cpp
+++ b/synfig-core/src/synfig/target_cairo_tile.cpp
@@ -97,7 +97,7 @@ Target_Cairo_Tile::next_tile(int& x, int& y)
}
bool
-synfig::Target_Cairo_Tile::render_frame_(cairo_surface_t* target_surface,
Context context,ProgressCallback *cb)
+synfig::Target_Cairo_Tile::render_frame_(Context context,ProgressCallback *cb)
{
if(tile_w_<=0||tile_h_<=0)
{
@@ -151,7 +151,7 @@ synfig::Target_Cairo_Tile::render_frame_(cairo_surface_t*
target_surface, Contex
return false;
}
// Add the tile to the target
- if(!add_tile(surface, target_surface, x,y))
+ if(!add_tile(surface, x,y))
{
if(cb)cb->error(_("add_tile():Unable to put
surface on target"));
return false;
@@ -206,6 +206,12 @@ synfig::Target_Cairo_Tile::render(ProgressCallback *cb)
if(cb &&
!cb->amount_complete(total_frames-frames,total_frames))
return false;
+ if(!start_frame(cb))
+ {
+ if(cb)cb->error(_("Can't start frame"));
+ return false;
+ }
+
// Set the time that we wish to render
if(!get_avoid_time_sync() || canvas->get_time()!=t)
canvas->set_time(t);
@@ -226,32 +232,13 @@ synfig::Target_Cairo_Tile::render(ProgressCallback *cb)
#else
context=canvas->get_context();
#endif
- // Obtain a pointer to the cairo_surface_t given by the
Target instance.
- cairo_surface_t* surface;
- if(obtain_surface(surface))
+ if(!render_frame_(context,cb))
{
- if(!render_frame_(surface,context,cb))
- {
- // For some reason, the accelerated
renderer failed.
- if(cb)cb->error(_("Accelerated Renderer
Failure"));
- return false;
- }
- else
- {
- // Put the surface we renderer onto the
target's device.
- // and destrois cairo_surface_t
- if(!put_surface(surface, cb))
- {
- if(cb)cb->error(_("Unable to
put surface on target"));
- return false;
- }
- }
- }
- else
- {
- if(cb)cb->error(_("Can't obtain a valid
surface"));
- return false;
+ // For some reason, the accelerated renderer
failed.
+ if(cb)cb->error(_("Accelerated Renderer
Failure"));
+ return false;
}
+ end_frame();
}while(frames);
}
catch(String str)
@@ -272,19 +259,6 @@ synfig::Target_Cairo_Tile::render(ProgressCallback *cb)
return true;
}
-bool
-Target_Cairo_Tile::put_surface(cairo_surface_t *surface, ProgressCallback *cb)
-{
- if(cairo_surface_status(surface))
- {
- if(cb) cb->error(_("Cairo Surface bad status"));
- return false;
- }
- cairo_surface_flush(surface);
- cairo_surface_destroy(surface);
- return true;
-}
-
void
Target_Cairo_Tile::gamma_filter(cairo_surface_t *surface)
{
diff --git a/synfig-core/src/synfig/target_cairo_tile.h
b/synfig-core/src/synfig/target_cairo_tile.h
index 6644745..0fd059e 100644
--- a/synfig-core/src/synfig/target_cairo_tile.h
+++ b/synfig-core/src/synfig/target_cairo_tile.h
@@ -115,13 +115,15 @@ public:
void set_clipping(bool x) { clipping_=x; }
- //! Obtain a surface pointer based on the render method
- //! this function has to be overrrided by the derived targets
- //! to create the proper Cairo backend surface for each target type.
- virtual bool obtain_surface(cairo_surface_t*&)=0;
+ //! Marks the start of a frame
+ /*! \return \c true on success, \c false upon an error.
+ ** \see end_frame()*/
+ virtual bool start_frame(ProgressCallback *cb=NULL)=0;
+
+ //! Marks the end of a frame
+ /*! \see start_frame() */
+ virtual void end_frame()=0;
- //! Puts the rendered surface onto the target.
- virtual bool put_surface(cairo_surface_t *surface, ProgressCallback
*cb=NULL);
//! Filters the cairo surface based on gamma (hardcored for the moment
to 2.2)
static void gamma_filter(cairo_surface_t* surface);
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl