Revert accidental changes to the samples

This reverts parts of 533958be10 (recreating Xcode project files with
new script, 2022-04-16) that seem to have been committed accidentally
and are now preventing CI builds from passing.
This commit is contained in:
Vadim Zeitlin
2022-04-16 15:33:05 +02:00
parent 88f5a14d34
commit a47382f95d
3 changed files with 4 additions and 102 deletions

View File

@@ -36,81 +36,6 @@
#include "canvas.h" #include "canvas.h"
// ============================================================================
// implementations
// ============================================================================
class ImageRGBMatcher
{
public:
ImageRGBMatcher(const wxImage& image, int tolerance)
: m_image(image)
, m_tolerance(tolerance)
{
}
bool match(const wxImage& other)
{
if ( other.GetWidth() != m_image.GetWidth() )
return false;
if ( other.GetHeight() != m_image.GetHeight() )
return false;
if ( memcmp(other.GetData(), m_image.GetData(),
other.GetWidth()*other.GetHeight()*3) == 0 )
return true;
const unsigned char* d1 = m_image.GetData();
const unsigned char* d2 = other.GetData();
for ( int x = 0; x < m_image.GetWidth(); ++x )
{
for ( int y = 0; y < m_image.GetHeight(); ++y )
{
const unsigned char diff = *d1 > * d2 ? *d1 - *d2 : *d2 - *d1;
if (diff > m_tolerance)
{
m_diffDesc.Printf
(
"first mismatch is at (%d, %d) which "
"has value 0x%06x instead of the "
"expected 0x%06x",
x, y, *d2, *d1
);
// Don't show all mismatches, there may be too many of them.
return false;
}
++d1;
++d2;
}
}
// We can only get here when the images are different AND we've not exited the
// method from the loop. That implies the tolerance must have caused this.
wxASSERT_MSG(m_tolerance > 0, "Unreachable without tolerance");
return true;
}
private:
const wxImage m_image;
const int m_tolerance;
mutable wxString m_diffDesc;
};
inline ImageRGBMatcher RGBSameAs(const wxImage& image)
{
return ImageRGBMatcher(image, 0);
}
// Allows small differences (within given tolerance) for r, g, and b values.
inline ImageRGBMatcher RGBSimilarTo(const wxImage& image, int tolerance)
{
return ImageRGBMatcher(image, tolerance);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// MyCanvas // MyCanvas
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -181,16 +106,6 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
else else
{ {
my_toucan = wxBitmap(image); my_toucan = wxBitmap(image);
bool result = false;
{
if( my_toucan.IsOk() )
{
auto match = RGBSimilarTo( my_toucan.ConvertToImage() , 2 );
result = match.match(image);
}
}
} }
my_toucan_flipped_horiz = wxBitmap(image.Mirror(true)); my_toucan_flipped_horiz = wxBitmap(image.Mirror(true));

View File

@@ -1012,6 +1012,10 @@ protected:
} }
}; };
// ============================================================================
// implementations
// ============================================================================
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// MyImageFrame // MyImageFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1153,7 +1157,6 @@ MyFrame::MyFrame()
// 500 width * 2750 height // 500 width * 2750 height
m_canvas->SetScrollbars( 10, 10, 50, 275 ); m_canvas->SetScrollbars( 10, 10, 50, 275 );
m_canvas->SetCursor(wxImage("cursor.png")); m_canvas->SetCursor(wxImage("cursor.png"));
} }
void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) ) void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )

16
samples/minimal/minimal.cpp Executable file → Normal file
View File

@@ -63,8 +63,6 @@ public:
// event handlers (these functions should _not_ be virtual) // event handlers (these functions should _not_ be virtual)
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
void OnPaint(wxPaintEvent& event);
void OnClick(wxMouseEvent& event);
private: private:
// any class wishing to process wxWidgets events must use this macro // any class wishing to process wxWidgets events must use this macro
@@ -97,8 +95,6 @@ enum
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
EVT_MENU(Minimal_About, MyFrame::OnAbout) EVT_MENU(Minimal_About, MyFrame::OnAbout)
EVT_PAINT( MyFrame::OnPaint)
EVT_LEFT_DOWN( MyFrame::OnClick)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
// Create a new application object: this macro will allow wxWidgets to create // Create a new application object: this macro will allow wxWidgets to create
@@ -181,18 +177,6 @@ MyFrame::MyFrame(const wxString& title)
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
} }
void MyFrame::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
wxRect update = GetUpdateRegion().GetBox();
printf("update %d,%d,%d,%d\n",update.GetX(), update.GetY(), update.GetWidth(), update.GetHeight());
}
void MyFrame::OnClick(wxMouseEvent& event)
{
wxRect r( event.GetX(), event.GetY(),2,2);
RefreshRect(r);
}
// event handlers // event handlers