WINTERMUTE: Move draw-code to render_ticket.cpp

This commit is contained in:
Einar Johan Trøan Sømåen 2012-12-13 23:43:18 +01:00
parent c14f45ee05
commit 6d79a66766
4 changed files with 34 additions and 29 deletions

View File

@ -277,7 +277,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S
if (*(compareTicket) == compare && compareTicket->_isValid) {
compareTicket->_colorMod = _colorMod;
if (_disableDirtyRects) {
drawFromSurface(compareTicket, NULL);
drawFromSurface(compareTicket);
} else {
drawFromTicket(compareTicket);
}
@ -292,7 +292,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S
} else {
ticket->_wantsDraw = true;
_renderQueue.push_back(ticket);
drawFromSurface(ticket, NULL);
drawFromSurface(ticket);
}
}
@ -426,7 +426,7 @@ void BaseRenderOSystem::drawTickets() {
dstClip.translate(-offsetX, -offsetY);
_colorMod = ticket->_colorMod;
drawFromSurface(ticket, &ticket->_srcRect, &pos, &dstClip);
drawFromSurface(ticket, &pos, &dstClip);
_needsFlip = true;
}
// Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color)
@ -456,24 +456,12 @@ void BaseRenderOSystem::drawTickets() {
}
// Replacement for SDL2's SDL_RenderCopy
void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect) {
TransparentSurface src(*ticket->getSurface(), false);
bool doDelete = false;
if (!clipRect) {
doDelete = true;
clipRect = new Common::Rect();
clipRect->setWidth(ticket->getSurface()->w);
clipRect->setHeight(ticket->getSurface()->h);
}
src._enableAlphaBlit = ticket->_hasAlpha;
src.blit(*_renderSurface, ticket->_dstRect.left, ticket->_dstRect.top, ticket->_mirror, clipRect, _colorMod, clipRect->width(), clipRect->height());
if (doDelete) {
delete clipRect;
}
void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket) {
ticket->drawToSurface(_renderSurface);
}
void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect) {
ticket->drawToSurface(_renderSurface, srcRect, dstRect, clipRect);
void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *dstRect, Common::Rect *clipRect) {
ticket->drawToSurface(_renderSurface, dstRect, clipRect);
}
//////////////////////////////////////////////////////////////////////////

View File

@ -86,9 +86,9 @@ private:
void addDirtyRect(const Common::Rect &rect);
void drawTickets();
// Non-dirty-rects:
void drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect);
void drawFromSurface(RenderTicket *ticket);
// Dirty-rects:
void drawFromSurface(RenderTicket *ticket, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect);
void drawFromSurface(RenderTicket *ticket, Common::Rect *dstRect, Common::Rect *clipRect);
typedef Common::List<RenderTicket *>::iterator RenderQueueIterator;
Common::Rect *_dirtyRect;
Common::List<RenderTicket *> _renderQueue;

View File

@ -83,7 +83,19 @@ bool RenderTicket::operator==(RenderTicket &t) {
return true;
}
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect) {
// Replacement for SDL2's SDL_RenderCopy
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) {
TransparentSurface src(*getSurface(), false);
Common::Rect clipRect;
clipRect.setWidth(getSurface()->w);
clipRect.setHeight(getSurface()->h);
src._enableAlphaBlit = _hasAlpha;
src.blit(*_targetSurface, _dstRect.left, _dstRect.top, _mirror, &clipRect, _colorMod, clipRect.width(), clipRect.height());
}
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) {
TransparentSurface src(*getSurface(), false);
bool doDelete = false;
if (!clipRect) {
@ -92,7 +104,7 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
clipRect->setWidth(getSurface()->w);
clipRect->setHeight(getSurface()->h);
}
src._enableAlphaBlit = _hasAlpha;
src.blit(*_targetSurface, dstRect->left, dstRect->top, _mirror, clipRect, _colorMod, clipRect->width(), clipRect->height());
if (doDelete) {

View File

@ -36,18 +36,18 @@ namespace Wintermute {
class BaseSurfaceOSystem;
class RenderTicket {
Graphics::Surface *_surface;
public:
RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false, bool disableAlpha = false);
RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {}
~RenderTicket();
const Graphics::Surface *getSurface() { return _surface; }
void drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect);
Common::Rect _srcRect;
// Non-dirty-rects:
void drawToSurface(Graphics::Surface *_targetSurface);
// Dirty-rects:
void drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect);
Common::Rect _dstRect;
uint32 _mirror;
uint32 _batchNum;
bool _hasAlpha;
bool _isValid;
bool _wantsDraw;
@ -56,6 +56,11 @@ public:
BaseSurfaceOSystem *_owner;
bool operator==(RenderTicket &a);
private:
Graphics::Surface *_surface;
Common::Rect _srcRect;
bool _hasAlpha;
uint32 _mirror;
};
} // end of namespace Wintermute