From 10dd5023e2d10882f37909310446699abf22622b Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 24 Apr 2013 09:48:34 +0200 Subject: [PATCH] Removed BeginLayer and EndLayer functions. Resolved Cairo layers drawing problem in a different way. --- common/gal/cairo/cairo_gal.cpp | 33 +++++++++++++----------- common/gal/opengl/opengl_gal.cpp | 9 ------- include/gal/cairo/cairo_gal.h | 11 +------- include/gal/graphics_abstraction_layer.h | 6 ----- include/gal/opengl/opengl_gal.h | 6 ----- 5 files changed, 19 insertions(+), 46 deletions(-) diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index bc97df090c..09c460034d 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -178,6 +178,8 @@ void CAIRO_GAL::BeginDrawing() throw( int ) lineWidth = 0; isDeleteSavedPixels = true; + + cairo_push_group( cairoImage ); } @@ -186,6 +188,9 @@ void CAIRO_GAL::EndDrawing() // Force remaining objects to be drawn Flush(); + cairo_pop_group_to_source( cairoImage ); + cairo_paint_with_alpha( cairoImage, fillColor.a ); + // This code was taken from the wxCairo example - it's not the most efficient one // Here is a good place for optimizations @@ -521,6 +526,19 @@ void CAIRO_GAL::ClearScreen() } +void CAIRO_GAL::SetLayerDepth( double aLayerDepth ) +{ + super::SetLayerDepth( aLayerDepth ); + + storePath(); + + cairo_pop_group_to_source( cairoImage ); + cairo_paint_with_alpha( cairoImage, fillColor.a ); + + cairo_push_group( cairoImage ); +} + + void CAIRO_GAL::Transform( MATRIX3x3D aTransformation ) { cairo_matrix_t cairoTransformation; @@ -617,21 +635,6 @@ 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 diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 710730785a..77bab85e86 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1288,15 +1288,6 @@ void OPENGL_GAL::Restore() } -void OPENGL_GAL::BeginLayer() -{ -} - -void OPENGL_GAL::EndLayer() -{ -} - - // TODO Error handling int OPENGL_GAL::BeginGroup() { diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index 36cae06c6e..5eb425e81e 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -95,12 +95,6 @@ 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 ); @@ -178,10 +172,7 @@ public: double GetLineWidth(); /// @copydoc GAL::SetLayerDepth() - virtual void SetLayerDepth( double aLayerDepth ) - { - super::SetLayerDepth( aLayerDepth ); - } + virtual void SetLayerDepth( double aLayerDepth ); // -------------- // Transformation diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 1940b047ab..245508b7a2 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -95,12 +95,6 @@ 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. * diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index d01028112b..ce4ff73c39 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -102,12 +102,6 @@ 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 );