diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-02 04:36:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-02 04:37:42 +0300 |
commit | ca58a3cced99fc2a8989da0155c1927bc0f08b6f (patch) | |
tree | c8fc16ac2c5c0a9184c17c2920266b96934ed28f /src/resources | |
parent | d4dd89e72f8b1e2c0517981f7e3ffac4a040f9fa (diff) | |
download | manaverse-ca58a3cced99fc2a8989da0155c1927bc0f08b6f.tar.gz manaverse-ca58a3cced99fc2a8989da0155c1927bc0f08b6f.tar.bz2 manaverse-ca58a3cced99fc2a8989da0155c1927bc0f08b6f.tar.xz manaverse-ca58a3cced99fc2a8989da0155c1927bc0f08b6f.zip |
Replace some getters to direct member access in Image class.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/ambientlayer.cpp | 12 | ||||
-rw-r--r-- | src/resources/image.cpp | 6 | ||||
-rw-r--r-- | src/resources/image.h | 3 | ||||
-rw-r--r-- | src/resources/imageloader.cpp | 4 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index caa4d46bf..09a235e59 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -47,9 +47,9 @@ AmbientLayer::AmbientLayer(Image *img, float parallax, // Rescale the overlay to keep the ratio as if we were on // the default resolution... Image *rescaledOverlay = ResourceManager::getInstance()-> - getRescaled(mImage, static_cast<int>(mImage->getWidth()) + getRescaled(mImage, static_cast<int>(mImage->mBounds.w) / defaultScreenWidth * graphics->getWidth(), - static_cast<int>(mImage->getHeight()) + static_cast<int>(mImage->mBounds.h) / defaultScreenHeight * graphics->getHeight()); if (rescaledOverlay) @@ -85,8 +85,8 @@ void AmbientLayer::update(int timePassed, float dx, float dy) mPosX += dx * mParallax; mPosY += dy * mParallax; - int imgW = mImage->getWidth(); - int imgH = mImage->getHeight(); + int imgW = mImage->mBounds.w; + int imgH = mImage->mBounds.h; // Wrap values while (mPosX > imgW) @@ -116,9 +116,9 @@ void AmbientLayer::draw(Graphics *graphics, int x, int y) graphics->drawRescaledImagePattern(mImage, static_cast<int>(-mPosX), static_cast<int>(-mPosY), x + static_cast<int>(mPosX), y + static_cast<int>(mPosY), - static_cast<int>(mImage->getWidth()) + static_cast<int>(mImage->mBounds.w) / defaultScreenWidth * graphics->getWidth(), - static_cast<int>(mImage->getHeight()) / defaultScreenHeight + static_cast<int>(mImage->mBounds.h) / defaultScreenHeight * graphics->getHeight()); } } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index ec74630ff..2d3676304 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -386,8 +386,10 @@ Image* Image::SDLmerge(Image *image, int x, int y) SDL_LockSurface(mSDLSurface); const int x0 = (y * getWidth()) + x; - const int maxX = std::min(image->getWidth(), getWidth() - x); - const int maxY = std::min(image->getHeight(), getHeight() - y); + const int maxX = std::min(image->mBounds.w, + static_cast<Uint16>(mBounds.w - x)); + const int maxY = std::min(image->mBounds.w, + static_cast<Uint16>(mBounds.h - y)); // for each pixel lines of a source image for (offset_x = (x > 0 ? 0 : -x); offset_x < maxX; offset_x++) diff --git a/src/resources/image.h b/src/resources/image.h index 4f59ba1ae..72b85cc1e 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -214,13 +214,14 @@ class Image : public Resource static int mTextureType; #endif + SDL_Rect mBounds; + protected: // ----------------------- // Generic protected members // ----------------------- - SDL_Rect mBounds; bool mLoaded; float mAlpha; bool mHasAlphaChannel; diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index fa5d0eea1..c63d33c00 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -66,7 +66,7 @@ int ProxyImage::getWidth() const if (mSDLImage) return mSDLImage->w; else if (mImage) - return mImage->getWidth(); + return mImage->mBounds.w; else return 0; } @@ -76,7 +76,7 @@ int ProxyImage::getHeight() const if (mSDLImage) return mSDLImage->h; else if (mImage) - return mImage->getHeight(); + return mImage->mBounds.h; else return 0; // return mSDLImage ? mSDLImage->h : mImage->getHeight(); |