From de4dc993a14f7a092f968c78b61e91ceedee342c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Feb 2020 18:12:50 -0800 Subject: [PATCH] ULTIMA8: Renaming render surface class fields --- engines/ultima/ultima8/graphics/anim_dat.cpp | 24 +- engines/ultima/ultima8/graphics/anim_dat.h | 2 +- .../graphics/base_soft_render_surface.cpp | 206 +++++++++--------- .../graphics/base_soft_render_surface.h | 48 ++-- .../ultima8/graphics/soft_render_surface.cpp | 110 +++++----- .../ultima8/graphics/soft_render_surface.inl | 71 +++--- 6 files changed, 221 insertions(+), 240 deletions(-) diff --git a/engines/ultima/ultima8/graphics/anim_dat.cpp b/engines/ultima/ultima8/graphics/anim_dat.cpp index 78b06a8cedf..880860c3741 100644 --- a/engines/ultima/ultima8/graphics/anim_dat.cpp +++ b/engines/ultima/ultima8/graphics/anim_dat.cpp @@ -39,22 +39,22 @@ AnimDat::AnimDat() { AnimDat::~AnimDat() { - for (unsigned int i = 0; i < anims.size(); i++) - delete anims[i]; - anims.clear(); + for (unsigned int i = 0; i < _anims.size(); i++) + delete _anims[i]; + _anims.clear(); } ActorAnim *AnimDat::getAnim(uint32 shape) const { - if (shape >= anims.size()) return 0; + if (shape >= _anims.size()) return 0; - return anims[shape]; + return _anims[shape]; } AnimAction *AnimDat::getAnim(uint32 shape, uint32 action) const { - if (shape >= anims.size()) return 0; - if (anims[shape] == 0) return 0; + if (shape >= _anims.size()) return 0; + if (_anims[shape] == 0) return 0; - return anims[shape]->getAction(action); + return _anims[shape]->getAction(action); } @@ -62,18 +62,18 @@ void AnimDat::load(IDataSource *ds) { AnimFrame f; // CONSTANT ! - anims.resize(2048); + _anims.resize(2048); unsigned int actioncount = 64; if (GAME_IS_CRUSADER) actioncount = 256; - for (unsigned int shape = 0; shape < anims.size(); shape++) { + for (unsigned int shape = 0; shape < _anims.size(); shape++) { ds->seek(4 * shape); uint32 offset = ds->read4(); if (offset == 0) { - anims[shape] = 0; + _anims[shape] = 0; continue; } @@ -146,7 +146,7 @@ void AnimDat::load(IDataSource *ds) { } } - anims[shape] = a; + _anims[shape] = a; } } diff --git a/engines/ultima/ultima8/graphics/anim_dat.h b/engines/ultima/ultima8/graphics/anim_dat.h index 40409390a31..451c59733c4 100644 --- a/engines/ultima/ultima8/graphics/anim_dat.h +++ b/engines/ultima/ultima8/graphics/anim_dat.h @@ -43,7 +43,7 @@ public: AnimAction *getAnim(uint32 shape, uint32 action) const; private: - Std::vector anims; + Std::vector _anims; }; } // End of namespace Ultima8 diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp index b4026712951..b4f9da6538f 100644 --- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp +++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp @@ -41,39 +41,39 @@ namespace Ultima8 { // Desc: Constructor for BaseSoftRenderSurface from a SDL_Surface // BaseSoftRenderSurface::BaseSoftRenderSurface(Graphics::ManagedSurface *s) : - pixels(0), pixels00(0), zbuffer(0), zbuffer00(0), - bytes_per_pixel(0), bits_per_pixel(0), format_type(0), - ox(0), oy(0), width(0), height(0), pitch(0), zpitch(0), - flipped(false), clip_window(0, 0, 0, 0), lock_count(0), - sdl_surf(s), rtt_tex(0) { - clip_window.ResizeAbs(width = sdl_surf->w, height = sdl_surf->h); - pitch = sdl_surf->pitch; - bits_per_pixel = sdl_surf->format.bpp(); - bytes_per_pixel = sdl_surf->format.bytesPerPixel; + _pixels(0), _pixels00(0), _zBuffer(0), _zBuffer00(0), + _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0), + _ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0), + _flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0), + _sdlSurf(s), _rttTex(0) { + _clipWindow.ResizeAbs(_width = _sdlSurf->w, _height = _sdlSurf->h); + _pitch = _sdlSurf->pitch; + _bitsPerPixel = _sdlSurf->format.bpp(); + _bytesPerPixel = _sdlSurf->format.bytesPerPixel; - RenderSurface::format.s_bpp = bits_per_pixel; - RenderSurface::format.s_bytes_per_pixel = bytes_per_pixel; - RenderSurface::format.r_loss = sdl_surf->format.rLoss; - RenderSurface::format.g_loss = sdl_surf->format.gLoss; - RenderSurface::format.b_loss = sdl_surf->format.bLoss; - RenderSurface::format.a_loss = sdl_surf->format.aLoss; + RenderSurface::format.s_bpp = _bitsPerPixel; + RenderSurface::format.s_bytes_per_pixel = _bytesPerPixel; + RenderSurface::format.r_loss = _sdlSurf->format.rLoss; + RenderSurface::format.g_loss = _sdlSurf->format.gLoss; + RenderSurface::format.b_loss = _sdlSurf->format.bLoss; + RenderSurface::format.a_loss = _sdlSurf->format.aLoss; RenderSurface::format.r_loss16 = format.r_loss + 8; RenderSurface::format.g_loss16 = format.g_loss + 8; RenderSurface::format.b_loss16 = format.b_loss + 8; RenderSurface::format.a_loss16 = format.a_loss + 8; - RenderSurface::format.r_shift = sdl_surf->format.rShift; - RenderSurface::format.g_shift = sdl_surf->format.gShift; - RenderSurface::format.b_shift = sdl_surf->format.bShift; - RenderSurface::format.a_shift = sdl_surf->format.aShift; - RenderSurface::format.r_mask = sdl_surf->format.rMax(); - RenderSurface::format.g_mask = sdl_surf->format.gMax(); - RenderSurface::format.b_mask = sdl_surf->format.bMax(); - RenderSurface::format.a_mask = sdl_surf->format.aMax(); + RenderSurface::format.r_shift = _sdlSurf->format.rShift; + RenderSurface::format.g_shift = _sdlSurf->format.gShift; + RenderSurface::format.b_shift = _sdlSurf->format.bShift; + RenderSurface::format.a_shift = _sdlSurf->format.aShift; + RenderSurface::format.r_mask = _sdlSurf->format.rMax(); + RenderSurface::format.g_mask = _sdlSurf->format.gMax(); + RenderSurface::format.b_mask = _sdlSurf->format.bMax(); + RenderSurface::format.a_mask = _sdlSurf->format.aMax(); SetPixelsPointer(); // Trickery to get the alpha channel - if (format.a_mask == 0 && bytes_per_pixel == 4) { + if (format.a_mask == 0 && _bytesPerPixel == 4) { uint32 mask = ~(format.r_mask | format.g_mask | format.b_mask); // Using all bits???? @@ -118,11 +118,11 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(Graphics::ManagedSurface *s) : // BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, int bpp, int rsft, int gsft, int bsft, int asft) : - pixels(0), pixels00(0), zbuffer(0), zbuffer00(0), - bytes_per_pixel(0), bits_per_pixel(0), format_type(0), - ox(0), oy(0), width(0), height(0), pitch(0), zpitch(0), - flipped(false), clip_window(0, 0, 0, 0), lock_count(0), sdl_surf(0), rtt_tex(0) { - clip_window.ResizeAbs(width = w, height = h); + _pixels(0), _pixels00(0), _zBuffer(0), _zBuffer00(0), + _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0), + _ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0), + _flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0), _sdlSurf(0), _rttTex(0) { + _clipWindow.ResizeAbs(_width = w, _height = h); switch (bpp) { case 15: @@ -151,12 +151,12 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, int bpp, break; } - pitch = w * bpp / 8; - bits_per_pixel = bpp; - bytes_per_pixel = bpp / 8; + _pitch = w * bpp / 8; + _bitsPerPixel = bpp; + _bytesPerPixel = bpp / 8; RenderSurface::format.s_bpp = bpp; - RenderSurface::format.s_bytes_per_pixel = bytes_per_pixel; + RenderSurface::format.s_bytes_per_pixel = _bytesPerPixel; RenderSurface::format.r_loss16 = format.r_loss + 8; RenderSurface::format.g_loss16 = format.g_loss + 8; RenderSurface::format.b_loss16 = format.b_loss + 8; @@ -180,18 +180,18 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, int bpp, // Desc: Constructor for Generic BaseSoftRenderSurface which matches screen params // BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, uint8 *buf) : - pixels(0), pixels00(0), zbuffer(0), zbuffer00(0), - bytes_per_pixel(0), bits_per_pixel(0), format_type(0), - ox(0), oy(0), width(0), height(0), pitch(0), zpitch(0), - flipped(false), clip_window(0, 0, 0, 0), lock_count(0), sdl_surf(0), rtt_tex(0) { - clip_window.ResizeAbs(width = w, height = h); + _pixels(0), _pixels00(0), _zBuffer(0), _zBuffer00(0), + _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0), + _ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0), + _flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0), _sdlSurf(0), _rttTex(0) { + _clipWindow.ResizeAbs(_width = w, _height = h); int bpp = RenderSurface::format.s_bpp; - pitch = w * bpp / 8; - bits_per_pixel = bpp; - bytes_per_pixel = bpp / 8; - pixels00 = buf; + _pitch = w * bpp / 8; + _bitsPerPixel = bpp; + _bytesPerPixel = bpp / 8; + _pixels00 = buf; SetPixelsPointer(); } @@ -202,25 +202,25 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, uint8 *buf) : // Desc: Constructor for Generic BaseSoftRenderSurface which matches screen params // BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h) : - pixels(0), pixels00(0), zbuffer(0), zbuffer00(0), - bytes_per_pixel(0), bits_per_pixel(0), format_type(0), - ox(0), oy(0), width(0), height(0), pitch(0), zpitch(0), - flipped(false), clip_window(0, 0, 0, 0), lock_count(0), sdl_surf(0), rtt_tex(0) { - clip_window.ResizeAbs(width = w, height = h); + _pixels(0), _pixels00(0), _zBuffer(0), _zBuffer00(0), + _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0), + _ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0), + _flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0), _sdlSurf(0), _rttTex(0) { + _clipWindow.ResizeAbs(_width = w, _height = h); int bpp = RenderSurface::format.s_bpp; - pitch = w * bpp / 8; - bits_per_pixel = bpp; - bytes_per_pixel = bpp / 8; - pixels00 = new uint8[pitch * height]; + _pitch = w * bpp / 8; + _bitsPerPixel = bpp; + _bytesPerPixel = bpp / 8; + _pixels00 = new uint8[_pitch * _height]; - rtt_tex = new Texture; - rtt_tex->buffer = reinterpret_cast(pixels00); - rtt_tex->width = width; - rtt_tex->height = height; - rtt_tex->format = TEX_FMT_NATIVE; - rtt_tex->CalcLOG2s(); + _rttTex = new Texture; + _rttTex->buffer = reinterpret_cast(_pixels00); + _rttTex->width = _width; + _rttTex->height = _height; + _rttTex->format = TEX_FMT_NATIVE; + _rttTex->CalcLOG2s(); SetPixelsPointer(); } @@ -232,15 +232,15 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h) : // Desc: Destructor // BaseSoftRenderSurface::~BaseSoftRenderSurface() { - if (rtt_tex) { - delete rtt_tex; - rtt_tex = 0; + if (_rttTex) { + delete _rttTex; + _rttTex = 0; - delete [] pixels00; - pixels00 = 0; + delete [] _pixels00; + _pixels00 = 0; - delete [] zbuffer00; - zbuffer00 = 0; + delete [] _zBuffer00; + _zBuffer00 = 0; } } @@ -252,26 +252,26 @@ BaseSoftRenderSurface::~BaseSoftRenderSurface() { // Returns: Non Zero on error // ECode BaseSoftRenderSurface::BeginPainting() { - if (!lock_count) { + if (!_lockCount) { - if (sdl_surf) { + if (_sdlSurf) { // Pixels pointer - Graphics::Surface s = sdl_surf->getSubArea(Common::Rect(0, 0, sdl_surf->w, sdl_surf->h)); - pixels00 = static_cast(s.getPixels()); + Graphics::Surface s = _sdlSurf->getSubArea(Common::Rect(0, 0, _sdlSurf->w, _sdlSurf->h)); + _pixels00 = static_cast(s.getPixels()); - pitch = sdl_surf->pitch; - if (flipped) pitch = -pitch; + _pitch = _sdlSurf->pitch; + if (_flipped) _pitch = -_pitch; } else { ECode ret = GenericLock(); if (ret.failed()) return ret; } } - lock_count++; + _lockCount++; - if (pixels00 == 0) { - // TODO: SetLastError(GR_SOFT_ERROR_LOCKED_NULL_PIXELS, "Surface Locked with NULL BaseSoftRenderSurface::pixels pointer!"); - perr << "Error: Surface Locked with NULL BaseSoftRenderSurface::pixels pointer!" << Std::endl; + if (_pixels00 == 0) { + // TODO: SetLastError(GR_SOFT_ERROR_LOCKED_NULL_PIXELS, "Surface Locked with NULL BaseSoftRenderSurface::_pixels pointer!"); + perr << "Error: Surface Locked with NULL BaseSoftRenderSurface::_pixels pointer!" << Std::endl; return GR_SOFT_ERROR_LOCKED_NULL_PIXELS; } @@ -291,22 +291,22 @@ ECode BaseSoftRenderSurface::BeginPainting() { // ECode BaseSoftRenderSurface::EndPainting() { // Already Unlocked - if (!lock_count) { + if (!_lockCount) { // TODO: SetLastError(GR_SOFT_ERROR_BEGIN_END_MISMATCH, "BeginPainting()/EndPainting() Mismatch!"); perr << "Error: BeginPainting()/EndPainting() Mismatch!" << Std::endl; return GR_SOFT_ERROR_BEGIN_END_MISMATCH; } // Decrement counter - --lock_count; + --_lockCount; - if (!lock_count) { - if (sdl_surf) { + if (!_lockCount) { + if (_sdlSurf) { // Clear pointers - pixels = pixels00 = 0; + _pixels = _pixels00 = 0; // Render the screen - Graphics::Screen *screen = dynamic_cast(sdl_surf); + Graphics::Screen *screen = dynamic_cast(_sdlSurf); assert(screen); screen->update(); @@ -326,11 +326,11 @@ ECode BaseSoftRenderSurface::EndPainting() { // Desc: Get the surface as a Texture. Only valid for SecondaryRenderSurfaces // Texture *BaseSoftRenderSurface::GetSurfaceAsTexture() { - if (!rtt_tex) { + if (!_rttTex) { perr << "Error: GetSurfaceAsTexture(): Surface doesn't render-to-texture" << Std::endl; } - return rtt_tex; + return _rttTex; } // @@ -413,7 +413,7 @@ void BaseSoftRenderSurface::CreateNativePalette(Palette *palette) { // r: Rect object to fill // void BaseSoftRenderSurface::GetSurfaceDims(Rect &r) const { - r.Set(ox, oy, width, height); + r.Set(_ox, _oy, _width, _height); } // @@ -423,11 +423,11 @@ void BaseSoftRenderSurface::GetSurfaceDims(Rect &r) const { // void BaseSoftRenderSurface::SetOrigin(int32 x, int32 y) { // Adjust the clipping window - clip_window.MoveRel(ox - x, oy - y); + _clipWindow.MoveRel(_ox - x, _oy - y); // Set the origin - ox = x; - oy = y; + _ox = x; + _oy = y; // The new pointers SetPixelsPointer(); @@ -440,8 +440,8 @@ void BaseSoftRenderSurface::SetOrigin(int32 x, int32 y) { // void BaseSoftRenderSurface::GetOrigin(int32 &x, int32 &y) const { // Set the origin - x = ox; - y = oy; + x = _ox; + y = _oy; } // @@ -451,7 +451,7 @@ void BaseSoftRenderSurface::GetOrigin(int32 &x, int32 &y) const { // r: Rect object to fill // void BaseSoftRenderSurface::GetClippingRect(Rect &r) const { - r = clip_window; + r = _clipWindow; } // @@ -462,8 +462,8 @@ void BaseSoftRenderSurface::GetClippingRect(Rect &r) const { // void BaseSoftRenderSurface::SetClippingRect(const Rect &r) { // What we need to do is to clip the clipping rect to the phyiscal screen - clip_window = r; - clip_window.Intersect(-ox, -oy, width, height); + _clipWindow = r; + _clipWindow.Intersect(-_ox, -_oy, _width, _height); } // @@ -476,7 +476,7 @@ void BaseSoftRenderSurface::SetClippingRect(const Rect &r) { // int16 BaseSoftRenderSurface::CheckClipped(const Rect &c) const { Rect r = c; - r.Intersect(clip_window); + r.Intersect(_clipWindow); // Clipped away to the void if (!r.IsValid()) return -1; @@ -485,7 +485,7 @@ int16 BaseSoftRenderSurface::CheckClipped(const Rect &c) const { } // -// void BaseSoftRenderSurface::SetFlipped(bool flipped) +// void BaseSoftRenderSurface::SetFlipped(bool _flipped) // // Desc: Flip the surface // @@ -493,20 +493,20 @@ void BaseSoftRenderSurface::SetFlipped(bool wantFlipped) { // Flipping is not terrible complex // But is a bit of a pain to set up - // First we check to see if we are currently flipped - if (wantFlipped == flipped) return; + // First we check to see if we are currently _flipped + if (wantFlipped == _flipped) return; - flipped = wantFlipped; + _flipped = wantFlipped; // What we 'need' to do is negate the pitches, and flip the clipping window // We keep the 'origin' in the same position relative to the clipping window - oy -= clip_window.y; - clip_window.y = height - (clip_window.y + clip_window.h); - oy += clip_window.y; + _oy -= _clipWindow.y; + _clipWindow.y = _height - (_clipWindow.y + _clipWindow.h); + _oy += _clipWindow.y; - pitch = -pitch; - zpitch = -zpitch; + _pitch = -_pitch; + _zPitch = -_zPitch; SetPixelsPointer(); @@ -515,10 +515,10 @@ void BaseSoftRenderSurface::SetFlipped(bool wantFlipped) { // // bool BaseSoftRenderSurface::IsFlipped() const // -// Desc: Has the render surface been flipped? +// Desc: Has the render surface been _flipped? // bool BaseSoftRenderSurface::IsFlipped() const { - return flipped; + return _flipped; } } // End of namespace Ultima8 diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.h b/engines/ultima/ultima8/graphics/base_soft_render_surface.h index 2070449f11c..3c09bfc9bd4 100644 --- a/engines/ultima/ultima8/graphics/base_soft_render_surface.h +++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.h @@ -38,35 +38,35 @@ namespace Ultima8 { class BaseSoftRenderSurface : public RenderSurface { protected: // Frame buffer - uint8 *pixels; // Pointer to logical pixel 0,0 - uint8 *pixels00; // Pointer to physical pixel 0,0 + uint8 *_pixels; // Pointer to logical pixel 0,0 + uint8 *_pixels00; // Pointer to physical pixel 0,0 // Depth Buffer - uint16 *zbuffer; // Pointer to logical pixel 0,0 - uint8 *zbuffer00; // Pointer to physical pixel 0,0 + uint16 *_zBuffer; // Pointer to logical pixel 0,0 + uint8 *_zBuffer00; // Pointer to physical pixel 0,0 // Pixel Format (also see 'Colour shifting values' later) - int bytes_per_pixel; // 2 or 4 - int bits_per_pixel; // 16 or 32 - int format_type; // 16, 555, 565, 32 or 888 + int _bytesPerPixel; // 2 or 4 + int _bitsPerPixel; // 16 or 32 + int _formatType; // 16, 555, 565, 32 or 888 // Dimensions - int32 ox, oy; // Physical Pixel for Logical Origin - int32 width, height; // Width and height - int32 pitch; // Frame buffer pitch (bytes) (could be negated) - int32 zpitch; // Z Buffer pitch (bytes) (could be negated) - bool flipped; + int32 _ox, _oy; // Physical Pixel for Logical Origin + int32 _width, _height; // Width and height + int32 _pitch; // Frame buffer pitch (bytes) (could be negated) + int32 _zPitch; // Z Buffer pitch (bytes) (could be negated) + bool _flipped; // Clipping Rectangle - Rect clip_window; + Rect _clipWindow; // Locking count - uint32 lock_count; // Number of locks on surface + uint32 _lockCount; // Number of locks on surface - Graphics::ManagedSurface *sdl_surf; + Graphics::ManagedSurface *_sdlSurf; // Renderint to a texture - Texture *rtt_tex; + Texture *_rttTex; // Create from a SDL_Surface BaseSoftRenderSurface(Graphics::ManagedSurface *); @@ -86,16 +86,16 @@ protected: // Update the Pixels Pointer void SetPixelsPointer() { - uint8 *pix00 = pixels00; - uint8 *zbuf00 = zbuffer00; + uint8 *pix00 = _pixels00; + uint8 *zbuf00 = _zBuffer00; - if (flipped) { - pix00 += -pitch * (height - 1); - zbuf00 += -zpitch * (height - 1); + if (_flipped) { + pix00 += -_pitch * (_height - 1); + zbuf00 += -_zPitch * (_height - 1); } - pixels = pix00 + ox * bytes_per_pixel + oy * pitch; - zbuffer = reinterpret_cast(zbuf00 + ox + oy * zpitch); + _pixels = pix00 + _ox * _bytesPerPixel + _oy * _pitch; + _zBuffer = reinterpret_cast(zbuf00 + _ox + _oy * _zPitch); } public: @@ -167,7 +167,7 @@ public: void CreateNativePalette(Palette *palette) override; Graphics::ManagedSurface *getRawSurface() const override { - return sdl_surf; + return _sdlSurf; } }; diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp index 6183dd473c3..fa53b1413c9 100644 --- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp +++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp @@ -98,22 +98,22 @@ template void SoftRenderSurface::Fill8(uint8 /*index*/, int3 // template void SoftRenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) { - clip_window.IntersectOther(sx, sy, w, h); + _clipWindow.IntersectOther(sx, sy, w, h); if (!w || !h) return; // An optimization. - if ((w * sizeof(uintX)) == pitch) { + if ((w * sizeof(uintX)) == _pitch) { w *= h; h = 1; } - uint8 *pixel = pixels + sy * pitch + sx * sizeof(uintX); - uint8 *end = pixel + h * pitch; + uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uintX); + uint8 *end = pixel + h * _pitch; rgb = PACK_RGB8((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF); uint8 *line_end = pixel + w * sizeof(uintX); - int diff = pitch - w * sizeof(uintX); + int diff = _pitch - w * sizeof(uintX); while (pixel != end) { while (pixel != line_end) { @@ -121,52 +121,52 @@ template void SoftRenderSurface::Fill32(uint32 rgb, int32 sx pixel += sizeof(uintX); } - line_end += pitch; + line_end += _pitch; pixel += diff; } } // 16 bit version template<> void SoftRenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) { - clip_window.IntersectOther(sx, sy, w, h); + _clipWindow.IntersectOther(sx, sy, w, h); if (!w || !h) return; // An optimization. - if (2 * w == pitch) { + if (2 * w == _pitch) { w *= h; h = 1; } - uint8 *pixel = pixels + sy * pitch + sx * sizeof(uint16); - uint8 *end = pixel + h * pitch; + uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uint16); + uint8 *end = pixel + h * _pitch; rgb = PACK_RGB8((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF); while (pixel != end) { memset_16(pixel, rgb, w); - pixel += pitch; + pixel += _pitch; } } // 32 bit version template<> void SoftRenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) { - clip_window.IntersectOther(sx, sy, w, h); + _clipWindow.IntersectOther(sx, sy, w, h); if (!w || !h) return; // An optimization. - if (4 * w == pitch) { + if (4 * w == _pitch) { w *= h; h = 1; } - uint8 *pixel = pixels + sy * pitch + sx * sizeof(uint32); - uint8 *end = pixel + h * pitch; + uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uint32); + uint8 *end = pixel + h * _pitch; rgb = PACK_RGB8((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF); while (pixel != end) { memset_32(pixel, rgb, w); - pixel += pitch; + pixel += _pitch; } } @@ -180,20 +180,20 @@ template<> void SoftRenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy //#define CHECK_ALPHA_FILLS template void SoftRenderSurface::FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h) { - clip_window.IntersectOther(sx, sy, w, h); + _clipWindow.IntersectOther(sx, sy, w, h); if (!w || !h || !RenderSurface::format.a_mask) return; // An optimization. - if ((int)(w * sizeof(uintX)) == pitch) { + if ((int)(w * sizeof(uintX)) == _pitch) { w *= h; h = 1; } - uint8 *pixel = pixels + sy * pitch + sx * sizeof(uintX); - uint8 *end = pixel + h * pitch; + uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uintX); + uint8 *end = pixel + h * _pitch; uint8 *line_end = pixel + w * sizeof(uintX); - int diff = pitch - w * sizeof(uintX); + int diff = _pitch - w * sizeof(uintX); uintX a = (((uintX)alpha) << RenderSurface::format.a_shift)&RenderSurface::format.a_mask; @@ -219,7 +219,7 @@ template void SoftRenderSurface::FillAlpha(uint8 alpha, int3 pixel += sizeof(uintX); } - line_end += pitch; + line_end += _pitch; pixel += diff; } } @@ -232,20 +232,20 @@ template void SoftRenderSurface::FillBlended(uint32 rgba, in return; } - clip_window.IntersectOther(sx, sy, w, h); + _clipWindow.IntersectOther(sx, sy, w, h); if (!w || !h) return; // An optimization. - if ((int)(w * sizeof(uintX)) == pitch) { + if ((int)(w * sizeof(uintX)) == _pitch) { w *= h; h = 1; } - uint8 *pixel = pixels + sy * pitch + sx * sizeof(uintX); - uint8 *end = pixel + h * pitch; + uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uintX); + uint8 *end = pixel + h * _pitch; uint8 *line_end = pixel + w * sizeof(uintX); - int diff = pitch - w * sizeof(uintX); + int diff = _pitch - w * sizeof(uintX); int alpha = TEX32_A(rgba) + 1; rgba = TEX32_PACK_RGBA16(TEX32_R(rgba) * alpha, TEX32_G(rgba) * alpha, TEX32_B(rgba) * alpha, 255 * alpha); @@ -258,7 +258,7 @@ template void SoftRenderSurface::FillBlended(uint32 rgba, in pixel += sizeof(uintX); } - line_end += pitch; + line_end += _pitch; pixel += diff; } } @@ -348,17 +348,17 @@ template void SoftRenderSurface::Blit(Texture *tex, int32 sx // Clip to window int px = dx, py = dy; - clip_window.IntersectOther(dx, dy, w, h); + _clipWindow.IntersectOther(dx, dy, w, h); if (!w || !h) return; // Adjust source x and y if (px != dx) sx += dx - px; if (py != dy) sy += dy - py; - uint8 *pixel = pixels + dy * pitch + dx * sizeof(uintX); + uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX); uint8 *line_end = pixel + w * sizeof(uintX); - uint8 *end = pixel + h * pitch; - int diff = pitch - w * sizeof(uintX); + uint8 *end = pixel + h * _pitch; + int diff = _pitch - w * sizeof(uintX); if (tex->format == TEX_FMT_STANDARD) { uint32 *texel = tex->buffer + (sy * tex->width + sx); @@ -384,7 +384,7 @@ template void SoftRenderSurface::Blit(Texture *tex, int32 sx texel++; } - line_end += pitch; + line_end += _pitch; pixel += diff; texel += tex_diff; } @@ -403,7 +403,7 @@ template void SoftRenderSurface::Blit(Texture *tex, int32 sx texel++; } - line_end += pitch; + line_end += _pitch; pixel += diff; texel += tex_diff; } @@ -430,17 +430,17 @@ template void SoftRenderSurface::Blit(Texture *tex, int32 sx // Clip to window int px = dx, py = dy; - clip_window.IntersectOther(dx,dy,w,h); + _clipWindow.IntersectOther(dx,dy,w,h); if (!w || !h) return; // Adjust source x and y if (px != dx) sx += dx - px; if (py != dy) sy += dy - py; - uint8 *pixel = pixels + dy * pitch + dx * sizeof(uintX); + uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX); uint8 *line_end = pixel + w*sizeof(uintX); - uint8 *end = pixel + h * pitch; - int diff = pitch - w*sizeof(uintX); + uint8 *end = pixel + h * _pitch; + int diff = _pitch - w*sizeof(uintX); uint32 *texel = tex->buffer + (sy * tex->width + sx); #ifdef BLIT_WRAP @@ -468,7 +468,7 @@ template void SoftRenderSurface::Blit(Texture *tex, int32 sx #endif } - line_end += pitch; + line_end += _pitch; pixel += diff; texel+= tex_diff; #ifdef BLIT_WRAP @@ -498,17 +498,17 @@ template void SoftRenderSurface::FadedBlit(Texture *tex, int // Clip to window int px = dx, py = dy; - clip_window.IntersectOther(dx, dy, w, h); + _clipWindow.IntersectOther(dx, dy, w, h); if (!w || !h) return; // Adjust source x and y if (px != dx) sx += dx - px; if (py != dy) sy += dy - py; - uint8 *pixel = pixels + dy * pitch + dx * sizeof(uintX); + uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX); uint8 *line_end = pixel + w * sizeof(uintX); - uint8 *end = pixel + h * pitch; - int diff = pitch - w * sizeof(uintX); + uint8 *end = pixel + h * _pitch; + int diff = _pitch - w * sizeof(uintX); uint32 a = TEX32_A(col32); uint32 ia = 256 - a; @@ -564,7 +564,7 @@ template void SoftRenderSurface::FadedBlit(Texture *tex, int texel++; } - line_end += pitch; + line_end += _pitch; pixel += diff; texel += tex_diff; } @@ -583,7 +583,7 @@ template void SoftRenderSurface::FadedBlit(Texture *tex, int texel++; } - line_end += pitch; + line_end += _pitch; pixel += diff; texel += tex_diff; } @@ -608,17 +608,17 @@ template void SoftRenderSurface::MaskedBlit(Texture *tex, in // Clip to window int px = dx, py = dy; - clip_window.IntersectOther(dx, dy, w, h); + _clipWindow.IntersectOther(dx, dy, w, h); if (!w || !h) return; // Adjust source x and y if (px != dx) sx += dx - px; if (py != dy) sy += dy - py; - uint8 *pixel = pixels + dy * pitch + dx * sizeof(uintX); + uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX); uint8 *line_end = pixel + w * sizeof(uintX); - uint8 *end = pixel + h * pitch; - int diff = pitch - w * sizeof(uintX); + uint8 *end = pixel + h * _pitch; + int diff = _pitch - w * sizeof(uintX); uint32 a = TEX32_A(col32); uint32 ia = 256 - a; @@ -678,7 +678,7 @@ template void SoftRenderSurface::MaskedBlit(Texture *tex, in texel++; } - line_end += pitch; + line_end += _pitch; pixel += diff; texel += tex_diff; } @@ -699,7 +699,7 @@ template void SoftRenderSurface::MaskedBlit(Texture *tex, in texel++; } - line_end += pitch; + line_end += _pitch; pixel += diff; texel += tex_diff; } @@ -727,8 +727,8 @@ template void SoftRenderSurface::StretchBlit(Texture *textur return; } - uint8 *pixel = pixels + dy * pitch + dx * sizeof(uintX); - Ultima8Engine::get_instance()->point_scaler.Scale(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clampedges); + uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX); + Ultima8Engine::get_instance()->point_scaler.Scale(texture, sx, sy, sw, sh, pixel, dw, dh, _pitch, clampedges); } // @@ -747,9 +747,9 @@ template bool SoftRenderSurface::ScalerBlit(Texture *texture return true; } - uint8 *pixel = pixels + dy * pitch + dx * sizeof(uintX); + uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX); - return scaler->Scale(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clampedges); + return scaler->Scale(texture, sx, sy, sw, sh, pixel, dw, dh, _pitch, clampedges); } // diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl index c53a4bb52b3..60cc24e4051 100644 --- a/engines/ultima/ultima8/graphics/soft_render_surface.inl +++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl @@ -102,7 +102,7 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; #define LINE_END_ASSIGN() #define NOT_CLIPPED_X (1) #define NOT_CLIPPED_Y (1) -#define OFFSET_PIXELS (pixels) +#define OFFSET_PIXELS (_pixels) // // No Clipping = FALSE @@ -113,15 +113,15 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; #define NOT_CLIPPED_Y (line >= 0 && line < scrn_height) #define NOT_CLIPPED_X (pixptr >= line_start && pixptr < line_end) - int scrn_width = clip_window.w; - int scrn_height = clip_window.h; + int scrn_width = _clipWindow.w; + int scrn_height = _clipWindow.h; uintX *line_end; #define OFFSET_PIXELS (off_pixels) - uint8 *off_pixels = static_cast(pixels) + static_cast(clip_window.x)*sizeof(uintX) + static_cast(clip_window.y)*pitch; - x -= clip_window.x; - y -= clip_window.y; + uint8 *off_pixels = static_cast(_pixels) + static_cast(_clipWindow.x)*sizeof(uintX) + static_cast(_clipWindow.y)*_pitch; + x -= _clipWindow.x; + y -= _clipWindow.y; #endif @@ -201,21 +201,18 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; y -= frame->_yoff; // Do it this way if compressed - if (frame->_compressed) for (int i=0; i_compressed) for (int i=0; i(static_cast(OFFSET_PIXELS) + pitch*line); + line_start = reinterpret_cast(static_cast(OFFSET_PIXELS) + _pitch*line); LINE_END_ASSIGN(); - do - { + do { xpos += *linedata++; if (xpos == width_) break; @@ -227,18 +224,13 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; pixptr= line_start+x+XNEG(xpos); endrun = pixptr + XNEG(dlen); - if (!type) - { - while (pixptr != endrun) - { - if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) - { + if (!type) { + while (pixptr != endrun) { + if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) { #ifdef XFORM_SHAPES - if (USE_XFORM_FUNC) - { + if (USE_XFORM_FUNC) { *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr)); - } - else + } else #endif { *pixptr = CUSTOM_BLEND(pal[*linedata]); @@ -247,20 +239,15 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; pixptr += XNEG(1); linedata++; } - } - else - { + } else { #ifdef XFORM_SHAPES pix = xform_pal[*linedata]; - if (USE_XFORM_FUNC) - { - while (pixptr != endrun) - { + if (USE_XFORM_FUNC) { + while (pixptr != endrun) { if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr)); pixptr += XNEG(1); } - } - else + } else #endif { pix = pal[*linedata]; @@ -282,19 +269,16 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; } } // Uncompressed - else for (int i=0; i(static_cast(OFFSET_PIXELS) + pitch*line); + if (NOT_CLIPPED_Y) { + line_start = reinterpret_cast(static_cast(OFFSET_PIXELS) + _pitch*line); LINE_END_ASSIGN(); - do - { + do { xpos += *linedata++; if (xpos == width_) break; @@ -304,13 +288,10 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0; pixptr= line_start+x+XNEG(xpos); endrun = pixptr + XNEG(dlen); - while (pixptr != endrun) - { - if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) - { + while (pixptr != endrun) { + if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) { #ifdef XFORM_SHAPES - if (USE_XFORM_FUNC) - { + if (USE_XFORM_FUNC) { *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr)); } else