From 71c649f8d9296f51c88fbc54eca34b9dfb4d9cd1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Mar 2016 19:57:42 +0100 Subject: GRAPHICS: Mark actual dirty area as dirty in Font::drawString. --- graphics/font.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'graphics') diff --git a/graphics/font.cpp b/graphics/font.cpp index d709758948..4214b3f41b 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -276,12 +276,16 @@ void Font::drawString(Surface *dst, const Common::U32String &str, int x, int y, void Font::drawString(ManagedSurface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align, int deltax, bool useEllipsis) const { drawString(&dst->_innerSurface, str, x, y, w, color, align, deltax, useEllipsis); - dst->addDirtyRect(Common::Rect(x, y, x + w, y + getFontHeight())); + if (w != 0) { + dst->addDirtyRect(getBoundingBox(str, x, y, w, align)); + } } void Font::drawString(ManagedSurface *dst, const Common::U32String &str, int x, int y, int w, uint32 color, TextAlign align) const { drawString(&dst->_innerSurface, str, x, y, w, color, align); - dst->addDirtyRect(Common::Rect(x, y, x + w, y + getFontHeight())); + if (w != 0) { + dst->addDirtyRect(getBoundingBox(str, x, y, w, align)); + } } int Font::wordWrapText(const Common::String &str, int maxWidth, Common::Array &lines) const { -- cgit v1.2.3 From 2e5ef7484899df83a403d4b4041f920d932a71c1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Mar 2016 20:01:52 +0100 Subject: GRAPHICS: Use correct bounding rect in Font::drawString taking Common::String. --- graphics/font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/font.cpp b/graphics/font.cpp index 4214b3f41b..abc9519fd9 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -277,7 +277,7 @@ void Font::drawString(Surface *dst, const Common::U32String &str, int x, int y, void Font::drawString(ManagedSurface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align, int deltax, bool useEllipsis) const { drawString(&dst->_innerSurface, str, x, y, w, color, align, deltax, useEllipsis); if (w != 0) { - dst->addDirtyRect(getBoundingBox(str, x, y, w, align)); + dst->addDirtyRect(getBoundingBox(str, x, y, w, align, deltax, useEllipsis)); } } -- cgit v1.2.3 From 14ba851d32bae17d1cdc7ef9dd05c645611c005d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 Mar 2016 16:37:19 -0400 Subject: GRAPHICS: Fix MangaedSurface pixel casting errors --- graphics/managed_surface.cpp | 8 ++++---- graphics/managed_surface.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'graphics') diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp index e493ab9f4e..9dcea12836 100644 --- a/graphics/managed_surface.cpp +++ b/graphics/managed_surface.cpp @@ -33,7 +33,7 @@ ManagedSurface::ManagedSurface() : _disposeAfterUse(DisposeAfterUse::NO), _owner(nullptr) { } -ManagedSurface::ManagedSurface(const ManagedSurface &surf) : +ManagedSurface::ManagedSurface(ManagedSurface &surf) : w(_innerSurface.w), h(_innerSurface.h), pitch(_innerSurface.pitch), format(_innerSurface.format), _disposeAfterUse(DisposeAfterUse::NO), _owner(nullptr) { *this = surf; @@ -61,7 +61,7 @@ ManagedSurface::~ManagedSurface() { free(); } -ManagedSurface &ManagedSurface::operator=(const ManagedSurface &surf) { +ManagedSurface &ManagedSurface::operator=(ManagedSurface &surf) { // Free any current surface free(); @@ -74,7 +74,7 @@ ManagedSurface &ManagedSurface::operator=(const ManagedSurface &surf) { // Source isn't managed, so simply copy its fields _owner = surf._owner; _offsetFromOwner = surf._offsetFromOwner; - void *srcPixels = (void *)surf._innerSurface.getPixels(); + void *srcPixels = surf._innerSurface.getPixels(); _innerSurface.setPixels(srcPixels); _innerSurface.w = surf.w; _innerSurface.h = surf.h; @@ -198,7 +198,7 @@ void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRe } template -void transBlit(const Surface &src, const Common::Rect &srcRect, const Surface *dest, const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor) { +void transBlit(const Surface &src, const Common::Rect &srcRect, Surface *dest, const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor) { int scaleX = SCALE_THRESHOLD * srcRect.width() / destRect.width(); int scaleY = SCALE_THRESHOLD * srcRect.height() / destRect.height(); diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h index bd0632a493..8cbd463266 100644 --- a/graphics/managed_surface.h +++ b/graphics/managed_surface.h @@ -89,7 +89,7 @@ public: * this surface will create it's own surface of the same size and copy * the contents from the source surface */ - ManagedSurface(const ManagedSurface &surf); + ManagedSurface(ManagedSurface &surf); /** * Create the managed surface @@ -124,7 +124,7 @@ public: * Reassign one managed surface to another one * Note that if the source has a managed surface, it will be duplicated */ - ManagedSurface &operator=(const ManagedSurface &surf); + ManagedSurface &operator=(ManagedSurface &surf); /** * Returns true if the surface has not yet been allocated -- cgit v1.2.3 From c382e179084d52656de7379822d89a5fe97ca988 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 Mar 2016 20:53:01 -0400 Subject: GRAPHICS: Fix create call in ManagedSurface constructor --- graphics/managed_surface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp index 9dcea12836..273b15de55 100644 --- a/graphics/managed_surface.cpp +++ b/graphics/managed_surface.cpp @@ -48,7 +48,7 @@ ManagedSurface::ManagedSurface(int width, int height) : ManagedSurface::ManagedSurface(int width, int height, const Graphics::PixelFormat &pixelFormat) : w(_innerSurface.w), h(_innerSurface.h), pitch(_innerSurface.pitch), format(_innerSurface.format), _disposeAfterUse(DisposeAfterUse::NO), _owner(nullptr) { - create(width, height, format); + create(width, height, pixelFormat); } ManagedSurface::ManagedSurface(ManagedSurface &surf, const Common::Rect &bounds) : -- cgit v1.2.3 From ce1be463c2dfea61e74a816d6590a1a4506483d2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Mar 2016 21:38:26 +0100 Subject: GRAPHICS: Implement convenience Font::drawChar taking ManagedSurface. --- graphics/font.cpp | 8 ++++++++ graphics/font.h | 1 + 2 files changed, 9 insertions(+) (limited to 'graphics') diff --git a/graphics/font.cpp b/graphics/font.cpp index abc9519fd9..97662dc15d 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -265,6 +265,14 @@ int Font::getStringWidth(const Common::U32String &str) const { return getStringWidthImpl(*this, str); } +void Font::drawChar(ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const { + drawChar(&dst->_innerSurface, chr, x, y, color); + + Common::Rect charBox = getBoundingBox(chr); + charBox.translate(x, y); + dst->addDirtyRect(charBox); +} + void Font::drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align, int deltax, bool useEllipsis) const { Common::String renderStr = useEllipsis ? handleEllipsis(str, w) : str; drawStringImpl(*this, dst, renderStr, x, y, w, color, align, deltax); diff --git a/graphics/font.h b/graphics/font.h index 62e71a8568..0478608708 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -142,6 +142,7 @@ public: * @param color The color of the character. */ virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const = 0; + void drawChar(ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const; // TODO: Add doxygen comments to this void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; -- cgit v1.2.3 From c299b8ce08630d3471336cb8a5715fcffab791f8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 21 Mar 2016 20:12:10 -0400 Subject: GRAPHICS: Set parameterless Screen constructor to use screen format --- graphics/screen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/screen.cpp b/graphics/screen.cpp index 4169c98035..ccf651f536 100644 --- a/graphics/screen.cpp +++ b/graphics/screen.cpp @@ -28,7 +28,7 @@ namespace Graphics { Screen::Screen(): ManagedSurface() { - create(g_system->getWidth(), g_system->getHeight()); + create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); } Screen::Screen(int width, int height): ManagedSurface() { -- cgit v1.2.3 From 9b69b86f2972c93395ce6ee88f5566a31a05ce0d Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sat, 26 Mar 2016 19:26:43 +0300 Subject: GRAPHICS: Prevent crash when drawing 0-height rounded corners Opening/closing the console when scroll bars were visible caused occasional crashes. Fixes #7089. --- graphics/VectorRendererSpec.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'graphics') diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 26f0ced625..258d935440 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -2256,6 +2256,9 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, template void VectorRendererAA:: drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { + w -= 2*Base::_strokeWidth; + h -= 2*Base::_strokeWidth; + // Do not draw empty space rounded squares. if (w <= 0 || h <= 0) { return; @@ -2272,8 +2275,6 @@ drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType colo r -= Base::_strokeWidth; x1 += Base::_strokeWidth; y1 += Base::_strokeWidth; - w -= 2*Base::_strokeWidth; - h -= 2*Base::_strokeWidth; rsq = r*r; PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r); -- cgit v1.2.3 From e9bfbbd470d2550f42b3f01100cb31bfc618f8d1 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 27 Mar 2016 14:47:23 +0200 Subject: GRAPHICS: Allow saving thumbnails of 32 bits screens Fixes saving in Myst ME when using the OpenGL output --- graphics/scaler/thumbnail_intern.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp index 65e327f9c2..78fb7828d7 100644 --- a/graphics/scaler/thumbnail_intern.cpp +++ b/graphics/scaler/thumbnail_intern.cpp @@ -171,7 +171,8 @@ static bool grabScreen565(Graphics::Surface *surf) { if (!screen) return false; - assert(screen->format.bytesPerPixel == 1 || screen->format.bytesPerPixel == 2); + assert(screen->format.bytesPerPixel == 1 || screen->format.bytesPerPixel == 2 + || screen->format.bytesPerPixel == 4); assert(screen->getPixels() != 0); Graphics::PixelFormat screenFormat = g_system->getScreenFormat(); @@ -197,6 +198,9 @@ static bool grabScreen565(Graphics::Surface *surf) { } else if (screenFormat.bytesPerPixel == 2) { uint16 col = READ_UINT16(screen->getBasePtr(x, y)); screenFormat.colorToRGB(col, r, g, b); + } else if (screenFormat.bytesPerPixel == 4) { + uint32 col = READ_UINT32(screen->getBasePtr(x, y)); + screenFormat.colorToRGB(col, r, g, b); } *((uint16 *)surf->getBasePtr(x, y)) = Graphics::RGBToColor >(r, g, b); -- cgit v1.2.3