Stroking on tab widgets. Basic support for backcaching.

svn-id: r33084
This commit is contained in:
Vicent Marti 2008-07-16 10:48:14 +00:00
parent 47119ee8b1
commit 14c8d5d6c3
4 changed files with 92 additions and 31 deletions

View File

@ -402,8 +402,13 @@ drawTab(int x, int y, int r, int w, int h) {
return;
case kFillGradient:
case kFillForeground:
case kFillBackground:
drawTabAlg(x, y, w, h, r, (Base::_fillMode == kFillBackground) ? _bgColor : _fgColor, Base::_fillMode);
if (Base::_strokeWidth)
drawTabAlg(x, y, w, h, r, _fgColor, kFillDisabled);
break;
case kFillForeground:
drawTabAlg(x, y, w, h, r, (Base::_fillMode == kFillBackground) ? _bgColor : _fgColor, Base::_fillMode);
break;
}
@ -471,44 +476,82 @@ drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer:
int f, ddF_x, ddF_y;
int x, y, px, py;
int pitch = Base::surfacePitch();
int sw = 0, sp = 0, hp = 0;
PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r);
PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
int real_radius = r;
int short_h = h - (r) + 2;
int short_h = h - r + 2;
int long_h = h;
__BE_RESET();
PixelType color1, color2;
if (fill_m == kFillForeground || fill_m == kFillBackground)
color1 = color2 = color;
while (x++ < y) {
__BE_ALGORITHM();
if (fill_m == kFillGradient) {
color1 = calcGradient(real_radius - x, long_h);
color2 = calcGradient(real_radius - y, long_h);
if (fill_m == kFillDisabled) {
while (sw++ < Base::_strokeWidth) {
colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color);
colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color);
sp += pitch;
__BE_RESET();
r--;
while (x++ < y) {
__BE_ALGORITHM();
*(ptr_tr + (y) - (px)) = color;
*(ptr_tr + (x) - (py)) = color;
*(ptr_tl - (x) - (py)) = color;
*(ptr_tl - (y) - (px)) = color;
if (Base::_strokeWidth > 1) {
*(ptr_tr + (y) - (px)) = color;
*(ptr_tr + (x - 1) - (py)) = color;
*(ptr_tl - (x - 1) - (py)) = color;
*(ptr_tl - (y) - (px)) = color;
*(ptr_tr + (y) - (px - pitch)) = color;
*(ptr_tr + (x) - (py)) = color;
*(ptr_tl - (x) - (py)) = color;
*(ptr_tl - (y) - (px - pitch)) = color;
}
}
}
ptr_fill += pitch * real_radius;
while (short_h--) {
colorFill(ptr_fill, ptr_fill + Base::_strokeWidth, color);
colorFill(ptr_fill + w - Base::_strokeWidth + 1, ptr_fill + w + 1, color);
ptr_fill += pitch;
}
} else {
__BE_RESET();
colorFill(ptr_tl - x - py, ptr_tr + x - py, color2);
colorFill(ptr_tl - y - px, ptr_tr + y - px, color1);
*(ptr_tr + (y) - (px)) = color;
*(ptr_tr + (x) - (py)) = color;
*(ptr_tl - (x) - (py)) = color;
*(ptr_tl - (y) - (px)) = color;
}
ptr_fill += pitch * r;
while (short_h--) {
if (fill_m == kFillGradient)
color = calcGradient(real_radius++, long_h);
colorFill(ptr_fill, ptr_fill + w + 1, color);
ptr_fill += pitch;
while (x++ < y) {
__BE_ALGORITHM();
if (fill_m == kFillGradient) {
color1 = calcGradient(real_radius - x, long_h);
color2 = calcGradient(real_radius - y, long_h);
}
colorFill(ptr_tl - x - py, ptr_tr + x - py, color2);
colorFill(ptr_tl - y - px, ptr_tr + y - px, color1);
*(ptr_tr + (y) - (px)) = color1;
*(ptr_tr + (x) - (py)) = color2;
*(ptr_tl - (x) - (py)) = color2;
*(ptr_tl - (y) - (px)) = color1;
}
ptr_fill += pitch * r;
while (short_h--) {
if (fill_m == kFillGradient)
color = calcGradient(real_radius++, long_h);
colorFill(ptr_fill, ptr_fill + w + 1, color);
ptr_fill += pitch;
}
}
}

View File

@ -63,7 +63,7 @@ bool ThemeRenderer::loadDefaultXML() {
"<drawdata id = 'tab_active' cache = false>"
"<text vertical_align = 'center' horizontal_align = 'center' color = '255, 255, 255' />"
"<drawstep func = 'tab' radius = '8' stroke = '0' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 3 />"
"<drawstep func = 'tab' radius = '8' stroke = '2' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 3 />"
"</drawdata>"
"<drawdata id = 'tab_inactive' cache = false>"

View File

@ -76,7 +76,7 @@ const char *ThemeRenderer::kDrawDataStrings[] = {
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false), _enabled(false) {
_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false), _themeOk(false), _enabled(false) {
_system = g_system;
_parser = new ThemeParser(this);
@ -153,9 +153,15 @@ void ThemeRenderer::disable() {
}
template<typename PixelType>
void ThemeRenderer::screenInit() {
void ThemeRenderer::screenInit(bool backBuffer) {
freeScreen();
freeBackbuffer();
if (backBuffer) {
_backBuffer = new Surface;
_backBuffer->create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(PixelType));
}
_screen = new Surface;
_screen->create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(PixelType));
_system->clearOverlay();
@ -166,7 +172,7 @@ void ThemeRenderer::setGraphicsMode(GraphicsMode mode) {
case kGfxStandard16bit:
case kGfxAntialias16bit:
_bytesPerPixel = sizeof(uint16);
screenInit<uint16>();
screenInit<uint16>(kEnableBackCaching);
break;
default:

View File

@ -73,6 +73,9 @@ class ThemeRenderer : public Theme {
/** Constant value to expand dirty rectangles, to make sure they are fully copied */
static const int kDirtyRectangleThreshold = 2;
/** Sets whether backcaching is enabled */
static const bool kEnableBackCaching = true;
public:
enum GraphicsMode {
@ -204,7 +207,7 @@ public:
void setGraphicsMode(GraphicsMode mode);
protected:
template<typename PixelType> void screenInit();
template<typename PixelType> void screenInit(bool backBuffer);
bool loadThemeXML(Common::String themeName);
bool loadDefaultXML();
@ -228,6 +231,14 @@ protected:
delete _vectorRenderer;
_vectorRenderer = 0;
}
void freeBackbuffer() {
if (_backBuffer != 0) {
_backBuffer->free();
delete _backBuffer;
_backBuffer = 0;
}
}
void freeScreen() {
if (_screen != 0) {
@ -283,6 +294,7 @@ protected:
GUI::ThemeParser *_parser;
Graphics::Surface *_screen;
Graphics::Surface *_backBuffer;
int _bytesPerPixel;
GraphicsMode _graphicsMode;