summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-14 16:59:21 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-14 16:59:21 +0300
commitd9a77eb8ac5d507665cbf8b20f5d8187148ebfd1 (patch)
treedb2f8a25d466ce6aa5ca1747216156f7869a06d1
parent2851324a6847efa7ea6f556941b369e9e304dc23 (diff)
downloadplus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.tar.gz
plus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.tar.bz2
plus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.tar.xz
plus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.zip
Improve a bit separate images drawing.
-rw-r--r--src/animatedsprite.cpp6
-rw-r--r--src/being/compoundsprite.cpp6
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/gui/sdlfont.cpp4
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp2
-rw-r--r--src/gui/widgets/button.cpp9
-rw-r--r--src/gui/widgets/checkbox.cpp2
-rw-r--r--src/gui/widgets/desktop.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp4
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/emotepage.cpp2
-rw-r--r--src/gui/widgets/extendedlistbox.cpp4
-rw-r--r--src/gui/widgets/icon.cpp3
-rw-r--r--src/gui/widgets/itemcontainer.cpp8
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/radiobutton.cpp2
-rw-r--r--src/gui/widgets/scrollarea.cpp4
-rw-r--r--src/gui/widgets/shoplistbox.cpp2
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/slider.cpp12
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/tabs/tab.cpp2
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/windows/equipmentwindow.cpp12
-rw-r--r--src/gui/windows/minimap.cpp2
-rw-r--r--src/gui/windows/outfitwindow.cpp5
-rw-r--r--src/gui/windows/skilldialog.cpp2
-rw-r--r--src/imagesprite.cpp3
-rw-r--r--src/maplayer.cpp6
-rw-r--r--src/particle/imageparticle.cpp3
-rw-r--r--src/render/graphics.cpp8
-rw-r--r--src/render/graphics.h25
-rw-r--r--src/render/mobileopenglgraphics.h12
-rw-r--r--src/render/normalopenglgraphics.h12
-rw-r--r--src/render/nullopenglgraphics.h12
-rw-r--r--src/render/safeopenglgraphics.h10
-rw-r--r--src/render/sdl2graphics.h2
-rw-r--r--src/render/sdl2softwaregraphics.h2
-rw-r--r--src/render/sdlgraphics.h2
-rw-r--r--src/render/surfacegraphics.h2
-rw-r--r--src/resources/atlasmanager.cpp2
-rw-r--r--src/simpleanimation.cpp7
-rw-r--r--src/test/testlauncher.cpp12
-rw-r--r--src/touchmanager.cpp2
45 files changed, 132 insertions, 109 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 456dc9c70..2f167e794 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -294,9 +294,9 @@ bool AnimatedSprite::draw(Graphics *const graphics,
if (image->getAlpha() != mAlpha)
image->setAlpha(mAlpha);
- return graphics->drawImage(image,
- posX + mFrame->offsetX,
- posY + mFrame->offsetY);
+ DRAW_IMAGE(graphics, image,
+ posX + mFrame->offsetX, posY + mFrame->offsetY);
+ return true;
}
bool AnimatedSprite::setSpriteDirection(const SpriteDirection direction)
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 3a615aa2b..b0442d055 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -123,13 +123,15 @@ bool CompoundSprite::draw(Graphics *const graphics,
if (mAlpha == 1.0F && mImage)
{
- return graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
+ DRAW_IMAGE(graphics, mImage, posX + mOffsetX, posY + mOffsetY);
+ return true;
}
else if (mAlpha && mAlphaImage)
{
mAlphaImage->setAlpha(mAlpha);
- return graphics->drawImage(mAlphaImage,
+ DRAW_IMAGE(graphics, mAlphaImage,
posX + mOffsetX, posY + mOffsetY);
+ return true;
}
else
{
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 60924bfd4..2a0c1d641 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -468,7 +468,7 @@ void Gui::draw()
{
const int posX = mouseX - (image->mBounds.w / 2);
const int posY = mouseY - (image->mBounds.h / 2);
- g2->drawImage(image, posX, posY);
+ DRAW_IMAGE(g2, image, posX, posY);
}
if (mGuiFont)
{
@@ -486,7 +486,7 @@ void Gui::draw()
if (mouseCursor)
{
mouseCursor->setAlpha(mMouseCursorAlpha);
- g2->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
+ DRAW_IMAGE(g2, mouseCursor, mouseX - 15, mouseY - 17);
}
}
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index b0596418d..74ae3ef88 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -483,7 +483,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
if (image)
{
image->setAlpha(alpha);
- g->drawImage(image, x, y);
+ DRAW_IMAGE(g, image, x, y);
}
}
else
@@ -505,7 +505,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
const Image *const image = chunk2->img;
if (image)
- g->drawImage(image, x, y);
+ DRAW_IMAGE(g, image, x, y);
}
BLOCK_END("SDLFont::drawString")
}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 123f7f843..6726475d2 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -137,7 +137,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
else
{
- graphics->drawImage(icon, mImagePadding, y + mPadding);
+ DRAW_IMAGE(graphics, icon, mImagePadding, y + mPadding);
}
}
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 8d1550f43..0dafe8e24 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -506,7 +506,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
}
else if (part.mImage)
{
- graphics2->drawImage(part.mImage, part.mX, part.mY);
+ DRAW_IMAGE(graphics2, part.mImage, part.mX, part.mY);
}
}
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index e1f95c334..91c531f6b 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -499,12 +499,17 @@ void Button::draw(gcn::Graphics *graphics)
else
{
g2->drawImageRect(0, 0, width, height, skin->getBorder());
+
if (mImages)
{
if (isPressed())
- g2->drawImage(mImages[mode], imageX + 1, imageY + 1);
+ {
+ DRAW_IMAGE(g2, mImages[mode], imageX + 1, imageY + 1);
+ }
else
- g2->drawImage(mImages[mode], imageX, imageY);
+ {
+ DRAW_IMAGE(g2, mImages[mode], imageX, imageY);
+ }
}
}
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index e21e50c53..c8710c573 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -165,7 +165,7 @@ void CheckBox::drawBox(gcn::Graphics *const graphics)
if (box)
{
- static_cast<Graphics*>(graphics)->drawImage(
+ DRAW_IMAGE(static_cast<Graphics*>(graphics),
box, mImagePadding, (getHeight() - mImageSize) / 2);
}
}
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index d2e132c56..1aed4a825 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -124,7 +124,7 @@ void Desktop::draw(gcn::Graphics *graphics)
if (imageHelper->useOpenGL() == RENDER_SOFTWARE)
{
- g->drawImage(mWallpaper,
+ DRAW_IMAGE(g, mWallpaper,
(width - wallpWidth) / 2,
(height - wallpHeight) / 2);
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 7c41bbacc..07d48f13d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -250,7 +250,7 @@ void DropDown::draw(gcn::Graphics* graphics)
}
else
{
- static_cast<Graphics*>(graphics)->drawImage(
+ DRAW_IMAGE(static_cast<Graphics*>(graphics),
image, mImagePadding, (mDimension.height
- image->getHeight()) / 2 + mPadding);
font->drawString(graphics, model->getElementAt(sel),
@@ -303,7 +303,7 @@ void DropDown::drawButton(gcn::Graphics *graphics)
Image *image = buttons[mDroppedDown][mPushed];
if (image)
{
- static_cast<Graphics*>(graphics)->drawImage(image,
+ DRAW_IMAGE(static_cast<Graphics*>(graphics), image,
mDimension.width - image->getWidth() - mImagePadding,
(height - image->getHeight()) / 2);
}
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index d8f2f1d68..9775b0fb0 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -144,7 +144,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
caption = "Eq.";
image->setAlpha(1.0F);
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
if (item->isEquipped())
g->setColorAll(mEquipedColor, mEquipedColor2);
else
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 5af84e88d..a68836a96 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -103,7 +103,7 @@ void EmotePage::draw(gcn::Graphics *graphics)
const Image *const image = *it;
if (image)
{
- g->drawImage(image, x, y);
+ DRAW_IMAGE(g, image, x, y);
x += emoteWidth;
if (x + emoteWidth > width)
{
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 68b4df766..0363b73a0 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -132,7 +132,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
const Image *const image = model->getImageAt(row1);
if (image)
{
- g->drawImage(image, mImagePadding, item.y + (height
+ DRAW_IMAGE(g, image, mImagePadding, item.y + (height
- image->getHeight()) / 2 + mPadding);
}
}
@@ -166,7 +166,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
const Image *const image = model->getImageAt(row1);
if (image)
{
- g->drawImage(image, mImagePadding, item.y + (height
+ DRAW_IMAGE(g, image, mImagePadding, item.y + (height
- image->getHeight()) / 2 + mPadding);
}
}
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 9232aea0d..e4985d68f 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -73,7 +73,8 @@ void Icon::draw(gcn::Graphics *g)
if (mImage)
{
Graphics *const graphics = static_cast<Graphics*>(g);
- graphics->drawImage(mImage, (mDimension.width - mImage->mBounds.w) / 2,
+ DRAW_IMAGE(graphics, mImage,
+ (mDimension.width - mImage->mBounds.w) / 2,
(mDimension.height - mImage->mBounds.h) / 2);
}
BLOCK_END("Icon::draw")
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 8754210f8..9064ca8b5 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -280,16 +280,16 @@ void ItemContainer::draw(gcn::Graphics *graphics)
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
if (mSelImg)
- g->drawImage(mSelImg, itemX, itemY);
+ DRAW_IMAGE(g, mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
- g->drawImage(image, itemX + mPaddingItemX,
+ DRAW_IMAGE(g, image, itemX + mPaddingItemX,
itemY + mPaddingItemY);
if (mProtectedImg && PlayerInfo::isItemProtected(
item->getId()))
{
- g->drawImage(mProtectedImg, itemX + mPaddingItemX,
- itemY + mPaddingItemY);
+ DRAW_IMAGE(g, mProtectedImg,
+ itemX + mPaddingItemX, itemY + mPaddingItemY);
}
}
}
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 266c96241..7271f3943 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -175,7 +175,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
caption = "Eq.";
image->setAlpha(1.0F);
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
if (item->isEquipped())
g->setColorAll(mEquipedColor, mEquipedColor2);
else
@@ -199,7 +199,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
image->setAlpha(1.0F);
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
}
}
@@ -218,7 +218,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
image->setAlpha(1.0F);
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
}
font->drawString(g, skill->data->shortName, itemX + 2,
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index fe0195680..1dff6ae7c 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -148,7 +148,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
if (box)
{
- static_cast<Graphics*>(graphics)->drawImage(
+ DRAW_IMAGE(static_cast<Graphics*>(graphics),
box, mImagePadding, (getHeight() - mImageSize) / 2);
}
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index e97dad715..a2e1ca4aa 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -428,8 +428,8 @@ void ScrollArea::drawButton(gcn::Graphics *const graphics,
if (buttons[dir][state])
{
- static_cast<Graphics*>(graphics)->
- drawImage(buttons[dir][state], dim.x, dim.y);
+ DRAW_IMAGE(static_cast<Graphics*>(graphics),
+ buttons[dir][state], dim.x, dim.y);
}
}
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 9918b7788..5bf56c842 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -157,7 +157,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (icon)
{
icon->setAlpha(1.0F);
- graphics->drawImage(icon, mPadding, y + mPadding);
+ DRAW_IMAGE(graphics, icon, mPadding, y + mPadding);
}
}
if (mSelected == i)
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index 2fb5c4099..a68bc8b07 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -109,7 +109,7 @@ void ShortcutContainer::drawBackground(Graphics *g)
{
for (unsigned i = 0; i < mMaxItems; i ++)
{
- g->drawImage(mBackgroundImg, (i % mGridWidth) * mBoxWidth,
+ DRAW_IMAGE(g, mBackgroundImg, (i % mGridWidth) * mBoxWidth,
(i / mGridWidth) * mBoxHeight);
}
}
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 20fc6b21b..47d4e2215 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -204,7 +204,7 @@ void Slider::draw(gcn::Graphics *graphics)
{
if (!mHasMouse)
{
- g->drawImage(buttons[0].grid[HSTART], x, y);
+ DRAW_IMAGE(g, buttons[0].grid[HSTART], x, y);
const int width = buttons[0].grid[HSTART]->getWidth();
w -= width + buttons[0].grid[HEND]->getWidth();
x += width;
@@ -216,18 +216,18 @@ void Slider::draw(gcn::Graphics *graphics)
}
x += w;
- g->drawImage(buttons[0].grid[HEND], x, y);
+ DRAW_IMAGE(g, buttons[0].grid[HEND], x, y);
const Image *const img = buttons[0].grid[HGRIP];
if (img)
{
- g->drawImage(img, getMarkerPosition(),
+ DRAW_IMAGE(g, img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
}
}
else
{
- g->drawImage(buttons[1].grid[HSTART], x, y);
+ DRAW_IMAGE(g, buttons[1].grid[HSTART], x, y);
const int width = buttons[1].grid[HSTART]->getWidth();
w -= width;
@@ -243,12 +243,12 @@ void Slider::draw(gcn::Graphics *graphics)
x += w;
if (buttons[1].grid[HEND])
- g->drawImage(buttons[1].grid[HEND], x, y);
+ DRAW_IMAGE(g, buttons[1].grid[HEND], x, y);
const Image *const img = buttons[1].grid[HGRIP];
if (img)
{
- g->drawImage(img, getMarkerPosition(),
+ DRAW_IMAGE(g, img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
}
}
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 3a28bfabf..7d9ba6d0f 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -135,7 +135,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
image->setAlpha(1.0F);
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
}
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index cdaa84d14..fd5d8ffc5 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -241,7 +241,7 @@ void Tab::draw(gcn::Graphics *graphics)
if (skin1)
{
const int padding = skin1->getPadding();
- g->drawImage(mImage, padding, padding);
+ DRAW_IMAGE(g, mImage, padding, padding);
}
}
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 5148ec3f5..a95bc0877 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -272,18 +272,18 @@ void Window::draw(gcn::Graphics *graphics)
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
if (button)
- g->drawImage(button, mCloseRect.x, mCloseRect.y);
+ DRAW_IMAGE(g, button, mCloseRect.x, mCloseRect.y);
}
// Draw Sticky Button
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
if (button)
- g->drawImage(button, mStickyRect.x, mStickyRect.y);
+ DRAW_IMAGE(g, button, mStickyRect.x, mStickyRect.y);
}
if (mGrip)
- g->drawImage(mGrip, mGripRect.x, mGripRect.y);
+ DRAW_IMAGE(g, mGrip, mGripRect.x, mGripRect.y);
}
// Draw title
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 9f1ed11bf..c5df1b528 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -201,9 +201,13 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
if (!box)
continue;
if (i == mSelected)
- g->drawImage(mSlotHighlightedBackground, box->x, box->y);
+ {
+ DRAW_IMAGE(g, mSlotHighlightedBackground, box->x, box->y);
+ }
else
- g->drawImage(mSlotBackground, box->x, box->y);
+ {
+ DRAW_IMAGE(g, mSlotBackground, box->x, box->y);
+ }
}
}
@@ -229,7 +233,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
- g->drawImage(image, box->x + mItemPadding,
+ DRAW_IMAGE(g, image, box->x + mItemPadding,
box->y + mItemPadding);
if (i == EQUIP_PROJECTILE_SLOT)
{
@@ -243,7 +247,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
}
else if (box->image)
{
- g->drawImage(box->image, box->x + mItemPadding,
+ DRAW_IMAGE(g, box->image, box->x + mItemPadding,
box->y + mItemPadding);
}
}
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 7aefa285b..6db0b5388 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -286,7 +286,7 @@ void Minimap::draw(gcn::Graphics *graphics)
mMapOriginY = 0;
}
- graph->drawImage(mMapImage, mMapOriginX, mMapOriginY);
+ DRAW_IMAGE(graph, mMapImage, mMapOriginX, mMapOriginY);
}
const ActorSprites &actors = actorManager->getAll();
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 704f3ce60..c242f5d85 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -348,7 +348,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
const Image *const image = item->getImage();
if (image)
{
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
foundItem = true;
}
}
@@ -359,7 +359,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
mItemColors[mCurrentOutfit][i]);
if (image)
{
- g->drawImage(image, itemX, itemY);
+ DRAW_IMAGE(g, image, itemX, itemY);
image->decRef();
}
}
@@ -367,7 +367,6 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
BLOCK_END("OutfitWindow::draw")
}
-
void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 74fb4faf5..b21f0c09b 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -134,7 +134,7 @@ class SkillListBox final : public ListBox
const SkillData *const data = e->data;
const int yPad = y + mPadding;
const std::string &description = data->description;
- graphics->drawImage(data->icon, mPadding, yPad);
+ DRAW_IMAGE(graphics, data->icon, mPadding, yPad);
font->drawString(graphics, data->name, mTextPadding, yPad);
if (!description.empty())
{
diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp
index 89b33937a..5e9cc9463 100644
--- a/src/imagesprite.cpp
+++ b/src/imagesprite.cpp
@@ -56,5 +56,6 @@ bool ImageSprite::draw(Graphics *const graphics,
return false;
mImage->setAlpha(mAlpha);
- return graphics->drawImage(mImage, posX, posY);
+ DRAW_IMAGE(graphics, mImage, posX, posY);
+ return true;
}
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index 1f8278304..2ea850eb6 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -139,7 +139,7 @@ void MapLayer::draw(Graphics *const graphics,
if (!c)
{
- graphics->drawImage(img, px, py);
+ DRAW_IMAGE(graphics, img, px, py);
}
else
{
@@ -455,7 +455,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
if (!c)
{
- graphics->drawImage(img, px, py);
+ DRAW_IMAGE(graphics, img, px, py);
}
else
{
@@ -796,7 +796,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
{
BLOCK_START("MapItem::draw")
if (mImage)
- graphics->drawImage(mImage, x, y);
+ DRAW_IMAGE(graphics, mImage, x, y);
switch (mType)
{
diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp
index 7e7139292..0654b3c6f 100644
--- a/src/particle/imageparticle.cpp
+++ b/src/particle/imageparticle.cpp
@@ -103,5 +103,6 @@ bool ImageParticle::draw(Graphics *const graphics,
}
mImage->setAlpha(alphafactor);
- return graphics->drawImage(mImage, screenX, screenY);
+ DRAW_IMAGE(graphics, mImage, screenX, screenY);
+ return true;
}
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 5a0adfeef..561ce3a90 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -494,10 +494,10 @@ void Graphics::drawImageRect(const int x, const int y,
// Draw the corners
if (drawMain)
{
- drawImage(topLeft, x, y);
- drawImage(topRight, x + w - topRight->getWidth(), y);
- drawImage(bottomLeft, x, h - bottomLeft->getHeight() + y);
- drawImage(bottomRight,
+ DRAW_IMAGE(this, topLeft, x, y);
+ DRAW_IMAGE(this, topRight, x + w - topRight->getWidth(), y);
+ DRAW_IMAGE(this, bottomLeft, x, h - bottomLeft->getHeight() + y);
+ DRAW_IMAGE(this, bottomRight,
x + w - bottomRight->getWidth(),
y + h - bottomRight->getHeight());
}
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 7d4d7c524..cb009291b 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -47,6 +47,15 @@ struct SDL_Window;
static const int defaultScreenWidth = 800;
static const int defaultScreenHeight = 600;
+#define DRAW_IMAGE(graphics, image, x, y) \
+ { \
+ if (image) \
+ { \
+ (graphics)->drawImage2(image, 0, 0, x, y, \
+ (image)->mBounds.w, (image)->mBounds.h, false); \
+ } \
+ }
+
/**
* 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The
* topology is as follows:
@@ -370,14 +379,6 @@ class Graphics : public gcn::Graphics
virtual void setRendererFlags(const uint32_t flags A_UNUSED)
{ }
#endif
- int mWidth;
- int mHeight;
-
- protected:
- /**
- * Constructor.
- */
- Graphics();
/**
* Blits an image onto the screen.
@@ -391,6 +392,14 @@ class Graphics : public gcn::Graphics
const int width, const int height,
const bool useColor) = 0;
+ int mWidth;
+ int mHeight;
+
+ protected:
+ /**
+ * Constructor.
+ */
+ Graphics();
void setMainFlags(const int w, const int h, const int bpp,
const bool fs, const bool hwaccel,
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index 75a171766..55283010e 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -184,6 +184,12 @@ class MobileOpenGLGraphics final : public Graphics
void updateTextureFormat();
+ bool drawImage2(const Image *const image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor) override final;
+
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
{ return mLastDrawCalls; }
@@ -198,12 +204,6 @@ class MobileOpenGLGraphics final : public Graphics
static GLuint mLastImage;
protected:
- bool drawImage2(const Image *const image,
- int srcX, int srcY,
- int dstX, int dstY,
- const int width, const int height,
- const bool useColor) override final;
-
void setTexturingAndBlending(const bool enable);
void debugBindTexture(const Image *const image);
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
index f59e02880..3af6ad00a 100644
--- a/src/render/normalopenglgraphics.h
+++ b/src/render/normalopenglgraphics.h
@@ -191,6 +191,12 @@ class NormalOpenGLGraphics final : public Graphics
void updateTextureFormat();
+ bool drawImage2(const Image *const image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor) override final;
+
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
{ return mLastDrawCalls; }
@@ -208,12 +214,6 @@ class NormalOpenGLGraphics final : public Graphics
static GLuint mLastImage;
protected:
- bool drawImage2(const Image *const image,
- int srcX, int srcY,
- int dstX, int dstY,
- const int width, const int height,
- const bool useColor) override final;
-
void setTexturingAndBlending(const bool enable);
void debugBindTexture(const Image *const image);
diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h
index cdd9df0f6..620baa59d 100644
--- a/src/render/nullopenglgraphics.h
+++ b/src/render/nullopenglgraphics.h
@@ -191,6 +191,12 @@ class NullOpenGLGraphics final : public Graphics
void updateTextureFormat();
+ bool drawImage2(const Image *const image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor) override final;
+
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
{ return mLastDrawCalls; }
@@ -205,12 +211,6 @@ class NullOpenGLGraphics final : public Graphics
static GLuint mLastImage;
protected:
- bool drawImage2(const Image *const image,
- int srcX, int srcY,
- int dstX, int dstY,
- const int width, const int height,
- const bool useColor) override final;
-
void setTexturingAndBlending(const bool enable);
void debugBindTexture(const Image *const image);
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index 773657261..6ece1bc88 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -154,17 +154,17 @@ class SafeOpenGLGraphics final : public Graphics
void prepareScreenshot() override final;
- static void bindTexture(const GLenum target, const GLuint texture);
-
- static GLuint mLastImage;
-
- protected:
bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ static void bindTexture(const GLenum target, const GLuint texture);
+
+ static GLuint mLastImage;
+
+ protected:
void setTexturingAndBlending(const bool enable);
private:
diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h
index 0e1801b0e..57e60135f 100644
--- a/src/render/sdl2graphics.h
+++ b/src/render/sdl2graphics.h
@@ -142,13 +142,13 @@ class SDLGraphics : public Graphics
void setRendererFlags(const uint32_t flags)
{ mRendererFlags = flags; }
- protected:
virtual bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
uint32_t mRendererFlags;
uint32_t mOldPixel;
int mOldAlpha;
diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h
index ab71f33e4..9c2b00ad9 100644
--- a/src/render/sdl2softwaregraphics.h
+++ b/src/render/sdl2softwaregraphics.h
@@ -145,13 +145,13 @@ class SDL2SoftwareGraphics : public Graphics
bool resizeScreen(const int width, const int height) override final;
- protected:
virtual bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
int SDL_FakeUpperBlit(const SDL_Surface *const src,
SDL_Rect *const srcrect,
const SDL_Surface *const dst,
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index 17540543e..dd33fcc0c 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -139,13 +139,13 @@ class SDLGraphics : public Graphics
const bool resize,
const bool noFrame) override final;
- protected:
virtual bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
int SDL_FakeUpperBlit(const SDL_Surface *const src,
SDL_Rect *const srcrect,
const SDL_Surface *const dst,
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index 3d62b5c22..d10ea938a 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -180,13 +180,13 @@ class SurfaceGraphics : public Graphics
const bool noFrame A_UNUSED) override final
{ return false; }
- protected:
bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
BlitMode mBlitMode;
SDL_Surface *mTarget;
};
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index 78e3d5190..1fe2ff248 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -250,7 +250,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
#else
SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE);
#endif
- graphics->drawImage(image, item->x, item->y);
+ DRAW_IMAGE(graphics, image, item->x, item->y);
}
}
}
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index bb120dee7..b1efc16e5 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -29,6 +29,7 @@
#include "resources/animation.h"
#include "resources/dye.h"
+#include "resources/image.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
@@ -78,9 +79,9 @@ bool SimpleAnimation::draw(Graphics *const graphics,
if (!mCurrentFrame || !mCurrentFrame->image)
return false;
- return graphics->drawImage(mCurrentFrame->image,
- posX + mCurrentFrame->offsetX,
- posY + mCurrentFrame->offsetY);
+ DRAW_IMAGE(graphics, mCurrentFrame->image,
+ posX + mCurrentFrame->offsetX, posY + mCurrentFrame->offsetY);
+ return true;
}
void SimpleAnimation::reset()
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 44421ee41..99f0b1753 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -94,7 +94,7 @@ int TestLauncher::testBackend() const
for (int f = 0; f < cnt; f ++)
{
- mainGraphics->drawImage(img, cnt * 7, cnt * 5);
+ DRAW_IMAGE(mainGraphics, img, cnt * 7, cnt * 5);
mainGraphics->updateScreen();
}
@@ -152,11 +152,11 @@ int TestLauncher::testFps()
{
for (int y = 0; y < 600; y += 50)
{
- mainGraphics->drawImage(img[idx], x, y);
+ DRAW_IMAGE(mainGraphics, img[idx], x, y);
idx ++;
if (idx > sz)
idx = 0;
- mainGraphics->drawImage(img[idx], x, y);
+ DRAW_IMAGE(mainGraphics, img[idx], x, y);
idx ++;
if (idx > sz)
idx = 0;
@@ -211,9 +211,9 @@ int TestLauncher::testInternal()
{
for (int y = 0; y < 600; y += 25)
{
- mainGraphics->drawImage(img[idx], x, y);
- mainGraphics->drawImage(img[idx], x + 1, y);
- mainGraphics->drawImage(img[idx], x, y + 5);
+ DRAW_IMAGE(mainGraphics, img[idx], x, y);
+ DRAW_IMAGE(mainGraphics, img[idx], x + 1, y);
+ DRAW_IMAGE(mainGraphics, img[idx], x, y + 5);
idx ++;
if (idx > 3)
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index a60680407..dbee76e49 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -225,7 +225,7 @@ void TouchManager::draw()
const Image *const icon = item->icon;
if (icon)
{
- mainGraphics->drawImage(icon,
+ DRAW_IMAGE(mainGraphics, icon,
item->x + (item->width - icon->mBounds.w) / 2,
item->y + (item->height - icon->mBounds.h) / 2);
}