* Draw the Surface Buffer to SDLSurface, using the surface palette */
| 205 | * Draw the Surface Buffer to SDLSurface, using the surface palette |
| 206 | */ |
| 207 | void cSurface::draw(const int16 pSkipX, const int16 pSkipY) { |
| 208 | if (mIsLoadedImage) |
| 209 | return; |
| 210 | |
| 211 | const uint8_t* bufferCurrent = mSurfaceBuffer; |
| 212 | const uint8_t* const bufferEnd = mSurfaceBuffer + mSurfaceBufferSize; |
| 213 | uint32_t* bufferTarget = reinterpret_cast<uint32_t*>(mSDLSurface->pixels); |
| 214 | const int width = mSDLSurface->w, height = mSDLSurface->h; |
| 215 | |
| 216 | clearSDLSurface(0); |
| 217 | |
| 218 | // Skip 'skipY' rows of pixels |
| 219 | bufferCurrent += width * pSkipY; |
| 220 | bufferTarget += width * pSkipY; |
| 221 | |
| 222 | for (int y = pSkipY; y < height; ++y) { |
| 223 | // Skip first 'skipX' pixels |
| 224 | bufferCurrent += pSkipX; |
| 225 | bufferTarget += pSkipX; |
| 226 | |
| 227 | // Process remaining pixels |
| 228 | for (int x = pSkipX; x < width; ++x) { |
| 229 | if (bufferCurrent >= bufferEnd) break; |
| 230 | |
| 231 | uint8_t currentPixel = *bufferCurrent++; |
| 232 | if (currentPixel) { |
| 233 | *bufferTarget = (currentPixel < g_MaxColors) ? mPaletteSDL[currentPixel] : 0; |
| 234 | } |
| 235 | |
| 236 | ++bufferTarget; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | if (mTexture) { |
| 241 | SDL_UpdateTexture(mTexture, NULL, mSDLSurface->pixels, mSDLSurface->pitch); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | void cSurface::copyFrom(const cSurface* pFrom) { |
| 246 |
no outgoing calls
no test coverage detected