aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2016-07-21 13:30:47 +0200
committerWillem Jan Palenstijn2016-07-21 13:30:47 +0200
commit6f001d831623a46f643379554d20e94463d8c2f1 (patch)
tree901caa296592814b48a98ac2e3d381331c5a7821 /graphics
parent75fdd1504de98c7c6937344877685bfef6514344 (diff)
parent5f301b24002fffb3e8e05061a92ae2e0ee3a92ec (diff)
downloadscummvm-rg350-6f001d831623a46f643379554d20e94463d8c2f1.tar.gz
scummvm-rg350-6f001d831623a46f643379554d20e94463d8c2f1.tar.bz2
scummvm-rg350-6f001d831623a46f643379554d20e94463d8c2f1.zip
Merge branch 'master' into titanic
Diffstat (limited to 'graphics')
-rw-r--r--graphics/VectorRendererSpec.cpp5
-rw-r--r--graphics/font.cpp16
-rw-r--r--graphics/font.h1
-rw-r--r--graphics/managed_surface.cpp8
-rw-r--r--graphics/managed_surface.h4
-rw-r--r--graphics/scaler/thumbnail_intern.cpp6
6 files changed, 29 insertions, 11 deletions
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<typename PixelType>
void VectorRendererAA<PixelType>::
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);
diff --git a/graphics/font.cpp b/graphics/font.cpp
index d709758948..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);
@@ -276,12 +284,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, deltax, useEllipsis));
+ }
}
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<Common::String> &lines) const {
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;
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index f3d8813f2e..273b15de55 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<typename T>
-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
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<Graphics::ColorMasks<565> >(r, g, b);