Commit ad4a72ff authored by Maciej Suminski's avatar Maciej Suminski

Cairo now renders layers properly (colors are not saturated after layer composition), but slower.

parent 062fc2d2
...@@ -612,6 +612,21 @@ void CAIRO_GAL::Restore() ...@@ -612,6 +612,21 @@ void CAIRO_GAL::Restore()
} }
void CAIRO_GAL::BeginLayer()
{
cairo_push_group( cairoImage );
}
void CAIRO_GAL::EndLayer()
{
storePath();
cairo_pop_group_to_source( cairoImage );
cairo_paint_with_alpha( cairoImage, fillColor.a );
}
int CAIRO_GAL::BeginGroup() int CAIRO_GAL::BeginGroup()
{ {
// If the grouping is started: the actual path is stored in the group, when // If the grouping is started: the actual path is stored in the group, when
...@@ -693,15 +708,13 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber ) ...@@ -693,15 +708,13 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber )
break; break;
case CMD_STROKE_PATH: case CMD_STROKE_PATH:
cairo_set_source_rgba( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b, cairo_set_source_rgb( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b );
strokeColor.a );
cairo_append_path( cairoImage, it->cairoPath ); cairo_append_path( cairoImage, it->cairoPath );
cairo_stroke( cairoImage ); cairo_stroke( cairoImage );
break; break;
case CMD_FILL_PATH: case CMD_FILL_PATH:
cairo_set_source_rgba( cairoImage, fillColor.r, fillColor.g, fillColor.b, cairo_set_source_rgb( cairoImage, fillColor.r, fillColor.g, fillColor.b );
fillColor.a );
cairo_append_path( cairoImage, it->cairoPath ); cairo_append_path( cairoImage, it->cairoPath );
cairo_fill( cairoImage ); cairo_fill( cairoImage );
break; break;
...@@ -779,15 +792,13 @@ void CAIRO_GAL::storePath() ...@@ -779,15 +792,13 @@ void CAIRO_GAL::storePath()
{ {
if( isFillEnabled ) if( isFillEnabled )
{ {
cairo_set_source_rgba( cairoImage, fillColor.r, fillColor.g, fillColor.b, cairo_set_source_rgb( cairoImage, fillColor.r, fillColor.g, fillColor.b );
fillColor.a );
cairo_fill_preserve( cairoImage ); cairo_fill_preserve( cairoImage );
} }
if( isStrokeEnabled ) if( isStrokeEnabled )
{ {
cairo_set_source_rgba( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b, cairo_set_source_rgb( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b );
strokeColor.a );
cairo_stroke_preserve( cairoImage ); cairo_stroke_preserve( cairoImage );
} }
} }
......
...@@ -1283,6 +1283,15 @@ void OPENGL_GAL::Restore() ...@@ -1283,6 +1283,15 @@ void OPENGL_GAL::Restore()
} }
void OPENGL_GAL::BeginLayer()
{
}
void OPENGL_GAL::EndLayer()
{
}
// TODO Error handling // TODO Error handling
int OPENGL_GAL::BeginGroup() int OPENGL_GAL::BeginGroup()
{ {
......
...@@ -419,9 +419,11 @@ void VIEW::redrawRect( const BOX2I& aRect ) ...@@ -419,9 +419,11 @@ void VIEW::redrawRect( const BOX2I& aRect )
{ {
drawItem drawFunc( this, l->id ); drawItem drawFunc( this, l->id );
m_gal->BeginLayer();
m_gal->SetLayerDepth( (double) l->renderingOrder ); m_gal->SetLayerDepth( (double) l->renderingOrder );
l->items->Query( aRect, drawFunc ); l->items->Query( aRect, drawFunc );
l->isDirty = false; l->isDirty = false;
m_gal->EndLayer();
totalItems += drawFunc.count; totalItems += drawFunc.count;
totalDrawTime += drawFunc.time; totalDrawTime += drawFunc.time;
......
...@@ -95,6 +95,12 @@ public: ...@@ -95,6 +95,12 @@ public:
/// @copydoc GAL::EndDrawing() /// @copydoc GAL::EndDrawing()
virtual void EndDrawing(); virtual void EndDrawing();
/// @copydoc GAL::BeginLayer()
virtual void BeginLayer();
/// @copydoc GAL::EndLayer()
virtual void EndLayer();
/// @copydoc GAL::DrawLine() /// @copydoc GAL::DrawLine()
virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
......
...@@ -95,6 +95,12 @@ public: ...@@ -95,6 +95,12 @@ public:
/// @brief End the drawing, needs to be called for every new frame. /// @brief End the drawing, needs to be called for every new frame.
virtual void EndDrawing() = 0; virtual void EndDrawing() = 0;
/// @brief Begin the layer drawing, needs to be called for every new layer.
virtual void BeginLayer() = 0;
/// @brief Finish the layer drawing, needs to be called for every new layer.
virtual void EndLayer() = 0;
/** /**
* @brief Draw a line. * @brief Draw a line.
* *
......
...@@ -102,6 +102,12 @@ public: ...@@ -102,6 +102,12 @@ public:
/// @copydoc GAL::EndDrawing() /// @copydoc GAL::EndDrawing()
virtual void EndDrawing(); virtual void EndDrawing();
/// @copydoc GAL::BeginLayer()
virtual void BeginLayer();
/// @copydoc GAL::EndLayer()
virtual void EndLayer();
/// @copydoc GAL::DrawLine() /// @copydoc GAL::DrawLine()
virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment