Commit a43dd351 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Assured that there are no excessive initializations

parent 1a4c6781
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
    paintListener = aPaintListener;

    isGrouping          = false;
    isInitialized       = false;
    isDeleteSavedPixels = false;
    zoomFactor          = 1.0;

    SetSize( aParent->GetSize() );
@@ -76,10 +78,6 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
    lineJoinMap[LINE_JOIN_ROUND] = CAIRO_LINE_JOIN_ROUND;
    lineJoinMap[LINE_JOIN_MITER] = CAIRO_LINE_JOIN_MITER;

    isDeleteSavedPixels = false;

    isGrouping = false;

    // Initialize the cursor shape
    SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
    initCursor( 21 );
@@ -91,13 +89,13 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
    SetGridColor( COLOR4D( 0.5, 0.5, 0.5, 0.3 ) );
    SetCoarseGrid( 10 );
    SetGridLineWidth( 0.5 );

    Refresh();
}


CAIRO_GAL::~CAIRO_GAL()
{
    deinitSurface();

    delete cursorPixels;
    delete cursorPixelsSaved;

@@ -139,6 +137,9 @@ void CAIRO_GAL::skipMouseEvent( wxMouseEvent& aEvent )

void CAIRO_GAL::initSurface()
{
    if( isInitialized )
        return;

    // The size of the client area needs to be greater than zero
    clientRectangle = parentWindow->GetClientRect();

@@ -184,14 +185,21 @@ void CAIRO_GAL::initSurface()
    lineWidth = 0;

    isDeleteSavedPixels = true;

    isInitialized = true;
}


void CAIRO_GAL::deinitSurface()
{
    if( !isInitialized )
        return;

    // Destroy Cairo objects
    cairo_destroy( cairoImage );
    cairo_surface_destroy( cairoSurface );

    isInitialized = false;
}


@@ -548,6 +556,8 @@ void CAIRO_GAL::SetLayerDepth( double aLayerDepth )
{
    super::SetLayerDepth( aLayerDepth );

    if( isInitialized )
    {
        storePath();

        cairo_pop_group_to_source( cairoImage );
@@ -555,6 +565,7 @@ void CAIRO_GAL::SetLayerDepth( double aLayerDepth )

        cairo_push_group( cairoImage );
    }
}


void CAIRO_GAL::Transform( MATRIX3x3D aTransformation )
+1 −0
Original line number Diff line number Diff line
@@ -359,6 +359,7 @@ private:
    unsigned int*       bitmapBuffer;           ///< Storage of the cairo image
    unsigned int*       bitmapBufferBackup;     ///< Backup storage of the cairo image
    int                 stride;                 ///< Stride value for Cairo
    bool                isInitialized;          ///< Are Cairo image & surface ready to use

    // Mapping between Cairo and GAL line attributes
    std::map<LineCap, cairo_line_cap_t>     lineCapMap;     ///< Line cap style mapping