[Scummvm-git-logs] scummvm master -> d60907de3e6c23b70e93db70726b9becf0d37bb9
dreammaster
paulfgilbert at gmail.com
Sun Mar 1 00:25:41 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d60907de3e ULTIMA8: Change Texture to based on a Graphics::ManagedSurface
Commit: d60907de3e6c23b70e93db70726b9becf0d37bb9
https://github.com/scummvm/scummvm/commit/d60907de3e6c23b70e93db70726b9becf0d37bb9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-29T16:25:16-08:00
Commit Message:
ULTIMA8: Change Texture to based on a Graphics::ManagedSurface
This resolves confusion with Texture originally using a uint32 * buffer,
but then force casting to an uint16 * when in 16bpp pixel mode and
TEX_FMT_NATIVE is being used. Now using a surface, it's more able to
manage it's own buffer, and there'll be less confusion about how the
data is contained
Changed paths:
engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
engines/ultima/ultima8/graphics/fonts/tt_font.cpp
engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
engines/ultima/ultima8/graphics/point_scaler.cpp
engines/ultima/ultima8/graphics/render_surface.cpp
engines/ultima/ultima8/graphics/render_surface.h
engines/ultima/ultima8/graphics/soft_render_surface.cpp
engines/ultima/ultima8/graphics/texture.cpp
engines/ultima/ultima8/graphics/texture.h
engines/ultima/ultima8/gumps/minimap_gump.cpp
engines/ultima/ultima8/gumps/minimap_gump.h
engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
engines/ultima/ultima8/gumps/pentagram_menu_gump.h
engines/ultima/ultima8/gumps/scaler_gump.h
engines/ultima/ultima8/kernel/mouse.cpp
engines/ultima/ultima8/ultima8.h
diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
index 11da0e63b4..6f5f2465ed 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
@@ -216,9 +216,9 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h) :
_pixels00 = new uint8[_pitch * _height];
_rttTex = new Texture;
- _rttTex->_buffer = reinterpret_cast<uint32 *>(_pixels00);
- _rttTex->_width = _width;
- _rttTex->_height = _height;
+ _rttTex->setPixels(_pixels00);
+ _rttTex->w = _width;
+ _rttTex->h = _height;
_rttTex->_format = TEX_FMT_NATIVE;
_rttTex->CalcLOG2s();
diff --git a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp b/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
index b97d882650..dfe885bfb7 100644
--- a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
@@ -61,11 +61,11 @@ FixedWidthFont *FixedWidthFont::Create(const Std::string &iniroot) {
fwf->_tex = fonttex;
if (!config->get(iniroot + "/font/width", fwf->_width)) {
- fwf->_width = fwf->_tex->_width / 16;
+ fwf->_width = fwf->_tex->w / 16;
}
if (!config->get(iniroot + "/font/height", fwf->_height)) {
- fwf->_height = fwf->_tex->_height / 16;
+ fwf->_height = fwf->_tex->h / 16;
}
if (!config->get(iniroot + "/font/align_x", fwf->_alignX)) {
diff --git a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h b/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
index a19addc218..fe80e64c81 100644
--- a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
+++ b/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
@@ -28,7 +28,7 @@
namespace Ultima {
namespace Ultima8 {
-struct Texture;
+class Texture;
class IDataSource;
struct FixedWidthFont {
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
index 9eadd246bb..6b0bdd07cb 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
@@ -141,14 +141,9 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
resultWidth, resultHeight, cursor);
lineHeight = _ttfFont->getFontHeight();
- // create 32bit RGBA texture buffer
- uint32 *buf = new uint32[resultWidth * resultHeight];
- memset(buf, 0, 4 * resultWidth * resultHeight);
-
Texture *texture = new Texture();
- texture->_buffer = buf;
- texture->_width = resultWidth;
- texture->_height = resultHeight;
+ texture->create(resultWidth, resultHeight, TEX_FMT_STANDARD);
+ uint32 *texBuf = (uint32 *)texture->getPixels();
Std::list<PositionedText>::const_iterator iter;
for (iter = lines.begin(); iter != lines.end(); ++iter) {
@@ -178,7 +173,7 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
byte *surfrow = (byte *)textSurf.getBasePtr(0, y);
// CHECKME: _borderSize!
- uint32 *bufrow = buf + (iter->_dims.y + y + _borderSize) * resultWidth;
+ uint32 *bufrow = texBuf + (iter->_dims.y + y + _borderSize) * resultWidth;
for (int x = 0; x < textSurf.w; x++) {
if (!_antiAliased && surfrow[x] == 1) {
@@ -191,8 +186,8 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
if (x + 1 + iter->_dims.x + dx >= 0 &&
x + 1 + iter->_dims.x + dx < resultWidth &&
y + 1 + dy >= 0 && y + 1 + dy < resultHeight) {
- if (buf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] == 0) {
- buf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] = 0xFF000000;
+ if (texBuf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] == 0) {
+ texBuf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] = 0xFF000000;
}
}
}
@@ -204,8 +199,8 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
if (x + _borderSize + iter->_dims.x + dx >= 0 &&
x + _borderSize + iter->_dims.x + dx < resultWidth &&
y + _borderSize + dy >= 0 && y + _borderSize + dy < resultHeight) {
- if (buf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] == 0) {
- buf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] = 0xFF000000;
+ if (texBuf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] == 0) {
+ texBuf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] = 0xFF000000;
}
}
}
@@ -230,10 +225,10 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
if (x + 1 + iter->_dims.x + dx >= 0 &&
x + 1 + iter->_dims.x + dx < resultWidth &&
y + 1 + dy >= 0 && y + 1 + dy < resultHeight) {
- uint32 alpha = TEX32_A(buf[(y + iter->_dims.y + dy + 1) * resultWidth + x + 1 + iter->_dims.x + dx]);
+ uint32 alpha = TEX32_A(texBuf[(y + iter->_dims.y + dy + 1) * resultWidth + x + 1 + iter->_dims.x + dx]);
if (alpha != 0xFF) {
alpha = 255 - (((255 - alpha) * (255 - idx)) >> 8);
- buf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] = alpha << TEX32_A_SHIFT;
+ texBuf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] = alpha << TEX32_A_SHIFT;
}
}
}
@@ -243,10 +238,10 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
if (x + _borderSize + iter->_dims.x + dx >= 0 &&
x + _borderSize + iter->_dims.x + dx < resultWidth &&
y + _borderSize + dy >= 0 && y + _borderSize + dy < resultHeight) {
- uint32 alpha = TEX32_A(buf[(y + iter->_dims.y + dy + _borderSize) * resultWidth + x + _borderSize + iter->_dims.x + dx]);
+ uint32 alpha = TEX32_A(texBuf[(y + iter->_dims.y + dy + _borderSize) * resultWidth + x + _borderSize + iter->_dims.x + dx]);
if (alpha != 0xFF) {
alpha = 255 - (((255 - alpha) * (255 - idx)) >> 8);
- buf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] = alpha << TEX32_A_SHIFT;
+ texBuf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] = alpha << TEX32_A_SHIFT;
}
}
}
@@ -264,7 +259,7 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
int w = _ttfFont->getStringWidth(unicodeText);
for (int y = 0; y < iter->_dims.h; y++) {
- uint32 *bufrow = buf + (iter->_dims.y + y) * resultWidth;
+ uint32 *bufrow = texBuf + (iter->_dims.y + y) * resultWidth;
bufrow[iter->_dims.x + w + _borderSize] = 0xFF000000;
// if (_borderSize > 0)
// bufrow[iter->_dims.x+w+_borderSize-1] = 0xFF000000;
diff --git a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
index 2fa71404c3..56ebfd1b22 100644
--- a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
+++ b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
@@ -31,7 +31,7 @@ namespace Ultima {
namespace Ultima8 {
class TTFont;
-struct Texture;
+class Texture;
class TTFRenderedText : public RenderedText {
public:
diff --git a/engines/ultima/ultima8/graphics/point_scaler.cpp b/engines/ultima/ultima8/graphics/point_scaler.cpp
index 8b5c7d343b..659f1625b5 100644
--- a/engines/ultima/ultima8/graphics/point_scaler.cpp
+++ b/engines/ultima/ultima8/graphics/point_scaler.cpp
@@ -33,11 +33,11 @@ public:
static bool Scale(Texture *tex , int32 sx, int32 sy, int32 sw, int32 sh,
uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src) {
// Source buffer pointers
- uintS *texel = reinterpret_cast<uintS *>(tex->_buffer) + (sy * tex->_width + sx);
- int tpitch = tex->_width;
+ uintS *texel = reinterpret_cast<uintS *>(tex->getPixels()) + (sy * tex->w + sx);
+ int tpitch = tex->w;
uintS *tline_end = texel + sw;
- uintS *tex_end = texel + sh * tex->_width;
- int tex_diff = tex->_width - sw;
+ uintS *tex_end = texel + sh * tex->w;
+ int tex_diff = tex->w - sw;
// First detect integer up scalings, since they are 'easy'
diff --git a/engines/ultima/ultima8/graphics/render_surface.cpp b/engines/ultima/ultima8/graphics/render_surface.cpp
index a45159df09..ebabeb8096 100644
--- a/engines/ultima/ultima8/graphics/render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/render_surface.cpp
@@ -23,6 +23,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/graphics/render_surface.h"
#include "ultima/ultima8/graphics/soft_render_surface.h"
+#include "common/system.h"
#include "engines/util.h"
#include "graphics/screen.h"
@@ -94,5 +95,9 @@ RenderSurface *RenderSurface::CreateSecondaryRenderSurface(uint32 width, uint32
RenderSurface::~RenderSurface() {
}
+Graphics::PixelFormat RenderSurface::getPixelFormat() {
+ return g_system->getScreenFormat();
+}
+
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/render_surface.h b/engines/ultima/ultima8/graphics/render_surface.h
index 8c41234da0..5d1a8cb74f 100644
--- a/engines/ultima/ultima8/graphics/render_surface.h
+++ b/engines/ultima/ultima8/graphics/render_surface.h
@@ -30,7 +30,7 @@
namespace Ultima {
namespace Ultima8 {
-struct Texture;
+class Texture;
class Shape;
class ShapeFont;
struct FixedWidthFont;
@@ -78,6 +78,7 @@ public:
// Virtual Destructor
virtual ~RenderSurface();
+ static Graphics::PixelFormat getPixelFormat();
//
// Being/End Painting
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index c30b15fcc8..f1f497e6e8 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -336,11 +336,11 @@ template<class uintX> void SoftRenderSurface<uintX>::DrawLine32(uint32 rgb, int3
//
template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend) {
// Clamp or wrap or return?
- if (sx + w > static_cast<int32>(_tex->_width))
+ if (sx + w > static_cast<int32>(_tex->w))
return;
// Clamp or wrap or return?
- if (sy + h > static_cast<int32>(_tex->_height))
+ if (sy + h > static_cast<int32>(_tex->h))
return;
if (sx < 0 || sy < 0)
@@ -361,8 +361,8 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
int diff = _pitch - w * sizeof(uintX);
if (_tex->_format == TEX_FMT_STANDARD) {
- uint32 *texel = _tex->_buffer + (sy * _tex->_width + sx);
- int tex_diff = _tex->_width - w;
+ uint32 *texel = (uint32 *)_tex->getBasePtr(sx, sy);
+ int tex_diff = _tex->w - w;
while (pixel != end) {
if (!alpha_blend) while (pixel != line_end) {
@@ -389,8 +389,8 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
texel += tex_diff;
}
} else if (_tex->_format == TEX_FMT_NATIVE) {
- uintX *texel = reinterpret_cast<uintX *>(_tex->_buffer) + (sy * _tex->_width + sx);
- int tex_diff = _tex->_width - w;
+ uintX *texel = reinterpret_cast<uintX *>(_tex->getBasePtr(sx, sy));
+ int tex_diff = _tex->w - w;
while (pixel != end) {
while (pixel != line_end) {
@@ -412,11 +412,11 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
/* Old complete code
// Clamp or wrap or return?
#ifndef BLIT_WRAP
- if (w > static_cast<int32>(_tex->_width))
+ if (w > static_cast<int32>(_tex->w))
#ifndef BLIT_CLIP
return;
#else
- w = _tex->_width;
+ w = _tex->w;
#endif
// Clamp or wrap or return?
@@ -442,14 +442,14 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
uint8 *end = pixel + h * _pitch;
int diff = _pitch - w*sizeof(uintX);
- uint32 *texel = _tex->_buffer + (sy * _tex->_width + sx);
+ uint32 *texel = _tex->_buffer + (sy * _tex->w + sx);
#ifdef BLIT_WRAP
- uint32 *texel_line_start = _tex->_buffer + sy * _tex->_width;
- uint32 *texel_line_end = _tex->_buffer + (sy+1) * _tex->_width;
+ uint32 *texel_line_start = _tex->_buffer + sy * _tex->w;
+ uint32 *texel_line_end = _tex->_buffer + (sy+1) * _tex->w;
uint32 *texel_col_start = _tex->_buffer + sx;
- uint32 *texel_col_end = _tex->_buffer + (_tex->_height * _tex->_width + sx);
+ uint32 *texel_col_end = _tex->_buffer + (_tex->_height * _tex->w + sx);
#endif
- int tex_diff = _tex->_width - w;
+ int tex_diff = _tex->w - w;
//b = PACK_RGB8( (rgb>>16)&0xFF , (rgb>>8)&0xFF , rgb&0xFF );
@@ -489,11 +489,11 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
//
template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
// Clamp or wrap or return?
- if (w > static_cast<int32>(_tex->_width))
+ if (w > static_cast<int32>(_tex->w))
return;
// Clamp or wrap or return?
- if (h > static_cast<int32>(_tex->_height))
+ if (h > static_cast<int32>(_tex->h))
return;
// Clip to window
@@ -517,8 +517,8 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, in
uint32 b = (TEX32_B(col32) * a);
if (_tex->_format == TEX_FMT_STANDARD) {
- uint32 *texel = _tex->_buffer + (sy * _tex->_width + sx);
- int tex_diff = _tex->_width - w;
+ uint32 *texel = (uint32 *)_tex->getBasePtr(sx, sy);
+ int tex_diff = _tex->w - w;
while (pixel != end) {
if (!alpha_blend) while (pixel != line_end) {
@@ -569,8 +569,8 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, in
texel += tex_diff;
}
} else if (_tex->_format == TEX_FMT_NATIVE) {
- uintX *texel = reinterpret_cast<uintX *>(_tex->_buffer) + (sy * _tex->_width + sx);
- int tex_diff = _tex->_width - w;
+ uintX *texel = reinterpret_cast<uintX *>(_tex->getBasePtr(sx, sy));
+ int tex_diff = _tex->w - w;
while (pixel != end) {
while (pixel != line_end) {
@@ -599,17 +599,18 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, in
//
template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
// Clamp or wrap or return?
- if (w > static_cast<int32>(_tex->_width))
+ if (w > static_cast<int32>(_tex->w))
return;
// Clamp or wrap or return?
- if (h > static_cast<int32>(_tex->_height))
+ if (h > static_cast<int32>(_tex->h))
return;
// Clip to window
int px = dx, py = dy;
_clipWindow.IntersectOther(dx, dy, w, h);
- if (!w || !h) return;
+ if (!w || !h)
+ return;
// Adjust source x and y
if (px != dx) sx += dx - px;
@@ -627,8 +628,8 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
uint32 b = (TEX32_B(col32) * a);
if (_tex->_format == TEX_FMT_STANDARD) {
- uint32 *texel = _tex->_buffer + (sy * _tex->_width + sx);
- int tex_diff = _tex->_width - w;
+ uint32 *texel = (uint32 *)_tex->getBasePtr(sx, sy);
+ int tex_diff = _tex->w - w;
while (pixel != end) {
if (!alpha_blend) {
@@ -688,8 +689,8 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
texel += tex_diff;
}
} else if (_tex->_format == TEX_FMT_NATIVE) {
- uintX *texel = reinterpret_cast<uintX *>(_tex->_buffer) + (sy * _tex->_width + sx);
- int tex_diff = _tex->_width - w;
+ uintX *texel = reinterpret_cast<uintX *>(_tex->getBasePtr(sx, sy));
+ int tex_diff = _tex->w - w;
while (pixel != end) {
while (pixel != line_end) {
diff --git a/engines/ultima/ultima8/graphics/texture.cpp b/engines/ultima/ultima8/graphics/texture.cpp
index e8a2ff97e3..736449c283 100644
--- a/engines/ultima/ultima8/graphics/texture.cpp
+++ b/engines/ultima/ultima8/graphics/texture.cpp
@@ -25,29 +25,17 @@
#include "ultima/ultima8/graphics/texture_bitmap.h"
#include "ultima/ultima8/graphics/texture_targa.h"
#include "ultima/ultima8/graphics/texture_png.h"
+#include "ultima/ultima8/graphics/render_surface.h"
#include <cstring>
namespace Ultima {
namespace Ultima8 {
-//
-// Base Clear Func
-//
-bool Texture::Clear() {
- // Temporary fix to prevent us from freeing a RenderSurface's memory
- if (_format != TEX_FMT_NATIVE)
- delete [] _buffer;
- _buffer = 0;
-
- return true;
-}
-
//
// Destructor
//
Texture::~Texture() {
- Clear();
}
//
@@ -65,6 +53,12 @@ Texture::~Texture() {
return tex; \
}
+void Texture::create(uint16 width, uint16 height, TextureFormat textureFormat) {
+ _format = textureFormat;
+ create(width, height, (_format == TEX_FMT_NATIVE) ? RenderSurface::getPixelFormat() :
+ Texture::getPixelFormat());
+}
+
//
// Create a texture from a Data Source
// (filename is used to help detection of type)
@@ -98,15 +92,13 @@ Texture *Texture::Create(IDataSource *ds, const char *filename) {
void Texture::loadSurface(const Graphics::Surface *surf) {
assert(surf->format.bytesPerPixel == 2 || surf->format.bytesPerPixel == 4);
- this->_width = surf->w;
- this->_height = surf->h;
+ create(surf->w, surf->h, Texture::getPixelFormat());
this->_format = TEX_FMT_STANDARD;
this->_wlog2 = -1;
this->_hlog2 = -1;
- _buffer = new uint32[_width * _height];
-
// Repack RGBA
+ uint32 *buffer = (uint32 *)getPixels();
uint32 pixel, i = 0;
byte r, g, b, a;
for (int y = 0; y < surf->h; ++y) {
@@ -116,7 +108,7 @@ void Texture::loadSurface(const Graphics::Surface *surf) {
pixel = (surf->format.bytesPerPixel == 2) ? *((const uint16 *)srcP) : *((const uint32 *)srcP);
surf->format.colorToARGB(pixel, a, r, g, b);
- _buffer[i++] = (r << TEX32_R_SHIFT)
+ buffer[i++] = (r << TEX32_R_SHIFT)
| (g << TEX32_G_SHIFT)
| (b << TEX32_B_SHIFT)
| (a << TEX32_A_SHIFT);
diff --git a/engines/ultima/ultima8/graphics/texture.h b/engines/ultima/ultima8/graphics/texture.h
index 4f7bc04f63..f8b3616cf0 100644
--- a/engines/ultima/ultima8/graphics/texture.h
+++ b/engines/ultima/ultima8/graphics/texture.h
@@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_TEXTURE_H
#define ULTIMA8_GRAPHICS_TEXTURE_H
-#include "graphics/surface.h"
+#include "graphics/managed_surface.h"
namespace Ultima {
namespace Ultima8 {
@@ -87,10 +87,8 @@ class IDataSource;
//
// Basic 32 Bit Texture
//
-struct Texture {
- uint32 *_buffer;
- int32 _width;
- int32 _height;
+class Texture : public Graphics::ManagedSurface {
+public:
uint32 _format;
// Use CalcLOG2s to calculate these (can be -1 which indicates not log2)
@@ -105,23 +103,28 @@ struct Texture {
return Graphics::PixelFormat(4, 8, 8, 8, 8, TEX32_R_SHIFT, TEX32_G_SHIFT, TEX32_B_SHIFT, TEX32_A_SHIFT);
}
- Texture() : _buffer(0), _format(TEX_FMT_STANDARD), _glTex(0), _next(0) {
+ Texture() : _format(TEX_FMT_STANDARD), _glTex(0), _next(0) {
}
virtual ~Texture();
- // Clear all texture data
- virtual bool Clear();
+ void create(uint16 width, uint16 height) override {
+ Graphics::ManagedSurface::create(width, height);
+ }
+ void create(uint16 width, uint16 height, const Graphics::PixelFormat &pixelFormat) override {
+ Graphics::ManagedSurface::create(width, height, pixelFormat);
+ }
+ void create(uint16 width, uint16 height, TextureFormat textureFormat);
// Calc texture log2's
void CalcLOG2s() {
_wlog2 = -1;
_hlog2 = -1;
for (int i = 0; i < 32; i++) {
- if (_width == (1 << i))
+ if (this->w == (1 << i))
_wlog2 = i;
- if (_height == (1 << i))
+ if (this->h == (1 << i))
_hlog2 = i;
}
}
diff --git a/engines/ultima/ultima8/gumps/minimap_gump.cpp b/engines/ultima/ultima8/gumps/minimap_gump.cpp
index 4d269af383..ef972c6704 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.cpp
+++ b/engines/ultima/ultima8/gumps/minimap_gump.cpp
@@ -42,8 +42,8 @@ MiniMapGump::MiniMapGump(int x, int y) :
Gump(x, y, MAP_NUM_CHUNKS * 2 + 2, MAP_NUM_CHUNKS * 2 + 2, 0,
FLAG_DRAGGABLE, LAYER_NORMAL), _minimap(), _lastMapNum(0) {
_minimap._format = TEX_FMT_NATIVE;
- _minimap._width = _minimap._height = MAP_NUM_CHUNKS * MINMAPGUMP_SCALE;
- _minimap._buffer = (uint32 *)_texBuffer;
+ _minimap.create((MAP_NUM_CHUNKS * MINMAPGUMP_SCALE), (MAP_NUM_CHUNKS * MINMAPGUMP_SCALE),
+ TEX_FMT_NATIVE);
}
MiniMapGump::MiniMapGump() : Gump() {
@@ -53,21 +53,21 @@ MiniMapGump::~MiniMapGump(void) {
}
void MiniMapGump::setPixelAt(int x, int y, uint32 pixel) {
- if (RenderSurface::_format.s_bytes_per_pixel == 2) {
- uint16 *buf = (uint16 *)_texBuffer + (y * _minimap._width) + x;
+ if (_minimap.format.bytesPerPixel == 2) {
+ uint16 *buf = (uint16 *)_minimap.getBasePtr(x, y);
*buf = pixel;
} else {
- uint32 *buf = (uint32 *)_texBuffer + (y * _minimap._width) + x;
+ uint32 *buf = (uint32 *)_minimap.getBasePtr(x, y);
*buf = pixel;
}
}
uint32 MiniMapGump::getPixelAt(int x, int y) {
- if (RenderSurface::_format.s_bytes_per_pixel == 2) {
- uint16 *buf = (uint16 *)_texBuffer + (y * _minimap._width) + x;
+ if (_minimap.format.bytesPerPixel == 2) {
+ uint16 *buf = (uint16 *)_minimap.getBasePtr(x, y);
return *buf;
} else {
- uint32 *buf = (uint32 *)_texBuffer + (y * _minimap._width) + x;
+ uint32 *buf = (uint32 *)_minimap.getBasePtr(x, y);
return *buf;
}
}
@@ -78,7 +78,7 @@ void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
int mapChunkSize = currentmap->getChunkSize();
if (currentmap->getNum() != _lastMapNum) {
- Std::memset(_texBuffer, 0, sizeof(_texBuffer));
+ _minimap.fillRect(Common::Rect(0, 0, _minimap.w, _minimap.h), 0);
_lastMapNum = currentmap->getNum();
}
@@ -204,9 +204,7 @@ bool MiniMapGump::loadData(IDataSource *ids, uint32 version) {
return false;
_lastMapNum = 0;
- _minimap._format = TEX_FMT_NATIVE;
- _minimap._width = _minimap._height = MAP_NUM_CHUNKS * MINMAPGUMP_SCALE;
- _minimap._buffer = (uint32 *)_texBuffer[0];
+ _minimap.create(MAP_NUM_CHUNKS * MINMAPGUMP_SCALE, MAP_NUM_CHUNKS * MINMAPGUMP_SCALE, TEX_FMT_NATIVE);
return true;
}
diff --git a/engines/ultima/ultima8/gumps/minimap_gump.h b/engines/ultima/ultima8/gumps/minimap_gump.h
index 08a3e1826f..713a4044d7 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.h
+++ b/engines/ultima/ultima8/gumps/minimap_gump.h
@@ -37,7 +37,6 @@ class MiniMapGump : public Gump {
private:
Texture _minimap;
unsigned int _lastMapNum;
- byte _texBuffer[(MAP_NUM_CHUNKS * MINMAPGUMP_SCALE) * (MAP_NUM_CHUNKS * MINMAPGUMP_SCALE) * 4];
uint32 getPixelAt(int x, int y);
void setPixelAt(int x, int y, uint32 pixel);
diff --git a/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp b/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
index ad6ae56616..62713ee234 100644
--- a/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
+++ b/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
@@ -112,10 +112,10 @@ void PentagramMenuGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool /
#endif
// surf->Fill32(0xFFDCB95C, 18, 0, 90, 400);
- surf->Blit(_navbarImage, 0, 0, _navbarImage->_width, _navbarImage->_height, 9, 0);
+ surf->Blit(_navbarImage, 0, 0, _navbarImage->w, _navbarImage->h, 9, 0);
// surf->Fill32(0xFFC11515, 200, 6, 340, 36);
- surf->Blit(_titleImage, 0, 0, _titleImage->_width, _titleImage->_height, 200, 6);
+ surf->Blit(_titleImage, 0, 0, _titleImage->w, _titleImage->h, 200, 6);
}
void PentagramMenuGump::PaintChildren(RenderSurface *surf, int32 lerp_factor, bool scaled) {
diff --git a/engines/ultima/ultima8/gumps/pentagram_menu_gump.h b/engines/ultima/ultima8/gumps/pentagram_menu_gump.h
index dd10d87fc7..d246e739e0 100644
--- a/engines/ultima/ultima8/gumps/pentagram_menu_gump.h
+++ b/engines/ultima/ultima8/gumps/pentagram_menu_gump.h
@@ -31,7 +31,7 @@
namespace Ultima {
namespace Ultima8 {
-struct Texture;
+class Texture;
class PentagramMenuGump : public ModalGump {
class PentagramMenuCallbackProcess : public Process {
diff --git a/engines/ultima/ultima8/gumps/scaler_gump.h b/engines/ultima/ultima8/gumps/scaler_gump.h
index 36455971c8..709b4fecde 100644
--- a/engines/ultima/ultima8/gumps/scaler_gump.h
+++ b/engines/ultima/ultima8/gumps/scaler_gump.h
@@ -31,7 +31,7 @@ namespace Ultima {
namespace Ultima8 {
class RenderSurface;
-struct Texture;
+class Texture;
class Scaler;
class ScalerGump : public DesktopGump {
diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index ba41b38f5d..6652f2d8cb 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -537,11 +537,11 @@ void Mouse::paint() {
if (frame >= 0) {
screen->Paint(mouse, frame, _mousePos.x, _mousePos.y, true);
} else if (frame == -2)
- screen->Blit(_defaultMouse, 0, 0, _defaultMouse->_width, _defaultMouse->_height, _mousePos.x, _mousePos.y);
+ screen->Blit(_defaultMouse, 0, 0, _defaultMouse->w, _defaultMouse->h, _mousePos.x, _mousePos.y);
}
} else {
if (getMouseFrame() != -1)
- screen->Blit(_defaultMouse, 0, 0, _defaultMouse->_width, _defaultMouse->_height, _mousePos.x, _mousePos.y);
+ screen->Blit(_defaultMouse, 0, 0, _defaultMouse->w, _defaultMouse->h, _mousePos.x, _mousePos.y);
}
}
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index f0022de490..4b72c203fa 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -72,7 +72,7 @@ class Mouse;
class AvatarMoverProcess;
class IDataSource;
class ODataSource;
-struct Texture;
+class Texture;
class AudioMixer;
class Ultima8Engine : public Shared::UltimaEngine, public CoreApp {
More information about the Scummvm-git-logs
mailing list