[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3909 - trunk/pingus/src/display
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3909 - trunk/pingus/src/display |
Date: |
Sun, 27 Jul 2008 05:59:35 +0200 |
Author: grumbel
Date: 2008-07-27 05:59:34 +0200 (Sun, 27 Jul 2008)
New Revision: 3909
Modified:
trunk/pingus/src/display/framebuffer_surface.cpp
trunk/pingus/src/display/framebuffer_surface.hpp
trunk/pingus/src/display/sdl_framebuffer.cpp
trunk/pingus/src/display/sdl_framebuffer_surface_impl.cpp
Log:
Added fault tollerance in FramebufferSurface when impl is 0
Modified: trunk/pingus/src/display/framebuffer_surface.cpp
===================================================================
--- trunk/pingus/src/display/framebuffer_surface.cpp 2008-07-27 03:38:21 UTC
(rev 3908)
+++ trunk/pingus/src/display/framebuffer_surface.cpp 2008-07-27 03:59:34 UTC
(rev 3909)
@@ -15,7 +15,78 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "framebuffer_surface.hpp"
+
+FramebufferSurface::FramebufferSurface()
+{
+}
+FramebufferSurface::FramebufferSurface(FramebufferSurfaceImpl* impl)
+ : impl(impl)
+{
+}
+FramebufferSurface::~FramebufferSurface()
+{
+}
+int
+FramebufferSurface::get_width() const
+{
+ if (impl.get())
+ return impl->get_width();
+ else
+ return 0;
+}
+
+int
+FramebufferSurface::get_height() const
+{
+ if (impl.get())
+ return impl->get_height();
+ else
+ return 0;
+}
+
+Size
+FramebufferSurface::get_size() const
+{
+ if (impl.get())
+ return Size(impl->get_width(), impl->get_height());
+ else
+ return Size(0, 0);
+}
+
+FramebufferSurfaceImpl*
+FramebufferSurface::get_impl() const
+{
+ return impl.get();
+}
+
+bool
+FramebufferSurface::operator==(const FramebufferSurface& other) const
+{
+ return impl == other.impl;
+}
+
+FramebufferSurface::operator bool() const
+{
+ return impl.get() != 0;
+}
+
+long
+FramebufferSurface::use_count() const
+{
+ return impl.use_count();
+}
+
+Surface
+FramebufferSurface::to_surface() const
+{
+ if (impl.get())
+ return impl->to_surface();
+ else
+ return Surface();
+}
+
+
/* EOF */
Modified: trunk/pingus/src/display/framebuffer_surface.hpp
===================================================================
--- trunk/pingus/src/display/framebuffer_surface.hpp 2008-07-27 03:38:21 UTC
(rev 3908)
+++ trunk/pingus/src/display/framebuffer_surface.hpp 2008-07-27 03:59:34 UTC
(rev 3909)
@@ -36,23 +36,24 @@
class FramebufferSurface
{
public:
- FramebufferSurface() {}
- FramebufferSurface(FramebufferSurfaceImpl* impl) : impl(impl) {}
- ~FramebufferSurface() {}
+ FramebufferSurface();
+ FramebufferSurface(FramebufferSurfaceImpl* impl);
+ ~FramebufferSurface();
- int get_width() const { return impl->get_width(); }
- int get_height() const { return impl->get_height(); }
- Size get_size() const { return Size(impl->get_width(),
impl->get_height()); }
+ int get_width() const;
+ int get_height() const;
+ Size get_size() const;
- FramebufferSurfaceImpl* get_impl() const { return impl.get(); }
+ FramebufferSurfaceImpl* get_impl() const;
- bool operator==(const FramebufferSurface& other) const { return impl ==
other.impl; }
+ bool operator==(const FramebufferSurface& other) const;
- operator bool() const { return impl.get() != 0; }
+ operator bool() const;
- long use_count() const { return impl.use_count(); }
+ long use_count() const;
- Surface to_surface() const { return impl->to_surface(); }
+ Surface to_surface() const;
+
private:
boost::shared_ptr<FramebufferSurfaceImpl> impl;
};
Modified: trunk/pingus/src/display/sdl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-27 03:38:21 UTC
(rev 3908)
+++ trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-27 03:59:34 UTC
(rev 3909)
@@ -150,7 +150,14 @@
FramebufferSurface
SDLFramebuffer::create_surface(const Surface& surface)
{
- return FramebufferSurface(new
SDLFramebufferSurfaceImpl(surface.get_surface()));
+ if (surface)
+ {
+ return FramebufferSurface(new
SDLFramebufferSurfaceImpl(surface.get_surface()));
+ }
+ else
+ {
+ return FramebufferSurface();
+ }
}
void
Modified: trunk/pingus/src/display/sdl_framebuffer_surface_impl.cpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer_surface_impl.cpp 2008-07-27
03:38:21 UTC (rev 3908)
+++ trunk/pingus/src/display/sdl_framebuffer_surface_impl.cpp 2008-07-27
03:59:34 UTC (rev 3909)
@@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include <stdexcept>
#include "sdl_framebuffer_surface_impl.hpp"
-
+
SDLFramebufferSurfaceImpl::SDLFramebufferSurfaceImpl(SDL_Surface* src)
{
if (src->format->Amask != 0 || (src->flags & SDL_SRCCOLORKEY))
@@ -52,5 +53,5 @@
return Surface(surface);
}
-
- /* EOF */
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3909 - trunk/pingus/src/display,
grumbel at BerliOS <=