Yet more FrameBuffer fixes. If I keep at this, the framebuffer overhaul

due in the next release will be already done :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1052 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-03-18 00:00:30 +00:00
parent b958c82bc1
commit e65d84ca3f
6 changed files with 52 additions and 54 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBufferGL.cxx,v 1.57 2006-03-17 23:06:28 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.58 2006-03-18 00:00:30 stephena Exp $
//============================================================================
#ifdef DISPLAY_OPENGL
@ -305,9 +305,6 @@ bool FrameBufferGL::createScreen()
SDL_GL_SwapBuffers();
p_glClear(GL_COLOR_BUFFER_BIT);
// FIXME - figure out why this is causing a segfault
//myOSystem->eventHandler().refreshDisplay();
return true;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBufferSoft.cxx,v 1.49 2006-03-17 23:06:28 stephena Exp $
// $Id: FrameBufferSoft.cxx,v 1.50 2006-03-18 00:00:30 stephena Exp $
//============================================================================
#include <SDL.h>
@ -108,8 +108,6 @@ bool FrameBufferSoft::createScreen()
break;
}
myOSystem->eventHandler().refreshDisplay();
return true;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.cxx,v 1.154 2006-03-17 19:44:18 stephena Exp $
// $Id: EventHandler.cxx,v 1.155 2006-03-18 00:00:30 stephena Exp $
//============================================================================
#include <sstream>
@ -184,7 +184,7 @@ void EventHandler::reset(State state)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::refreshDisplay()
void EventHandler::refreshDisplay(bool forceUpdate)
{
// These are reset each time the display changes size
DialogContainer::ourJoyMouse.x_max = myOSystem->frameBuffer().imageWidth();
@ -194,7 +194,7 @@ void EventHandler::refreshDisplay()
switch(myState)
{
case S_EMULATE:
myOSystem->frameBuffer().refresh(true);
myOSystem->frameBuffer().refresh();
break;
case S_MENU:
@ -206,9 +206,13 @@ void EventHandler::refreshDisplay()
break;
default:
return;
break;
}
if(forceUpdate)
myOSystem->frameBuffer().update();
// cerr << " ==> State change = " << myState << endl;
}
@ -1966,7 +1970,7 @@ void EventHandler::takeSnapshot()
filename = sspath + ".png";
// Now create a Snapshot object and save the PNG
myOSystem->frameBuffer().refresh(true);
myOSystem->eventHandler().refreshDisplay(true); // force an immediate update
Snapshot snapshot(myOSystem->frameBuffer());
string result = snapshot.savePNG(filename);
myOSystem->frameBuffer().showMessage(result);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.hxx,v 1.80 2006-03-05 01:18:42 stephena Exp $
// $Id: EventHandler.hxx,v 1.81 2006-03-18 00:00:30 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -107,7 +107,7 @@ struct JoyMouse {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.80 2006-03-05 01:18:42 stephena Exp $
@version $Id: EventHandler.hxx,v 1.81 2006-03-18 00:00:30 stephena Exp $
*/
class EventHandler
{
@ -208,8 +208,11 @@ class EventHandler
/**
Refresh display according to the current state
@param forceUpdate Do a framebuffer update right away, instead
of waiting for the next frame
*/
void refreshDisplay();
void refreshDisplay(bool forceUpdate = false);
/**
This method indicates whether a pause event has been received.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.cxx,v 1.81 2006-03-16 16:10:47 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.82 2006-03-18 00:00:30 stephena Exp $
//============================================================================
#include <sstream>
@ -121,6 +121,9 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
// Initialize video subsystem
initSubsystem();
// And refresh the display
myOSystem->eventHandler().refreshDisplay();
// Set palette for GUI
for(int i = 0; i < kNumColors-256; i++)
myPalette[i+256] = mapRGB(ourGUIColors[i][0], ourGUIColors[i][1], ourGUIColors[i][2]);
@ -235,17 +238,6 @@ void FrameBuffer::update()
theRedrawTIAIndicator = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::refresh(bool now)
{
theRedrawTIAIndicator = true;
if(now)
{
myMessageTime = 0;
update();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showMessage(const string& message)
{
@ -268,6 +260,31 @@ void FrameBuffer::hideMessage()
myOSystem->eventHandler().refreshDisplay();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void FrameBuffer::drawMessage()
{
int w = myOSystem->font().getStringWidth(myMessageText) + 10;
int h = myOSystem->font().getFontHeight() + 8;
int x = (myBaseDim.w >> 1) - (w >> 1);
int y = myBaseDim.h - h - 10/2;
// Draw the bounded box and text
fillRect(x+1, y+2, w-2, h-4, kBGColor);
box(x, y+1, w, h-2, kColor, kColor);
drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter);
myMessageTime--;
// Either erase the entire message (when time is reached),
// or show again this frame
if(myMessageTime == 0)
{
// Force an immediate update
myOSystem->eventHandler().refreshDisplay(true);
}
else
addDirtyRect(x, y, w, h);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::pause(bool status)
{
@ -335,6 +352,8 @@ void FrameBuffer::setFullscreen(bool enable)
if(!createScreen())
return;
myOSystem->eventHandler().refreshDisplay();
setCursorState();
}
@ -377,6 +396,8 @@ void FrameBuffer::resize(Size size, Int8 zoom)
if(!createScreen())
return;
myOSystem->eventHandler().refreshDisplay();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -521,28 +542,6 @@ void FrameBuffer::setWindowIcon()
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void FrameBuffer::drawMessage()
{
int w = myOSystem->font().getStringWidth(myMessageText) + 10;
int h = myOSystem->font().getFontHeight() + 8;
int x = (myBaseDim.w >> 1) - (w >> 1);
int y = myBaseDim.h - h - 10/2;
// Draw the bounded box and text
fillRect(x+1, y+2, w-2, h-4, kBGColor);
box(x, y+1, w, h-2, kColor, kColor);
drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter);
myMessageTime--;
// Either erase the entire message (when time is reached),
// or show again this frame
if(myMessageTime == 0)
myOSystem->eventHandler().refreshDisplay();
else
addDirtyRect(x, y, w, h);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor colorA, OverlayColor colorB)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.hxx,v 1.65 2006-01-19 00:45:12 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.66 2006-03-18 00:00:30 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -57,7 +57,7 @@ enum BufferType {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.65 2006-01-19 00:45:12 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.66 2006-03-18 00:00:30 stephena Exp $
*/
class FrameBuffer
{
@ -143,11 +143,8 @@ class FrameBuffer
/**
Indicates that the TIA area is dirty, and certain areas need
to be redrawn.
@param now Determine if the refresh should be done right away or in
the next frame
*/
void refresh(bool now = false);
void refresh() { theRedrawTIAIndicator = true; myMessageTime = 0; }
/**
Toggles between fullscreen and window mode.