aboutsummaryrefslogtreecommitdiff
path: root/backends/networking
diff options
context:
space:
mode:
authorBastien Bouclet2016-09-13 20:29:09 +0200
committerBastien Bouclet2016-09-13 20:29:09 +0200
commit4d68b93abacf78dae480a52e242a0644896e5101 (patch)
tree9a507f6ef2a6a411166add54ed4458cb236770e6 /backends/networking
parent521ba2cb8ac6cbe4240ad4da7ad44d13449e3943 (diff)
downloadscummvm-rg350-4d68b93abacf78dae480a52e242a0644896e5101.tar.gz
scummvm-rg350-4d68b93abacf78dae480a52e242a0644896e5101.tar.bz2
scummvm-rg350-4d68b93abacf78dae480a52e242a0644896e5101.zip
CLOUD: Switch to the new OSD API
Diffstat (limited to 'backends/networking')
-rw-r--r--backends/networking/curl/cloudicon.cpp46
-rw-r--r--backends/networking/curl/cloudicon.h8
2 files changed, 18 insertions, 36 deletions
diff --git a/backends/networking/curl/cloudicon.cpp b/backends/networking/curl/cloudicon.cpp
index 3ae6fd225e..9aa08af9fb 100644
--- a/backends/networking/curl/cloudicon.cpp
+++ b/backends/networking/curl/cloudicon.cpp
@@ -39,7 +39,11 @@ CloudIcon::CloudIcon():
initIcons();
}
-CloudIcon::~CloudIcon() {}
+CloudIcon::~CloudIcon() {
+ _icon.free();
+ _disabledIcon.free();
+ _alphaIcon.free();
+}
bool CloudIcon::draw() {
bool stop = false;
@@ -48,7 +52,6 @@ bool CloudIcon::draw() {
if (CloudMan.isWorking() || _disabledFrames > 0) {
if (g_system) {
if (!_wasVisible) {
- g_system->clearOSD();
_wasVisible = true;
}
--_disabledFrames;
@@ -81,13 +84,11 @@ bool CloudIcon::draw() {
}
if (g_system) {
- Graphics::TransparentSurface *surface = &_icon;
- makeAlphaIcon((_showingDisabled ? _disabledIcon : _icon), _currentAlpha);
- if (_alphaIcon.getPixels())
- surface = &_alphaIcon;
- if (surface && surface->getPixels()) {
- int x = g_system->getOverlayWidth() - surface->w - 10, y = 10;
- g_system->copyRectToOSD(surface->getPixels(), surface->pitch, x, y, surface->w, surface->h);
+ if (!stop) {
+ makeAlphaIcon((_showingDisabled ? _disabledIcon : _icon), _currentAlpha);
+ g_system->displayActivityIconOnOSD(&_alphaIcon);
+ } else {
+ g_system->displayActivityIconOnOSD(nullptr);
}
}
@@ -112,36 +113,17 @@ void CloudIcon::initIcons() {
_iconsInited = true;
}
-void CloudIcon::loadIcon(Graphics::TransparentSurface &icon, byte *data, uint32 size) {
+void CloudIcon::loadIcon(Graphics::Surface &icon, byte *data, uint32 size) {
Image::PNGDecoder decoder;
Common::MemoryReadStream stream(data, size);
if (!decoder.loadStream(stream))
error("CloudIcon::loadIcon: error decoding PNG");
- Graphics::TransparentSurface *s = new Graphics::TransparentSurface(*decoder.getSurface(), true);
- if (s) {
- Graphics::PixelFormat f = g_system->getOSDFormat();
- if (f != s->format) {
- // Graphics::TransparentSurface::convertTo(f) errors out if the format is not 2Bpp or 4Bpp.
- // We don't need to error out as we can recover from it. So check the format before calling convertTo(f);
- Graphics::TransparentSurface *s2 = nullptr;
- if (f.bytesPerPixel == 2 || f.bytesPerPixel == 4)
- s2 = s->convertTo(f);
- if (s2)
- icon.copyFrom(*s2);
- else
- warning("CloudIcon::loadIcon: failed converting TransparentSurface");
- delete s2;
- } else {
- icon.copyFrom(*s);
- }
- delete s;
- } else {
- warning("CloudIcon::loadIcon: failed reading TransparentSurface from PNGDecoder");
- }
+ const Graphics::Surface *s = decoder.getSurface();
+ return icon.copyFrom(*s);
}
-void CloudIcon::makeAlphaIcon(Graphics::TransparentSurface &icon, float alpha) {
+void CloudIcon::makeAlphaIcon(Graphics::Surface &icon, float alpha) {
_alphaIcon.copyFrom(icon);
byte *pixels = (byte *)_alphaIcon.getPixels();
diff --git a/backends/networking/curl/cloudicon.h b/backends/networking/curl/cloudicon.h
index 316cb67370..d6ea60bd51 100644
--- a/backends/networking/curl/cloudicon.h
+++ b/backends/networking/curl/cloudicon.h
@@ -23,7 +23,7 @@
#ifndef BACKENDS_NETWORKING_CURL_CLOUDICON_H
#define BACKENDS_NETWORKING_CURL_CLOUDICON_H
-#include "graphics/transparent_surface.h"
+#include "graphics/surface.h"
namespace Networking {
@@ -31,14 +31,14 @@ class CloudIcon {
static const float ALPHA_STEP, ALPHA_MAX, ALPHA_MIN;
bool _wasVisible, _iconsInited, _showingDisabled;
- Graphics::TransparentSurface _icon, _disabledIcon, _alphaIcon;
+ Graphics::Surface _icon, _disabledIcon, _alphaIcon;
float _currentAlpha;
bool _alphaRising;
int _disabledFrames;
void initIcons();
- void loadIcon(Graphics::TransparentSurface &icon, byte *data, uint32 size);
- void makeAlphaIcon(Graphics::TransparentSurface &icon, float alpha);
+ void loadIcon(Graphics::Surface &icon, byte *data, uint32 size);
+ void makeAlphaIcon(Graphics::Surface &icon, float alpha);
public:
CloudIcon();