Stop playing tricks with the width to account for a border.

Just scale the thing and not worry about it.
Still have to do a little hacking for 24bit :/
This commit is contained in:
Arthur Moore 2015-03-12 13:13:31 -04:00
parent a68d9cf44a
commit 13b22f7a6d
2 changed files with 15 additions and 23 deletions

View File

@ -83,9 +83,9 @@ public:
//32 bit filter, so 4 bytes per pixel //32 bit filter, so 4 bytes per pixel
// The +1 is for a 1 pixel border that the emulator spits out // The +1 is for a 1 pixel border that the emulator spits out
horiz_bytes = (width+1) * 4; horiz_bytes = width * 4;
//Unfortunately, the filter keeps the border on the scaled output, but DOES NOT scale it //Unfortunately, the filter keeps the border on the scaled output, but DOES NOT scale it
horiz_bytes_out = width * 4 * myScale + 4; horiz_bytes_out = horiz_bytes * myScale;
} }
unsigned int getWidth() unsigned int getWidth()

View File

@ -979,7 +979,7 @@ END_EVENT_TABLE()
IMPLEMENT_ABSTRACT_CLASS(DrawingPanel, wxEvtHandler) IMPLEMENT_ABSTRACT_CLASS(DrawingPanel, wxEvtHandler)
DrawingPanel::DrawingPanel(int _width, int _height) : DrawingPanel::DrawingPanel(int _width, int _height) :
wxObject(), width(_width), height(_height), scale(1), todraw(0), wxObject(), width(_width+1), height(_height), scale(1), todraw(0),
pixbuf1(0), pixbuf2(0), rpi(0), nthreads(0) pixbuf1(0), pixbuf2(0), rpi(0), nthreads(0)
{ {
myFilter = new filter(std::string(gopts.filter.mb_str(wxConvUTF8))); myFilter = new filter(std::string(gopts.filter.mb_str(wxConvUTF8)));
@ -1074,22 +1074,14 @@ public:
// This is the lower height value of the band this thread will process // This is the lower height value of the band this thread will process
int band_lower = band_height * threadno; int band_lower = band_height * threadno;
//Set the starting location for the destination buffer
//Unfortunately, the filter keeps the border on the scaled output, but DOES NOT scale it dst += width * scale * band_lower * scale;
unsigned int scaled_width = width * scale + 1;
// + 1 for stupid top border
dst += scaled_width * (band_lower + 1) * scale;
//There is a 1 pixel border not included in the official width
width += 1;
while(nthreads == 1 || sig.Wait() == wxCOND_NO_ERROR) { while(nthreads == 1 || sig.Wait() == wxCOND_NO_ERROR) {
if(!src /* && nthreads > 1 */ ) { if(!src /* && nthreads > 1 */ ) {
lock.Unlock(); lock.Unlock();
return 0; return 0;
} }
// + 1 for stupid top border
src += width;
if(!mainFilter || !iFilter) if(!mainFilter || !iFilter)
{ {
@ -1132,7 +1124,7 @@ void DrawingPanel::DrawArea(u8 **data)
//The number of bytes per pixel, as determined by the systemColorDepth //The number of bytes per pixel, as determined by the systemColorDepth
int bytes_per_pixel = systemColorDepth/8; int bytes_per_pixel = systemColorDepth/8;
//Used for determining size of the buffer to allocate //Used for determining size of the buffer to allocate
int horiz_bytes_out = (width+2)* bytes_per_pixel * scale; int horiz_bytes_out = width * bytes_per_pixel * scale;
if(!pixbuf2) { if(!pixbuf2) {
pixbuf2 = (u8 *)calloc(horiz_bytes_out, (height + 2) * scale); pixbuf2 = (u8 *)calloc(horiz_bytes_out, (height + 2) * scale);
@ -1217,12 +1209,12 @@ void DrawingPanel::DrawArea(u8 **data)
// draw OSD text old-style (directly into output buffer) // draw OSD text old-style (directly into output buffer)
GameArea *panel = wxGetApp().frame->GetPanel(); GameArea *panel = wxGetApp().frame->GetPanel();
if(panel->osdstat.size()) if(panel->osdstat.size())
drawText(todraw,width*scale+(systemColorDepth != 24),bytes_per_pixel, drawText(todraw,width*scale-(systemColorDepth == 24),bytes_per_pixel,
0, 2, panel->osdstat.utf8_str(), gopts.osd_transparent); 0, 2, tmp, gopts.osd_transparent);
if(!gopts.no_osd_status && !panel->osdtext.empty()) { if(!gopts.no_osd_status && !panel->osdtext.empty()) {
if(systemGetClock() - panel->osdtime < OSD_TIME) { if(systemGetClock() - panel->osdtime < OSD_TIME) {
std::string message = ToString(panel->osdtext); std::string message = ToString(panel->osdtext);
drawText(todraw,width*scale+(systemColorDepth != 24),bytes_per_pixel, drawText(todraw,width*scale-(systemColorDepth == 24),bytes_per_pixel,
20,height/2, 20,height/2,
message.c_str(),gopts.osd_transparent); message.c_str(),gopts.osd_transparent);
} else } else
@ -1288,14 +1280,14 @@ void BasicDrawingPanel::DrawArea(wxWindowDC &dc)
wxBitmap *bm; wxBitmap *bm;
if(systemColorDepth == 24) { if(systemColorDepth == 24) {
// never scaled, no borders, no transformations needed // never scaled, no borders, no transformations needed
wxImage im(width, height, todraw, true); wxImage im(width-1, height, todraw, true);
bm = new wxBitmap(im); bm = new wxBitmap(im);
} }
else else
{ // 32-bit { // 32-bit
// scaled by filters, top/right borders, transform to 24-bit // scaled by filters, top/right borders, transform to 24-bit
wxImage im(width * scale+1, height * scale+1, false); wxImage im(width * scale, height * scale, false);
convert32To24((u32 *)todraw,(u8 *)im.GetData(),width * scale+1,height * scale+1); convert32To24((u32 *)todraw,(u8 *)im.GetData(),width * scale,height * scale);
bm = new wxBitmap(im); bm = new wxBitmap(im);
} }
double sx, sy; double sx, sy;
@ -1459,7 +1451,7 @@ void GLDrawingPanel::DrawArea(wxWindowDC &dc)
Init(); Init();
if(todraw) { if(todraw) {
int rowlen = width * scale + 1; int rowlen = width * scale;
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlen); glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlen);
glTexImage2D(GL_TEXTURE_2D, 0, int_fmt, width * scale, height * scale, glTexImage2D(GL_TEXTURE_2D, 0, int_fmt, width * scale, height * scale,
0, tex_fmt, todraw); 0, tex_fmt, todraw);
@ -1560,10 +1552,10 @@ void CairoDrawingPanel::DrawArea(wxWindowDC &dc)
#endif #endif
#endif #endif
cairo_surface_t *surf; cairo_surface_t *surf;
surf = cairo_image_surface_create_for_data(todraw + 4 * width, surf = cairo_image_surface_create_for_data(todraw,
CAIRO_FORMAT_RGB24, CAIRO_FORMAT_RGB24,
width, height, width, height,
4 * (width + 1)); 4 * width);
cairo_pattern_t *pat = cairo_pattern_create_for_surface(surf); cairo_pattern_t *pat = cairo_pattern_create_for_surface(surf);
// GOOD is "similar to" bilinear, and FAST is "similar to" nearest // GOOD is "similar to" bilinear, and FAST is "similar to" nearest