From 1583a226f4cbfa772cb5bb42950afe44855e20d4 Mon Sep 17 00:00:00 2001 From: Zach Bacon Date: Sun, 27 Aug 2017 13:11:34 -0400 Subject: [PATCH] *Removal of the cairo renderer, it never performed well to begin with. --- src/wx/CMakeLists.txt | 23 -------- src/wx/drawing.h | 14 ----- src/wx/guiinit.cpp | 4 -- src/wx/opts.cpp | 6 +-- src/wx/panel.cpp | 123 ------------------------------------------ src/wx/wxvbam.h | 1 - 6 files changed, 3 insertions(+), 168 deletions(-) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index e56e5218..552d27f9 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -5,11 +5,6 @@ IF(NOT CMAKE_VERSION VERSION_LESS 3.0) cmake_policy(SET CMP0043 NEW) # for wxWidgets ENDIF() -# not yet implemented -SET(CAIRO_DEFAULT OFF) - -option(ENABLE_CAIRO "Enable Cairo rendering for the wxWidgets port" ${CAIRO_DEFAULT}) - if( WIN32 ) # not yet implemented option( ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" ON ) @@ -30,10 +25,6 @@ IF(APPLE) ADD_DEFINITIONS(-DwxMAC_USE_CORE_GRAPHICS) ENDIF(APPLE) -if( NOT ENABLE_CAIRO ) - ADD_DEFINITIONS (-DNO_CAIRO) -endif( NOT ENABLE_CAIRO ) - if( NOT ENABLE_XAUDIO2 ) ADD_DEFINITIONS (-DNO_XAUDIO2) endif( NOT ENABLE_XAUDIO2 ) @@ -130,19 +121,6 @@ FIND_PROGRAM(MSGINIT msginit) if(ENABLE_NLS AND (NOT XGETTEXT OR NOT MSGINIT)) message(SEND_ERROR "Cannot find gettext ${XGETTEXT} ${MSGINIT}") endif(ENABLE_NLS AND (NOT XGETTEXT OR NOT MSGINIT)) -IF(ENABLE_CAIRO) - FIND_PACKAGE ( PkgConfig REQUIRED ) - PKG_CHECK_MODULES(CAIRO REQUIRED cairo) - include_directories(${CAIRO_INCLUDE_DIRS}) - IF(WIN32) - # need gdiplus to extract hdc for cairo context - SET(CAIRO_LIBRARIES ${CAIRO_LIBRARIES} -lgdiplus) - ENDIF(WIN32) - # SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CAIRO_CFLAGS}) -ELSE(ENABLE_CAIRO) - ADD_DEFINITIONS (-DNO_CAIRO) - SET(CAIRO_LIBRARIES ) -ENDIF(ENABLE_CAIRO) IF(WIN32 AND ENABLE_DIRECTX) FIND_PACKGE ( DirectX REQUIRED ) ENDIF(WIN32 AND ENABLE_DIRECTX) @@ -407,7 +385,6 @@ TARGET_LINK_LIBRARIES ( ${wxWidgets_LIBRARIES} ${FFMPEG_LIBRARIES} ${DIRECTX_LIBRARIES} - ${CAIRO_LIBRARIES} ${GTK_LIBRARIES} ${OPENAL_LIBRARY} ) diff --git a/src/wx/drawing.h b/src/wx/drawing.h index b2e14206..2c689675 100644 --- a/src/wx/drawing.h +++ b/src/wx/drawing.h @@ -57,20 +57,6 @@ protected: }; #endif -#ifndef NO_CAIRO -#include - -class CairoDrawingPanel : public DrawingPanel { -public: - CairoDrawingPanel(wxWindow* parent, int _width, int _height); - ~CairoDrawingPanel(); - -protected: - void DrawArea(wxWindowDC&); - cairo_surface_t* conv_surf; -}; -#endif - #if defined(__WXMAC__) class Quartz2DDrawingPanel : public BasicDrawingPanel { public: diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index 3e36ccb9..bc22c0a0 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -3316,10 +3316,6 @@ bool MainFrame::BindControls() if (wxGetApp().UsingWayland()) { rb->Hide(); } -#endif - getrbi("OutputCairo", gopts.render_method, RND_CAIRO); -#ifdef NO_CAIRO - rb->Hide(); #endif getrbi("OutputDirect3D", gopts.render_method, RND_DIRECT3D); #if !defined(__WXMSW__) || defined(NO_D3D) || 1 // not implemented diff --git a/src/wx/opts.cpp b/src/wx/opts.cpp index de00d5e8..ce891bc1 100644 --- a/src/wx/opts.cpp +++ b/src/wx/opts.cpp @@ -156,11 +156,11 @@ opt_desc opts[] = { BOOLOPT("Display/KeepOnTop", "KeepOnTop", wxTRANSLATE("Keep window on top"), gopts.keep_on_top), INTOPT("Display/MaxThreads", "Multithread", wxTRANSLATE("Maximum number of threads to run filters in"), gopts.max_threads, 1, 8), #ifdef __WXMSW__ - ENUMOPT("Display/RenderMethod", "", wxTRANSLATE("Render method; if unsupported, simple method will be used"), gopts.render_method, wxTRANSLATE("simple|opengl|cairo|direct3d")), + ENUMOPT("Display/RenderMethod", "", wxTRANSLATE("Render method; if unsupported, simple method will be used"), gopts.render_method, wxTRANSLATE("simple|opengl|direct3d")), #elif defined(__WXMAC__) - ENUMOPT("Display/RenderMethod", "", wxTRANSLATE("Render method; if unsupported, simple method will be used"), gopts.render_method, wxTRANSLATE("simple|opengl|cairo||quartz2d")), + ENUMOPT("Display/RenderMethod", "", wxTRANSLATE("Render method; if unsupported, simple method will be used"), gopts.render_method, wxTRANSLATE("simple|opengl|quartz2d")), #else - ENUMOPT("Display/RenderMethod", "", wxTRANSLATE("Render method; if unsupported, simple method will be used"), gopts.render_method, wxTRANSLATE("simple|opengl|cairo")), + ENUMOPT("Display/RenderMethod", "", wxTRANSLATE("Render method; if unsupported, simple method will be used"), gopts.render_method, wxTRANSLATE("simple|opengl")), #endif DOUBLEOPT("Display/Scale", "", wxTRANSLATE("Default scale factor"), gopts.video_scale, 1, 6), BOOLOPT("Display/Stretch", "RetainAspect", wxTRANSLATE("Retain aspect ratio when resizing"), gopts.retain_aspect), diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 7dca12b5..c469863d 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1002,11 +1002,6 @@ void GameArea::OnIdle(wxIdleEvent& event) panel = new GLDrawingPanel(this, basic_width, basic_height); break; #endif -#ifndef NO_CAIRO - case RND_CAIRO: - panel = new CairoDrawingPanel(this, basic_width, basic_height); - break; -#endif #ifdef __WXMSW__ case RND_DIRECT3D: panel = new DXDrawingPanel(this, basic_width, basic_height); @@ -2209,124 +2204,6 @@ void GLDrawingPanel::DrawArea(wxWindowDC& dc) #endif // GL support -#ifndef NO_CAIRO - -CairoDrawingPanel::CairoDrawingPanel(wxWindow* parent, int _width, int _height) - : DrawingPanel(parent, _width, _height) -{ - conv_surf = NULL; - - // Intialize color tables in reverse order from default - // probably doesn't help mmx hq3x/hq4x - if (systemColorDepth == 32) { -#if wxBYTE_ORDER == wxLITTLE_ENDIAN - systemBlueShift = 3; - systemRedShift = 19; -#else - systemBlueShift = 27; - systemRedShift = 11; -#endif - } - - // FIXME: should be "true" for GBA carts if lcd mode selected - utilUpdateSystemColorMaps(false); - - if (!did_init) DrawingPanelInit(); -} - -CairoDrawingPanel::~CairoDrawingPanel() -{ - if (conv_surf) - cairo_surface_destroy(conv_surf); -} - -#include -#ifdef __WXMSW__ -#include -#include -#endif -#if defined(__WXMAC__) && wxMAC_USE_CORE_GRAPHICS -#include -#endif - -void CairoDrawingPanel::DrawArea(wxWindowDC& dc) -{ - cairo_t* cr; - wxGraphicsContext* gc = wxGraphicsContext::Create(dc); -#ifdef __WXMSW__ - // not sure why this is so slow - // doing this only once in constructor and resize handler doesn't seem - // to help, and may be unsafe - Gdiplus::Graphics* gr = (Gdiplus::Graphics*)gc->GetNativeContext(); - cairo_surface_t* s = cairo_win32_surface_create(gr->GetHDC()); - cr = cairo_create(s); - cairo_surface_destroy(s); -#else -#ifdef __WXGTK__ - cr = cairo_reference((cairo_t*)gc->GetNativeContext()); -#else -#if defined(__WXMAC__) && wxMAC_USE_CORE_GRAPHICS - CGContextRef c = static_cast(gc->GetNativeContext()); - cairo_surface_t* s = cairo_quartz_surface_create_for_cg_context(c, width, height); - cr = cairo_create(s); - cairo_surface_destroy(s); -#else -#error Cairo rendering is not supported on this platform -#endif -#endif -#endif - cairo_surface_t* surf; - - if (!out_16) - surf = cairo_image_surface_create_for_data(todraw + 4 * width, - CAIRO_FORMAT_RGB24, - width, height, - 4 * (width + 1)); - else { - if (!conv_surf) - conv_surf = cairo_image_surface_create(CAIRO_FORMAT_RGB24, - std::ceil(width * scale), - std::ceil(height * scale)); - - if (!conv_surf) { - wxLogError(_("Cannot create conversion buffer")); - wxGetApp().frame->Close(true); - } - - surf = cairo_surface_reference(conv_surf); - uint16_t* src = (uint16_t*)todraw + (int)std::ceil((width + 2) * scale); // skip top border - uint32_t* dst = (uint32_t*)cairo_image_surface_get_data(surf); - - for (int y = 0; y < std::ceil(height * scale); y++) { - for (int x = 0; x < std::ceil(width * scale); x++, src++) { - *dst++ = (((*src >> systemRedShift) & 0x1f) << 19) | (((*src >> systemGreenShift) & 0x1f) << 11) | (((*src >> systemBlueShift) & 0x1f) << 3); - } - - src += 2; // skip rhs border - } - } - - cairo_pattern_t* pat = cairo_pattern_create_for_surface(surf); - // GOOD is "similar to" bilinear, and FAST is "similar to" nearest - // could also just use BILINEAR and NEAREST directly, I suppose - cairo_pattern_set_filter(pat, gopts.bilinear ? CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST); - double sx, sy; - int w, h; - GetClientSize(&w, &h); - sx = (double)width / w; - sy = (double)height / h; - cairo_matrix_t mat; - cairo_matrix_init_scale(&mat, sx, sy); - cairo_pattern_set_matrix(pat, &mat); - cairo_set_source(cr, pat); - cairo_paint(cr); - cairo_pattern_destroy(pat); - cairo_surface_destroy(surf); - cairo_destroy(cr); - delete gc; -} -#endif - #if defined(__WXMSW__) && !defined(NO_D3D) #define DIRECT3D_VERSION 0x0900 #include diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index d264d396..98459e30 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -436,7 +436,6 @@ enum ifbfunc { enum renderer { RND_SIMPLE, RND_OPENGL, - RND_CAIRO, RND_DIRECT3D, RND_QUARTZ2D, };