aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2012-10-08 14:18:33 -0700
committerJohannes Schickel2012-10-08 14:18:33 -0700
commitc2971374cdb189dbf9f72953a970d0769648e5ae (patch)
tree90734d450f4f30677f14b3a3a2ef29a28ff35d67 /gui
parentdbb09fe984373205453ca7989f9f4aefb245bc4f (diff)
parenta1e56adad8eb8ed4c8de5850fb2c81af9adb9585 (diff)
downloadscummvm-rg350-c2971374cdb189dbf9f72953a970d0769648e5ae.tar.gz
scummvm-rg350-c2971374cdb189dbf9f72953a970d0769648e5ae.tar.bz2
scummvm-rg350-c2971374cdb189dbf9f72953a970d0769648e5ae.zip
Merge pull request #257 from lordhoto/graphics-conversion
Extend crossBlit for abitrary (in-place) conversions and add a in-place conversion to Surface
Diffstat (limited to 'gui')
-rw-r--r--gui/widget.cpp64
-rw-r--r--gui/widget.h4
2 files changed, 30 insertions, 38 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 270cdc56de..4ffb63e945 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -376,7 +376,7 @@ void ButtonWidget::wantTickle(bool tickled) {
PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey),
- _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) {
+ _gfx(), _alpha(256), _transparency(false) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
@@ -384,18 +384,17 @@ PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, co
PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, name, "", tooltip, cmd, hotkey),
- _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) {
+ _gfx(), _alpha(256), _transparency(false) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
}
PicButtonWidget::~PicButtonWidget() {
- _gfx->free();
- delete _gfx;
+ _gfx.free();
}
void PicButtonWidget::setGfx(const Graphics::Surface *gfx) {
- _gfx->free();
+ _gfx.free();
if (!gfx || !gfx->pixels)
return;
@@ -411,7 +410,7 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) {
return;
}
- _gfx->copyFrom(*gfx);
+ _gfx.copyFrom(*gfx);
}
void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) {
@@ -422,29 +421,26 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) {
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- _gfx->free();
- _gfx->create(w, h, requiredFormat);
- _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b));
+ _gfx.free();
+ _gfx.create(w, h, requiredFormat);
+ _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b));
}
void PicButtonWidget::drawWidget() {
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags());
- if (_gfx->pixels) {
+ if (_gfx.pixels) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- if (_gfx->format != requiredFormat) {
- Graphics::Surface *converted = _gfx->convertTo(requiredFormat);
- _gfx->free();
- delete _gfx;
- _gfx = converted;
+ if (_gfx.format != requiredFormat) {
+ _gfx.convertToInPlace(requiredFormat);
}
- const int x = _x + (_w - _gfx->w) / 2;
- const int y = _y + (_h - _gfx->h) / 2;
+ const int x = _x + (_w - _gfx.w) / 2;
+ const int y = _y + (_h - _gfx.h) / 2;
- g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx->w, y + _gfx->h), *_gfx, _state, _alpha, _transparency);
+ g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency);
}
}
@@ -632,24 +628,23 @@ int SliderWidget::posToValue(int pos) {
#pragma mark -
GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip)
- : Widget(boss, x, y, w, h, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) {
+ : Widget(boss, x, y, w, h, tooltip), _gfx(), _alpha(256), _transparency(false) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
_type = kGraphicsWidget;
}
GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name, const char *tooltip)
- : Widget(boss, name, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) {
+ : Widget(boss, name, tooltip), _gfx(), _alpha(256), _transparency(false) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
_type = kGraphicsWidget;
}
GraphicsWidget::~GraphicsWidget() {
- _gfx->free();
- delete _gfx;
+ _gfx.free();
}
void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
- _gfx->free();
+ _gfx.free();
if (!gfx || !gfx->pixels)
return;
@@ -664,7 +659,7 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
return;
}
- _gfx->copyFrom(*gfx);
+ _gfx.copyFrom(*gfx);
}
void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
@@ -675,27 +670,24 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- _gfx->free();
- _gfx->create(w, h, requiredFormat);
- _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b));
+ _gfx.free();
+ _gfx.create(w, h, requiredFormat);
+ _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b));
}
void GraphicsWidget::drawWidget() {
- if (_gfx->pixels) {
+ if (_gfx.pixels) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- if (_gfx->format != requiredFormat) {
- Graphics::Surface *converted = _gfx->convertTo(requiredFormat);
- _gfx->free();
- delete _gfx;
- _gfx = converted;
+ if (_gfx.format != requiredFormat) {
+ _gfx.convertToInPlace(requiredFormat);
}
- const int x = _x + (_w - _gfx->w) / 2;
- const int y = _y + (_h - _gfx->h) / 2;
+ const int x = _x + (_w - _gfx.w) / 2;
+ const int y = _y + (_h - _gfx.h) / 2;
- g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx->w, y + _gfx->h), *_gfx, _state, _alpha, _transparency);
+ g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency);
}
}
diff --git a/gui/widget.h b/gui/widget.h
index 6f710f302f..e3f712564f 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -230,7 +230,7 @@ public:
protected:
void drawWidget();
- Graphics::Surface *_gfx;
+ Graphics::Surface _gfx;
int _alpha;
bool _transparency;
};
@@ -358,7 +358,7 @@ public:
protected:
void drawWidget();
- Graphics::Surface *_gfx;
+ Graphics::Surface _gfx;
int _alpha;
bool _transparency;
};