diff --git a/common/gal/cairo/cairo_compositor.cpp b/common/gal/cairo/cairo_compositor.cpp index 3ac229e6b0..3b1117f563 100644 --- a/common/gal/cairo/cairo_compositor.cpp +++ b/common/gal/cairo/cairo_compositor.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -93,13 +94,11 @@ void CAIRO_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight ) unsigned int CAIRO_COMPOSITOR::CreateBuffer() { // Pixel storage - BitmapPtr bitmap( new unsigned int[m_bufferSize] ); - - memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) ); + BitmapPtr bitmap = new uint32_t[m_bufferSize](); // Create the Cairo surface cairo_surface_t* surface = cairo_image_surface_create_for_data( - (unsigned char*) bitmap.get(), + (unsigned char*) bitmap, CAIRO_FORMAT_ARGB32, m_width, m_height, m_stride ); cairo_t* context = cairo_create( surface ); @@ -144,7 +143,7 @@ void CAIRO_COMPOSITOR::Begin() void CAIRO_COMPOSITOR::ClearBuffer( const COLOR4D& aColor ) { // Clear the pixel storage - memset( m_buffers[m_current].bitmap.get(), 0x00, m_bufferSize * sizeof(int) ); + memset( m_buffers[m_current].bitmap, 0x00, m_bufferSize * sizeof(int) ); } @@ -177,6 +176,7 @@ void CAIRO_COMPOSITOR::clean() { cairo_destroy( it->context ); cairo_surface_destroy( it->surface ); + delete it->bitmap; } m_buffers.clear(); diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index 05b01e22ad..31b1323616 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -1257,6 +1257,7 @@ void CAIRO_GAL::endDrawing() // Now translate the raw context data from the format stored // by cairo into a format understood by wxImage. + pixman_image_t* dstImg = pixman_image_create_bits( PIXMAN_r8g8b8, screenSize.x, screenSize.y, (uint32_t*) wxOutput, wxBufferWidth * 3 ); pixman_image_t* srcImg = pixman_image_create_bits( PIXMAN_a8b8g8r8, @@ -1269,7 +1270,7 @@ void CAIRO_GAL::endDrawing() pixman_image_unref( srcImg ); pixman_image_unref( dstImg ); - wxImage img( wxBufferWidth, screenSize.y, (unsigned char*) wxOutput, true ); + wxImage img( wxBufferWidth, screenSize.y, wxOutput, true ); wxBitmap bmp( img ); wxMemoryDC mdc( bmp ); wxClientDC clientDC( this ); @@ -1310,37 +1311,6 @@ bool CAIRO_GAL::Show( bool aShow ) } -void CAIRO_GAL::SaveScreen() -{ - // Copy the current bitmap to the backup buffer - int offset = 0; - - for( int j = 0; j < screenSize.y; j++ ) - { - for( int i = 0; i < stride; i++ ) - { - bitmapBufferBackup[offset + i] = bitmapBuffer[offset + i]; - offset += stride; - } - } -} - - -void CAIRO_GAL::RestoreScreen() -{ - int offset = 0; - - for( int j = 0; j < screenSize.y; j++ ) - { - for( int i = 0; i < stride; i++ ) - { - bitmapBuffer[offset + i] = bitmapBufferBackup[offset + i]; - offset += stride; - } - } -} - - int CAIRO_GAL::BeginGroup() { initSurface(); @@ -1420,7 +1390,7 @@ void CAIRO_GAL::initSurface() if( isInitialized ) return; - surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT, + surface = cairo_image_surface_create_for_data( bitmapBuffer, GAL_FORMAT, wxBufferWidth, screenSize.y, stride ); context = cairo_create( surface ); @@ -1458,8 +1428,7 @@ void CAIRO_GAL::allocateBitmaps() stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth ); bufferSize = stride * screenSize.y; - bitmapBuffer = new unsigned int[bufferSize]; - bitmapBufferBackup = new unsigned int[bufferSize]; + bitmapBuffer = new unsigned char[bufferSize * 4]; wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y]; } @@ -1467,7 +1436,6 @@ void CAIRO_GAL::allocateBitmaps() void CAIRO_GAL::deleteBitmaps() { delete[] bitmapBuffer; - delete[] bitmapBufferBackup; delete[] wxOutput; } diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index eae1baaf56..c91e6b5da2 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1526,18 +1526,6 @@ void OPENGL_GAL::ClearCache() } -void OPENGL_GAL::SaveScreen() -{ - wxASSERT_MSG( false, wxT( "Not implemented yet" ) ); -} - - -void OPENGL_GAL::RestoreScreen() -{ - wxASSERT_MSG( false, wxT( "Not implemented yet" ) ); -} - - void OPENGL_GAL::SetTarget( RENDER_TARGET aTarget ) { switch( aTarget ) diff --git a/include/gal/cairo/cairo_compositor.h b/include/gal/cairo/cairo_compositor.h index b742555971..1cf70f925f 100644 --- a/include/gal/cairo/cairo_compositor.h +++ b/include/gal/cairo/cairo_compositor.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -34,7 +35,8 @@ #include #include #include -#include + +#include #include namespace KIGFX @@ -107,7 +109,7 @@ public: } protected: - typedef boost::shared_array BitmapPtr; + typedef uint32_t* BitmapPtr; typedef struct { cairo_t* context; ///< Main texture handle diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index ad28a2f109..669daf4dd1 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -341,7 +341,7 @@ protected: /// Format used to store pixels - static constexpr cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24; + static constexpr cairo_format_t GAL_FORMAT = CAIRO_FORMAT_ARGB32; }; @@ -379,10 +379,6 @@ public: virtual bool Show( bool aShow ) override; - virtual void SaveScreen() override; - - virtual void RestoreScreen() override; - virtual int BeginGroup() override; virtual void EndGroup() override; @@ -433,8 +429,7 @@ protected: unsigned char* wxOutput; ///< wxImage comaptible buffer // Variables related to Cairo <-> wxWidgets - unsigned int* bitmapBuffer; ///< Storage of the cairo image - unsigned int* bitmapBufferBackup; ///< Backup storage of the cairo image + unsigned char* bitmapBuffer; ///< Storage of the cairo image int stride; ///< Stride value for Cairo int wxBufferWidth; bool isInitialized; ///< Are Cairo image & surface ready to use diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index f2fffbb839..05bd5968af 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -800,16 +800,6 @@ public: // Buffer manipulation methods // --------------------------- - /** - * @brief Save the screen contents. - */ - virtual void SaveScreen() {}; - - /** - * @brief Restore the screen contents. - */ - virtual void RestoreScreen() {}; - /** * @brief Sets the target for rendering. * diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index 87d72f2c96..4ea5606465 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -218,12 +218,6 @@ public: // Handling the world <-> screen transformation // -------------------------------------------------------- - /// @copydoc GAL::SaveScreen() - virtual void SaveScreen() override; - - /// @copydoc GAL::RestoreScreen() - virtual void RestoreScreen() override; - /// @copydoc GAL::SetTarget() virtual void SetTarget( RENDER_TARGET aTarget ) override;