diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-29 21:22:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-29 21:22:33 +0300 |
commit | f94a6551b8d140e272ac1c46bce1ff0e5df34986 (patch) | |
tree | 35c764dfec7b76f926c30cd186b6fe36968b6529 | |
parent | 0336b91f51cdf14e022f74d16c15892b63b658eb (diff) | |
download | mv-f94a6551b8d140e272ac1c46bce1ff0e5df34986.tar.gz mv-f94a6551b8d140e272ac1c46bce1ff0e5df34986.tar.bz2 mv-f94a6551b8d140e272ac1c46bce1ff0e5df34986.tar.xz mv-f94a6551b8d140e272ac1c46bce1ff0e5df34986.zip |
improve draw image calls.
53 files changed, 130 insertions, 217 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 0d3755617..0f07b0a39 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -294,7 +294,7 @@ void AnimatedSprite::draw(Graphics *const graphics, if (image->getAlpha() != mAlpha) image->setAlpha(mAlpha); - DRAW_IMAGE(graphics, image, + graphics->drawImage2(image, posX + mFrame->offsetX, posY + mFrame->offsetY); } diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp index ef489c166..d23f43259 100644 --- a/src/being/compoundsprite.cpp +++ b/src/being/compoundsprite.cpp @@ -123,12 +123,12 @@ void CompoundSprite::draw(Graphics *const graphics, if (mAlpha == 1.0F && mImage) { - DRAW_IMAGE(graphics, mImage, posX + mOffsetX, posY + mOffsetY); + graphics->drawImage2(mImage, posX + mOffsetX, posY + mOffsetY); } else if (mAlpha && mAlphaImage) { mAlphaImage->setAlpha(mAlpha); - DRAW_IMAGE(graphics, mAlphaImage, + graphics->drawImage2(mAlphaImage, posX + mOffsetX, posY + mOffsetY); } else diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 47a533bf8..a9005c4d2 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); - DRAW_IMAGE(g2, image, posX, posY); + g2->drawImage2(image, posX, posY); } if (mGuiFont) { @@ -486,7 +486,7 @@ void Gui::draw() if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); - DRAW_IMAGE(g2, mouseCursor, mouseX - 15, mouseY - 17); + g2->drawImage2(mouseCursor, mouseX - 15, mouseY - 17); } } diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 3998ffcd2..742f3d9aa 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -482,7 +482,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics, if (image) { image->setAlpha(alpha); - DRAW_IMAGE(g, image, x, y); + g->drawImage2(image, x, y); } } else @@ -504,7 +504,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics, const Image *const image = chunk2->img; if (image) - DRAW_IMAGE(g, image, x, y); + g->drawImage2(image, x, y); } BLOCK_END("SDLFont::drawString") } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index cc9b1a262..0c87df057 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -137,7 +137,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } else { - DRAW_IMAGE(graphics, icon, mImagePadding, y + mPadding); + graphics->drawImage2(icon, mImagePadding, y + mPadding); } } } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index d3e2efc67..5394054fe 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -508,7 +508,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) } else if (part.mImage) { - DRAW_IMAGE(graphics2, part.mImage, part.mX, part.mY); + graphics2->drawImage2(part.mImage, part.mX, part.mY); } } diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index c8ac617c0..b7cba68af 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -508,11 +508,11 @@ void Button::draw(gcn::Graphics *graphics) { if (isPressed()) { - DRAW_IMAGE(g2, mImages[mode], imageX + 1, imageY + 1); + g2->drawImage2(mImages[mode], imageX + 1, imageY + 1); } else { - DRAW_IMAGE(g2, mImages[mode], imageX, imageY); + g2->drawImage2(mImages[mode], imageX, imageY); } } } diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 0dfd45745..1497706a1 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -167,7 +167,7 @@ void CheckBox::drawBox(gcn::Graphics *const graphics) if (box) { - DRAW_IMAGE(static_cast<Graphics*>(graphics), + static_cast<Graphics*>(graphics)->drawImage2( box, mImagePadding, (getHeight() - mImageSize) / 2); } } diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 1aed4a825..7d464b46d 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) { - DRAW_IMAGE(g, mWallpaper, + g->drawImage2(mWallpaper, (width - wallpWidth) / 2, (height - wallpHeight) / 2); } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 0cfcb2a6f..bb4ca313a 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -250,7 +250,7 @@ void DropDown::draw(gcn::Graphics* graphics) } else { - DRAW_IMAGE(static_cast<Graphics*>(graphics), + static_cast<Graphics*>(graphics)->drawImage2( 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) { - DRAW_IMAGE(static_cast<Graphics*>(graphics), image, + static_cast<Graphics*>(graphics)->drawImage2(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 9775b0fb0..1662bdbb4 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); - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(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 3c7d1a842..f80f80874 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) { - DRAW_IMAGE(g, image, x, y); + g->drawImage2(image, x, y); x += emoteWidth; if (x + emoteWidth > width) { diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index da9c4521e..781f35e79 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -146,7 +146,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - DRAW_IMAGE(g, image, mImagePadding, item.y + (height + g->drawImage2(image, mImagePadding, item.y + (height - image->getHeight()) / 2 + mPadding); } } @@ -180,7 +180,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - DRAW_IMAGE(g, image, mImagePadding, item.y + (height + g->drawImage2(image, mImagePadding, item.y + (height - image->getHeight()) / 2 + mPadding); } } diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index e4985d68f..95e287ace 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -73,7 +73,7 @@ void Icon::draw(gcn::Graphics *g) if (mImage) { Graphics *const graphics = static_cast<Graphics*>(g); - DRAW_IMAGE(graphics, mImage, + graphics->drawImage2(mImage, (mDimension.width - mImage->mBounds.w) / 2, (mDimension.height - mImage->mBounds.h) / 2); } diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 8ba9707a4..5e5caf234 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -278,15 +278,15 @@ void ItemContainer::draw(gcn::Graphics *graphics) if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelImg) - DRAW_IMAGE(g, mSelImg, itemX, itemY); + g->drawImage2(mSelImg, itemX, itemY); } image->setAlpha(1.0F); // ensure the image if fully drawn... - DRAW_IMAGE(g, image, itemX + mPaddingItemX, + g->drawImage2(image, itemX + mPaddingItemX, itemY + mPaddingItemY); if (mProtectedImg && PlayerInfo::isItemProtected( item->getId())) { - DRAW_IMAGE(g, mProtectedImg, + g->drawImage2(mProtectedImg, itemX + mPaddingItemX, itemY + mPaddingItemY); } } diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 7271f3943..f969e34d9 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); - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(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); - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(image, itemX, itemY); } } @@ -218,7 +218,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) if (image) { image->setAlpha(1.0F); - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(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 6ef7439b4..3ae2e73aa 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -149,7 +149,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) if (box) { - DRAW_IMAGE(static_cast<Graphics*>(graphics), + static_cast<Graphics*>(graphics)->drawImage2( box, mImagePadding, (getHeight() - mImageSize) / 2); } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 3a69ea0c0..41204415d 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -429,7 +429,7 @@ void ScrollArea::drawButton(gcn::Graphics *const graphics, if (buttons[dir][state]) { - DRAW_IMAGE(static_cast<Graphics*>(graphics), + static_cast<Graphics*>(graphics)->drawImage2( buttons[dir][state], dim.x, dim.y); } } diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 5bf56c842..90f4e3648 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); - DRAW_IMAGE(graphics, icon, mPadding, y + mPadding); + graphics->drawImage2(icon, mPadding, y + mPadding); } } if (mSelected == i) diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index c4a6fe249..17a6c4edf 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 ++) { - DRAW_IMAGE(g, mBackgroundImg, (i % mGridWidth) * mBoxWidth, + g->drawImage2(mBackgroundImg, (i % mGridWidth) * mBoxWidth, (i / mGridWidth) * mBoxHeight); } } diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index e68482821..b03ba7c2d 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -209,7 +209,7 @@ void Slider::draw(gcn::Graphics *graphics) { if (!mHasMouse) { - DRAW_IMAGE(g, buttons[0].grid[HSTART], x, y); + g->drawImage2(buttons[0].grid[HSTART], x, y); const int width = buttons[0].grid[HSTART]->getWidth(); w -= width + buttons[0].grid[HEND]->getWidth(); x += width; @@ -221,18 +221,18 @@ void Slider::draw(gcn::Graphics *graphics) } x += w; - DRAW_IMAGE(g, buttons[0].grid[HEND], x, y); + g->drawImage2(buttons[0].grid[HEND], x, y); const Image *const img = buttons[0].grid[HGRIP]; if (img) { - DRAW_IMAGE(g, img, getMarkerPosition(), + g->drawImage2(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } else { - DRAW_IMAGE(g, buttons[1].grid[HSTART], x, y); + g->drawImage2(buttons[1].grid[HSTART], x, y); const int width = buttons[1].grid[HSTART]->getWidth(); w -= width; @@ -248,12 +248,12 @@ void Slider::draw(gcn::Graphics *graphics) x += w; if (buttons[1].grid[HEND]) - DRAW_IMAGE(g, buttons[1].grid[HEND], x, y); + g->drawImage2(buttons[1].grid[HEND], x, y); const Image *const img = buttons[1].grid[HGRIP]; if (img) { - DRAW_IMAGE(g, img, getMarkerPosition(), + g->drawImage2(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 7d9ba6d0f..f18668b2b 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); - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(image, itemX, itemY); } } diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 3fa27bbe8..de44d5b02 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -242,7 +242,7 @@ void Tab::draw(gcn::Graphics *graphics) if (skin1) { const int padding = skin1->getPadding(); - DRAW_IMAGE(g, mImage, padding, padding); + g->drawImage2(mImage, padding, padding); } } } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 963288a03..a0ef3038a 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -278,18 +278,18 @@ void Window::draw(gcn::Graphics *graphics) const Image *const button = mSkin->getCloseImage( mResizeHandles == CLOSE); if (button) - DRAW_IMAGE(g, button, mCloseRect.x, mCloseRect.y); + g->drawImage2(button, mCloseRect.x, mCloseRect.y); } // Draw Sticky Button if (mStickyButton) { const Image *const button = mSkin->getStickyImage(mSticky); if (button) - DRAW_IMAGE(g, button, mStickyRect.x, mStickyRect.y); + g->drawImage2(button, mStickyRect.x, mStickyRect.y); } if (mGrip) - DRAW_IMAGE(g, mGrip, mGripRect.x, mGripRect.y); + g->drawImage2(mGrip, mGripRect.x, mGripRect.y); } // Draw title diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 9fe03d1cc..6ea49e607 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -202,13 +202,9 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) if (!box) continue; if (i == mSelected) - { - DRAW_IMAGE(g, mSlotHighlightedBackground, box->x, box->y); - } + g->drawImage2(mSlotHighlightedBackground, box->x, box->y); else - { - DRAW_IMAGE(g, mSlotBackground, box->x, box->y); - } + g->drawImage2(mSlotBackground, box->x, box->y); } } @@ -234,7 +230,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) { image->setAlpha(1.0F); // Ensure the image is drawn // with maximum opacity - DRAW_IMAGE(g, image, box->x + mItemPadding, + g->drawImage2(image, box->x + mItemPadding, box->y + mItemPadding); if (i == EQUIP_PROJECTILE_SLOT) { @@ -248,7 +244,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) } else if (box->image) { - DRAW_IMAGE(g, box->image, box->x + mItemPadding, + g->drawImage2(box->image, box->x + mItemPadding, box->y + mItemPadding); } } diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 6db0b5388..22980f7d9 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; } - DRAW_IMAGE(graph, mMapImage, mMapOriginX, mMapOriginY); + graph->drawImage2(mMapImage, mMapOriginX, mMapOriginY); } const ActorSprites &actors = actorManager->getAll(); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index c242f5d85..abd3e966a 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) { - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(image, itemX, itemY); foundItem = true; } } @@ -359,7 +359,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) mItemColors[mCurrentOutfit][i]); if (image) { - DRAW_IMAGE(g, image, itemX, itemY); + g->drawImage2(image, itemX, itemY); image->decRef(); } } diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index b21f0c09b..f4526475c 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; - DRAW_IMAGE(graphics, data->icon, mPadding, yPad); + graphics->drawImage2(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 71592566c..6e40f50da 100644 --- a/src/imagesprite.cpp +++ b/src/imagesprite.cpp @@ -56,5 +56,5 @@ void ImageSprite::draw(Graphics *const graphics, return; mImage->setAlpha(mAlpha); - DRAW_IMAGE(graphics, mImage, posX, posY); + graphics->drawImage2(mImage, posX, posY); } diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 10e134e9d..1d5c4d003 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -139,7 +139,7 @@ void MapLayer::draw(Graphics *const graphics, if (!c) { - DRAW_IMAGE(graphics, img, px, py); + graphics->drawImage2(img, px, py); } else { @@ -455,7 +455,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, if (!c) { - DRAW_IMAGE(graphics, img, px, py); + graphics->drawImage2(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) - DRAW_IMAGE(graphics, mImage, x, y); + graphics->drawImage2(mImage, x, y); switch (mType) { diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp index fa96f5962..a0b31da02 100644 --- a/src/particle/imageparticle.cpp +++ b/src/particle/imageparticle.cpp @@ -103,6 +103,6 @@ void ImageParticle::draw(Graphics *const graphics, } mImage->setAlpha(alphafactor); - DRAW_IMAGE(graphics, mImage, screenX, screenY); + graphics->drawImage2(mImage, screenX, screenY); return; } diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 9072c0a29..cd2332d19 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -482,17 +482,17 @@ void Graphics::drawImageRect(const int x, const int y, // Draw the corners if (drawMain) { - DRAW_IMAGE(this, topLeft, x, y); + drawImage2(topLeft, x, y); const int trw = topRight->getWidth(); if (w > trw) { - DRAW_IMAGE(this, topRight, x + w - trw, y); + drawImage2(topRight, x + w - trw, y); } - DRAW_IMAGE(this, bottomLeft, x, h - bottomLeft->getHeight() + y); + drawImage2(bottomLeft, x, h - bottomLeft->getHeight() + y); const int brw = bottomRight->getWidth(); if (w > brw) { - DRAW_IMAGE(this, bottomRight, + drawImage2(bottomRight, x + w - brw, y + h - bottomRight->getHeight()); } diff --git a/src/render/graphics.h b/src/render/graphics.h index 82bf220ab..a0c0c64eb 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -47,15 +47,6 @@ 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: @@ -380,10 +371,7 @@ class Graphics : public gcn::Graphics * <code>false</code> otherwise. */ virtual bool drawImage2(const Image *const image, - int srcX, int srcY, - int dstX, int dstY, - const int width, const int height, - const bool useColor) = 0; + int dstX, int dstY) = 0; virtual void drawImageCached(const Image *const image, int srcX, int srcY) = 0; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index dc3341fd2..8a1f47bef 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -218,29 +218,22 @@ static inline void drawRescaledQuad(const Image *const image, bool MobileOpenGLGraphics::drawImage2(const Image *const image, - int srcX, int srcY, - int dstX, int dstY, - const int width, const int height, - const bool useColor) + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) if (!image) return false; - const SDL_Rect &imageRect = image->mBounds; - - if (!useColor) - setColorAlpha(image->mAlpha); - + setColorAlpha(image->mAlpha); #ifdef DEBUG_BIND_TEXTURE debugBindTexture(image); #endif bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); - setTexturingAndBlending(true); - drawQuad(image, srcX + imageRect.x, srcY + imageRect.y, - dstX, dstY, width, height); + const SDL_Rect &imageRect = image->mBounds; + drawQuad(image, imageRect.x, imageRect.y, + dstX, dstY, imageRect.w, imageRect.h); return true; } @@ -407,10 +400,7 @@ bool MobileOpenGLGraphics::drawRescaledImage(const Image *const image, // Just draw the image normally when no resizing is necessary, if (width == desiredWidth && height == desiredHeight) - { - return drawImage2(image, srcX, srcY, dstX, dstY, - width, height, useColor); - } + return drawImage2(image, dstX, dstY); // When the desired image is smaller than the current one, // disable smooth effect. diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index 447415823..74b4aa458 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -190,10 +190,7 @@ 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 0f7cc966b..28572f9ba 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -285,29 +285,23 @@ static inline void drawRescaledQuad(const Image *const image, bool NormalOpenGLGraphics::drawImage2(const Image *const image, - int srcX, int srcY, - int dstX, int dstY, - const int width, const int height, - const bool useColor) + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) if (!image) return false; - const SDL_Rect &imageRect = image->mBounds; - - if (!useColor) - setColorAlpha(image->mAlpha); + setColorAlpha(image->mAlpha); #ifdef DEBUG_BIND_TEXTURE debugBindTexture(image); #endif bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); - setTexturingAndBlending(true); - drawQuad(image, srcX + imageRect.x, srcY + imageRect.y, - dstX, dstY, width, height); + const SDL_Rect &imageRect = image->mBounds; + drawQuad(image, imageRect.x, imageRect.y, + dstX, dstY, imageRect.w, imageRect.h); return true; } @@ -520,10 +514,7 @@ bool NormalOpenGLGraphics::drawRescaledImage(const Image *const image, // Just draw the image normally when no resizing is necessary, if (width == desiredWidth && height == desiredHeight) - { - return drawImage2(image, srcX, srcY, dstX, dstY, - width, height, useColor); - } + return drawImage2(image, dstX, dstY); // When the desired image is smaller than the current one, // disable smooth effect. diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 73457ef0d..27e6120b4 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -199,10 +199,7 @@ 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index ab1291233..9e0b49aeb 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -138,30 +138,22 @@ static inline void drawRescaledQuad(const Image *const image A_UNUSED, bool NullOpenGLGraphics::drawImage2(const Image *const image, - int srcX, int srcY, - int dstX, int dstY, - const int width, const int height, - const bool useColor) + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) if (!image) return false; - const SDL_Rect &imageRect = image->mBounds; - srcX += imageRect.x; - srcY += imageRect.y; - - if (!useColor) - setColorAlpha(image->mAlpha); - + setColorAlpha(image->mAlpha); #ifdef DEBUG_BIND_TEXTURE debugBindTexture(image); #endif bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); - setTexturingAndBlending(true); - drawQuad(image, srcX, srcY, dstX, dstY, width, height); + const SDL_Rect &imageRect = image->mBounds; + drawQuad(image, imageRect.x, imageRect.y, dstX, dstY, + imageRect.w, imageRect.h); return true; } @@ -211,10 +203,7 @@ bool NullOpenGLGraphics::drawRescaledImage(const Image *const image, // Just draw the image normally when no resizing is necessary, if (width == desiredWidth && height == desiredHeight) - { - return drawImage2(image, srcX, srcY, dstX, dstY, - width, height, useColor); - } + return drawImage2(image, dstX, dstY); // When the desired image is smaller than the current one, // disable smooth effect. diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index 7b15cfbf5..abb2f836f 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -195,10 +195,7 @@ 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index 1170f0300..614c4158c 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -140,26 +140,21 @@ static inline void drawRescaledQuad(const Image *const image, bool SafeOpenGLGraphics::drawImage2(const Image *const image, - int srcX, int srcY, - int dstX, int dstY, - const int width, const int height, - const bool useColor) + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) if (!image) return false; - if (!useColor) - setColorAlpha(image->mAlpha); - + setColorAlpha(image->mAlpha); bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); - setTexturingAndBlending(true); + const SDL_Rect &bounds = image->mBounds; // Draw a textured quad. glBegin(GL_QUADS); - drawQuad(image, srcX + image->mBounds.x, srcY + image->mBounds.y, - dstX, dstY, width, height); + drawQuad(image, bounds.x, bounds.y, + dstX, dstY, bounds.w, bounds.h); glEnd(); return true; @@ -254,10 +249,7 @@ bool SafeOpenGLGraphics::drawRescaledImage(const Image *const image, int srcX, // Just draw the image normally when no resizing is necessary, if (width == desiredWidth && height == desiredHeight) - { - return drawImage2(image, srcX, srcY, dstX, dstY, - width, height, useColor); - } + return drawImage2(image, dstX, dstY); // When the desired image is smaller than the current one, // disable smooth effect. diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index dac61cb47..2fdc3b3f2 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -158,10 +158,7 @@ class SafeOpenGLGraphics final : public Graphics void prepareScreenshot() override final; 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 00452d9c6..d9844ee6d 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -116,9 +116,8 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, &srcRect, &dstRect) < 0); } -bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, - int dstX, int dstY, const int width, - const int height, const bool useColor A_UNUSED) +bool SDLGraphics::drawImage2(const Image *const image, + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) // Check that preconditions for blitting are met. @@ -132,18 +131,18 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, const SDL_Rect &bounds = image->mBounds; const SDL_Rect srcRect = { - static_cast<int32_t>(srcX + bounds.x), - static_cast<int32_t>(srcY + bounds.y), - static_cast<int32_t>(width), - static_cast<int32_t>(height) + static_cast<int32_t>(bounds.x), + static_cast<int32_t>(bounds.y), + static_cast<int32_t>(bounds.w), + static_cast<int32_t>(bounds.h) }; const SDL_Rect dstRect = { static_cast<int32_t>(dstX + top.xOffset), static_cast<int32_t>(dstY + top.yOffset), - static_cast<int32_t>(width), - static_cast<int32_t>(height) + static_cast<int32_t>(bounds.w), + static_cast<int32_t>(bounds.h) }; return !MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect); diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index f1960d358..9ab56afe7 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -137,10 +137,7 @@ class SDLGraphics final : public Graphics { mRendererFlags = flags; } 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index b0d76bd57..fa92f6030 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -112,10 +112,7 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image, } bool SDL2SoftwareGraphics::drawImage2(const Image *const image, - int srcX, int srcY, - int dstX, int dstY, const int width, - const int height, - const bool useColor A_UNUSED) + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) // Check that preconditions for blitting are met. @@ -127,13 +124,13 @@ bool SDL2SoftwareGraphics::drawImage2(const Image *const image, SDL_Surface *const src = image->mSDLSurface; - srcX += bounds.x; - srcY += bounds.y; + int srcX = bounds.x; + int srcY = bounds.y; dstX += top.xOffset; dstY += top.yOffset; - int w = width; - int h = height; + int w = bounds.w; + int h = bounds.h; if (srcX < 0) { w += srcX; @@ -183,8 +180,8 @@ bool SDL2SoftwareGraphics::drawImage2(const Image *const image, { SDL_Rect srcRect = { - static_cast<int16_t>(srcX), - static_cast<int16_t>(srcY), + static_cast<int16_t>(0), + static_cast<int16_t>(0), static_cast<uint16_t>(w), static_cast<uint16_t>(h) }; diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index ab9fb7ce4..718088972 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -140,10 +140,7 @@ class SDL2SoftwareGraphics final : public Graphics bool resizeScreen(const int width, const int height) override final; 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index c46b65000..ef1f2d2a5 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -104,9 +104,8 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, return returnValue; } -bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, - int dstX, int dstY, const int width, - const int height, const bool useColor A_UNUSED) +bool SDLGraphics::drawImage2(const Image *const image, + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) // Check that preconditions for blitting are met. @@ -118,13 +117,13 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, SDL_Surface *const src = image->mSDLSurface; - srcX += bounds.x; - srcY += bounds.y; + int srcX = bounds.x; + int srcY = bounds.y; dstX += top.xOffset; dstY += top.yOffset; - int w = width; - int h = height; + int w = bounds.w; + int h = bounds.h; if (srcX < 0) { w += srcX; @@ -174,8 +173,8 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, { SDL_Rect srcRect = { - static_cast<int16_t>(srcX), - static_cast<int16_t>(srcY), + static_cast<int16_t>(0), + static_cast<int16_t>(0), static_cast<uint16_t>(w), static_cast<uint16_t>(h) }; diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index aa7a250f8..2c1847751 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -134,10 +134,7 @@ class SDLGraphics final : public Graphics const bool noFrame) override final; 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp index db2722164..fe2926473 100644 --- a/src/render/surfacegraphics.cpp +++ b/src/render/surfacegraphics.cpp @@ -42,27 +42,23 @@ SurfaceGraphics::~SurfaceGraphics() { } -bool SurfaceGraphics::drawImage2(const Image *const image, int srcX, int srcY, - int dstX, int dstY, - const int width, const int height, - const bool useColor A_UNUSED) +bool SurfaceGraphics::drawImage2(const Image *const image, + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage2", 1) // Check that preconditions for blitting are met. if (!mTarget || !image || !image->mSDLSurface) return false; - srcX += image->mBounds.x; - srcY += image->mBounds.y; - + const SDL_Rect &imageRect = image->mBounds; SDL_Rect dstRect; SDL_Rect srcRect; dstRect.x = static_cast<int16_t>(dstX); dstRect.y = static_cast<int16_t>(dstY); - srcRect.x = static_cast<int16_t>(srcX); - srcRect.y = static_cast<int16_t>(srcY); - srcRect.w = static_cast<uint16_t>(width); - srcRect.h = static_cast<uint16_t>(height); + srcRect.x = static_cast<int16_t>(imageRect.x); + srcRect.y = static_cast<int16_t>(imageRect.y); + srcRect.w = static_cast<uint16_t>(imageRect.w); + srcRect.h = static_cast<uint16_t>(imageRect.h); #ifdef USE_SDL2 return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index 6a2a7f3cb..b606d0ddf 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -183,10 +183,7 @@ class SurfaceGraphics final : public Graphics { return false; } 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; + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index f1a67bfe5..ccf21ecfc 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 - DRAW_IMAGE(graphics, image, item->x, item->y); + graphics->drawImage2(image, item->x, item->y); } } } diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 77e84d835..64b64af41 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -79,7 +79,7 @@ void SimpleAnimation::draw(Graphics *const graphics, if (!mCurrentFrame || !mCurrentFrame->image) return; - DRAW_IMAGE(graphics, mCurrentFrame->image, + graphics->drawImage2(mCurrentFrame->image, posX + mCurrentFrame->offsetX, posY + mCurrentFrame->offsetY); } diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 99f0b1753..d13308110 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 ++) { - DRAW_IMAGE(mainGraphics, img, cnt * 7, cnt * 5); + mainGraphics->drawImage2(img, cnt * 7, cnt * 5); mainGraphics->updateScreen(); } @@ -152,11 +152,11 @@ int TestLauncher::testFps() { for (int y = 0; y < 600; y += 50) { - DRAW_IMAGE(mainGraphics, img[idx], x, y); + mainGraphics->drawImage2(img[idx], x, y); idx ++; if (idx > sz) idx = 0; - DRAW_IMAGE(mainGraphics, img[idx], x, y); + mainGraphics->drawImage2(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) { - DRAW_IMAGE(mainGraphics, img[idx], x, y); - DRAW_IMAGE(mainGraphics, img[idx], x + 1, y); - DRAW_IMAGE(mainGraphics, img[idx], x, y + 5); + mainGraphics->drawImage2(img[idx], x, y); + mainGraphics->drawImage2(img[idx], x + 1, y); + mainGraphics->drawImage2(img[idx], x, y + 5); idx ++; if (idx > 3) diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 843a578ce..195ef7100 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -225,7 +225,7 @@ void TouchManager::draw() const Image *const icon = item->icon; if (icon) { - DRAW_IMAGE(mainGraphics, icon, + mainGraphics->drawImage2(icon, item->x + (item->width - icon->mBounds.w) / 2, item->y + (item->height - icon->mBounds.h) / 2); } |