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()
}
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()
{
// If the grouping is started: the actual path is stored in the group, when
......@@ -693,15 +708,13 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber )
break;
case CMD_STROKE_PATH:
cairo_set_source_rgba( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b,
strokeColor.a );
cairo_set_source_rgb( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b );
cairo_append_path( cairoImage, it->cairoPath );
cairo_stroke( cairoImage );
break;
case CMD_FILL_PATH:
cairo_set_source_rgba( cairoImage, fillColor.r, fillColor.g, fillColor.b,
fillColor.a );
cairo_set_source_rgb( cairoImage, fillColor.r, fillColor.g, fillColor.b );
cairo_append_path( cairoImage, it->cairoPath );
cairo_fill( cairoImage );
break;
......@@ -779,15 +792,13 @@ void CAIRO_GAL::storePath()
{
if( isFillEnabled )
{
cairo_set_source_rgba( cairoImage, fillColor.r, fillColor.g, fillColor.b,
fillColor.a );
cairo_set_source_rgb( cairoImage, fillColor.r, fillColor.g, fillColor.b );
cairo_fill_preserve( cairoImage );
}
if( isStrokeEnabled )
{
cairo_set_source_rgba( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b,
strokeColor.a );
cairo_set_source_rgb( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b );
cairo_stroke_preserve( cairoImage );
}
}
......
......@@ -1283,6 +1283,15 @@ void OPENGL_GAL::Restore()
}
void OPENGL_GAL::BeginLayer()
{
}
void OPENGL_GAL::EndLayer()
{
}
// TODO Error handling
int OPENGL_GAL::BeginGroup()
{
......
......@@ -419,9 +419,11 @@ void VIEW::redrawRect( const BOX2I& aRect )
{
drawItem drawFunc( this, l->id );
m_gal->BeginLayer();
m_gal->SetLayerDepth( (double) l->renderingOrder );
l->items->Query( aRect, drawFunc );
l->isDirty = false;
m_gal->EndLayer();
totalItems += drawFunc.count;
totalDrawTime += drawFunc.time;
......
......@@ -95,6 +95,12 @@ public:
/// @copydoc GAL::EndDrawing()
virtual void EndDrawing();
/// @copydoc GAL::BeginLayer()
virtual void BeginLayer();
/// @copydoc GAL::EndLayer()
virtual void EndLayer();
/// @copydoc GAL::DrawLine()
virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
......
......@@ -95,6 +95,12 @@ public:
/// @brief End the drawing, needs to be called for every new frame.
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.
*
......
......@@ -102,6 +102,12 @@ public:
/// @copydoc GAL::EndDrawing()
virtual void EndDrawing();
/// @copydoc GAL::BeginLayer()
virtual void BeginLayer();
/// @copydoc GAL::EndLayer()
virtual void EndLayer();
/// @copydoc GAL::DrawLine()
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