summaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/32bpp.cpp77
-rw-r--r--src/renderer/32bpp.hpp35
-rw-r--r--src/renderer/8bpp.cpp71
-rw-r--r--src/renderer/8bpp.hpp29
-rw-r--r--src/renderer/null.cpp39
-rw-r--r--src/renderer/null.hpp29
-rw-r--r--src/renderer/renderer.hpp165
7 files changed, 0 insertions, 445 deletions
diff --git a/src/renderer/32bpp.cpp b/src/renderer/32bpp.cpp
deleted file mode 100644
index 1d1d78e6a..000000000
--- a/src/renderer/32bpp.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "../stdafx.h"
-#include "../gfx.h"
-#include "32bpp.hpp"
-
-static FRenderer_32bpp iFRenderer_32bpp;
-
-void *Renderer_32bpp::MoveTo(const void *video, int x, int y)
-{
- return (uint32 *)video + x + y * _screen.pitch;
-}
-
-void Renderer_32bpp::SetPixel(void *video, int x, int y, uint8 color)
-{
- *((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
-}
-
-void Renderer_32bpp::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
-{
- uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
- if (*dst == 0) *dst = LookupColourInPalette(color);
-}
-
-void Renderer_32bpp::SetHorizontalLine(void *video, int width, uint8 color)
-{
- uint32 *dst = (uint32 *)video;
- uint32 color32 = LookupColourInPalette(color);
-
- for (; width > 0; width--) {
- *dst = color32;
- dst++;
- }
-}
-
-void Renderer_32bpp::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch)
-{
- int direction = (height < 0) ? -1 : 1;
- uint32 *dst = (uint32 *)video;
- uint32 *usrc = (uint32 *)src;
-
- height = abs(height);
- for (; height > 0; height--) {
- memcpy(dst, usrc, width * sizeof(uint32));
- usrc += src_pitch * direction;
- dst += _screen.pitch * direction;
- }
-}
-
-void Renderer_32bpp::CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
-{
- int direction = (height < 0) ? -1 : 1;
- uint32 *udst = (uint32 *)dst;
- uint32 *src = (uint32 *)video;
-
- height = abs(height);
- for (; height > 0; height--) {
- memcpy(udst, src, width * sizeof(uint32));
- src += _screen.pitch * direction;
- udst += dst_pitch * direction;
- }
-}
-
-void Renderer_32bpp::MoveBuffer(void *video_dst, const void *video_src, int width, int height)
-{
- uint32 *dst = (uint32 *)video_dst;
- uint32 *src = (uint32 *)video_src;
-
- for (; height > 0; height--) {
- memmove(dst, src, width * sizeof(uint32));
- src += _screen.pitch;
- dst += _screen.pitch;
- }
-}
-
-int Renderer_32bpp::BufferSize(int width, int height)
-{
- return width * height * sizeof(uint32);
-}
diff --git a/src/renderer/32bpp.hpp b/src/renderer/32bpp.hpp
deleted file mode 100644
index 7f0283754..000000000
--- a/src/renderer/32bpp.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $Id$ */
-
-/** @file 32bpp.hpp */
-
-#ifndef RENDERER_32BPP_HPP
-#define RENDERER_32BPP_HPP
-
-#include "renderer.hpp"
-
-class Renderer_32bpp : public Renderer {
-public:
- /* virtual */ void *MoveTo(const void *video, int x, int y);
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 color);
- /* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color);
- /* virtual */ void SetHorizontalLine(void *video, int width, uint8 color);
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch);
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
- /* virtual */ void MoveBuffer(void *video_dst, const void *video_src, int width, int height);
- /* virtual */ int BufferSize(int width, int height);
-
- static inline uint32 LookupColourInPalette(uint8 index) {
- #define ARGB(a, r, g, b) ((((a) << 24) & 0xFF000000) | (((r) << 16) & 0x00FF0000) | (((g) << 8) & 0x0000FF00) | ((b) & 0x000000FF))
- if (index == 0) return 0x00000000;
- return ARGB(0xFF, _cur_palette[index].r, _cur_palette[index].g, _cur_palette[index].b);
- }
-};
-
-class FRenderer_32bpp: public RendererFactory<FRenderer_32bpp> {
-public:
- /* virtual */ const char *GetName() { return "32bpp"; }
-
- /* virtual */ Renderer *CreateInstance() { return new Renderer_32bpp(); }
-};
-
-#endif /* RENDERER_32BPP_HPP */
diff --git a/src/renderer/8bpp.cpp b/src/renderer/8bpp.cpp
deleted file mode 100644
index 2f595c6c9..000000000
--- a/src/renderer/8bpp.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "../stdafx.h"
-#include "../gfx.h"
-#include "8bpp.hpp"
-
-static FRenderer_8bpp iFRenderer_8bpp;
-
-void *Renderer_8bpp::MoveTo(const void *video, int x, int y)
-{
- return (uint8 *)video + x + y * _screen.pitch;
-}
-
-void Renderer_8bpp::SetPixel(void *video, int x, int y, uint8 color)
-{
- *((uint8 *)video + x + y * _screen.pitch) = color;
-}
-
-void Renderer_8bpp::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
-{
- uint8 *dst = (uint8 *)video + x + y * _screen.pitch;
- if (*dst == 0) *dst = color;
-}
-
-void Renderer_8bpp::SetHorizontalLine(void *video, int width, uint8 color)
-{
- memset(video, color, width);
-}
-
-void Renderer_8bpp::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch)
-{
- int direction = (height < 0) ? -1 : 1;
- uint8 *dst = (uint8 *)video;
- uint8 *usrc = (uint8 *)src;
-
- height = abs(height);
- for (; height > 0; height--) {
- memcpy(dst, usrc, width);
- usrc += src_pitch * direction;
- dst += _screen.pitch * direction;
- }
-}
-
-void Renderer_8bpp::CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
-{
- int direction = (height < 0) ? -1 : 1;
- uint8 *udst = (uint8 *)dst;
- uint8 *src = (uint8 *)video;
-
- height = abs(height);
- for (; height > 0; height--) {
- memcpy(udst, src, width);
- src += _screen.pitch * direction;
- udst += dst_pitch * direction;
- }
-}
-
-void Renderer_8bpp::MoveBuffer(void *video_dst, const void *video_src, int width, int height)
-{
- uint8 *dst = (uint8 *)video_dst;
- uint8 *src = (uint8 *)video_src;
-
- for (; height > 0; height--) {
- memmove(dst, src, width);
- src += _screen.pitch;
- dst += _screen.pitch;
- }
-}
-
-int Renderer_8bpp::BufferSize(int width, int height)
-{
- return width * height;
-}
diff --git a/src/renderer/8bpp.hpp b/src/renderer/8bpp.hpp
deleted file mode 100644
index a8bb27a48..000000000
--- a/src/renderer/8bpp.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $Id$ */
-
-/** @file 8bpp.hpp */
-
-#ifndef RENDERER_8BPP_HPP
-#define RENDERER_8BPP_HPP
-
-#include "renderer.hpp"
-
-class Renderer_8bpp : public Renderer {
-public:
- /* virtual */ void *MoveTo(const void *video, int x, int y);
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 color);
- /* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color);
- /* virtual */ void SetHorizontalLine(void *video, int width, uint8 color);
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch);
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
- /* virtual */ void MoveBuffer(void *video_dst, const void *video_src, int width, int height);
- /* virtual */ int BufferSize(int width, int height);
-};
-
-class FRenderer_8bpp: public RendererFactory<FRenderer_8bpp> {
-public:
- /* virtual */ const char *GetName() { return "8bpp"; }
-
- /* virtual */ Renderer *CreateInstance() { return new Renderer_8bpp(); }
-};
-
-#endif /* RENDERER_8BPP_HPP */
diff --git a/src/renderer/null.cpp b/src/renderer/null.cpp
deleted file mode 100644
index fc68feaf2..000000000
--- a/src/renderer/null.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "../stdafx.h"
-#include "../gfx.h"
-#include "null.hpp"
-
-static FRenderer_Null iFRenderer_Null;
-
-void *Renderer_Null::MoveTo(const void *video, int x, int y)
-{
- return NULL;
-}
-
-void Renderer_Null::SetPixel(void *video, int x, int y, uint8 color)
-{
-}
-
-void Renderer_Null::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
-{
-}
-
-void Renderer_Null::SetHorizontalLine(void *video, int width, uint8 color)
-{
-}
-
-void Renderer_Null::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch)
-{
-}
-
-void Renderer_Null::CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
-{
-}
-
-void Renderer_Null::MoveBuffer(void *video_dst, const void *video_src, int width, int height)
-{
-}
-
-int Renderer_Null::BufferSize(int width, int height)
-{
- return 0;
-}
diff --git a/src/renderer/null.hpp b/src/renderer/null.hpp
deleted file mode 100644
index 1eb95bbdd..000000000
--- a/src/renderer/null.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $Id$ */
-
-/** @file null.hpp */
-
-#ifndef RENDERER_NULL_HPP
-#define RENDERER_NULL_HPP
-
-#include "renderer.hpp"
-
-class Renderer_Null : public Renderer {
-public:
- /* virtual */ void *MoveTo(const void *video, int x, int y);
- /* virtual */ void SetPixel(void *video, int x, int y, uint8 color);
- /* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color);
- /* virtual */ void SetHorizontalLine(void *video, int width, uint8 color);
- /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch);
- /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
- /* virtual */ void MoveBuffer(void *video_dst, const void *video_src, int width, int height);
- /* virtual */ int BufferSize(int width, int height);
-};
-
-class FRenderer_Null: public RendererFactory<FRenderer_Null> {
-public:
- /* virtual */ const char *GetName() { return "null"; }
-
- /* virtual */ Renderer *CreateInstance() { return new Renderer_Null(); }
-};
-
-#endif /* RENDERER_NULL_HPP */
diff --git a/src/renderer/renderer.hpp b/src/renderer/renderer.hpp
deleted file mode 100644
index 7b7ad0f4f..000000000
--- a/src/renderer/renderer.hpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/* $Id$ */
-
-/** @file renderer.hpp */
-
-#ifndef RENDERER_HPP
-#define RENDERER_HPP
-
-#include <string>
-#include <map>
-
-class Renderer {
-public:
- virtual ~Renderer() { }
-
- /**
- * Move the destination pointer the requested amount x and y, keeping in mind
- * any pitch and bpp of the renderer.
- * @param video The destination pointer (video-buffer) to scroll.
- * @param x How much you want to scroll to the right.
- * @param y How much you want to scroll to the bottom.
- * @return A new destination pointer moved the the requested place.
- */
- virtual void *MoveTo(const void *video, int x, int y) = 0;
-
- /**
- * Draw a pixel with a given color on the video-buffer.
- * @param video The destination pointer (video-buffer).
- * @param x The x position within video-buffer.
- * @param y The y position within video-buffer.
- * @param color A 8bpp mapping color.
- */
- virtual void SetPixel(void *video, int x, int y, uint8 color) = 0;
-
- /**
- * Draw a pixel with a given color on the video-buffer if there is currently a black pixel.
- * @param video The destination pointer (video-buffer).
- * @param x The x position within video-buffer.
- * @param y The y position within video-buffer.
- * @param color A 8bpp mapping color.
- */
- virtual void SetPixelIfEmpty(void *video, int x, int y, uint8 color) = 0;
-
- /**
- * Make a single horizontal line in a single color on the video-buffer.
- * @param video The destination pointer (video-buffer).
- * @param width The lenght of the line.
- * @param color A 8bpp mapping color.
- */
- virtual void SetHorizontalLine(void *video, int width, uint8 color) = 0;
-
- /**
- * Copy from a buffer to the screen.
- * @param video The destionation pointer (video-buffer).
- * @param src The buffer from which the data will be read.
- * @param width The width of the buffer.
- * @param height The height of the buffer.
- * @param src_pitch The pitch (byte per line) of the source buffer.
- */
- virtual void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) = 0;
-
- /**
- * Copy from the screen to a buffer.
- * @param video The destination pointer (video-buffer).
- * @param dst The buffer in which the data will be stored.
- * @param width The width of the buffer.
- * @param height The height of the buffer.
- * @param dst_pitch The pitch (byte per line) of the destination buffer.
- */
- virtual void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
-
- /**
- * Move the videobuffer some places (via memmove).
- * @param video_dst The destination pointer (video-buffer).
- * @param video_src The source pointer (video-buffer).
- * @param width The width of the buffer to move.
- * @param height The height of the buffer to move.
- */
- virtual void MoveBuffer(void *video_dst, const void *video_src, int width, int height) = 0;
-
- /**
- * Calculate how much memory there is needed for an image of this size in the video-buffer.
- * @param width The width of the buffer-to-be.
- * @param height The height of the buffer-to-be.
- * @return The size needed for the buffer.
- */
- virtual int BufferSize(int width, int height) = 0;
-};
-
-/**
- * The factory, keeping track of all renderers.
- */
-class RendererFactoryBase {
-private:
- char *name;
- typedef std::map<std::string, RendererFactoryBase *> Renderers;
-
- static Renderers &GetRenderers()
- {
- static Renderers &s_renderers = *new Renderers();
- return s_renderers;
- }
-
-protected:
- /**
- * Register a renderer internally, based on his bpp.
- * @param name the name of the renderer.
- * @note an assert() will be trigger if 2 renderers with the same bpp try to register.
- */
- void RegisterRenderer(const char *name)
- {
- /* Don't register nameless Renderers */
- if (name == NULL) return;
-
- this->name = strdup(name);
- std::pair<Renderers::iterator, bool> P = GetRenderers().insert(Renderers::value_type(name, this));
- assert(P.second);
- }
-
-public:
- RendererFactoryBase() :
- name(NULL)
- { }
-
- virtual ~RendererFactoryBase() { if (this->name != NULL) GetRenderers().erase(this->name); free(this->name); }
-
- /**
- * Find the requested renderer and return his class-instance.
- * @param name the renderer to select.
- */
- static Renderer *SelectRenderer(const char *name)
- {
- if (GetRenderers().size() == 0) return NULL;
-
- Renderers::iterator it = GetRenderers().begin();
- for (; it != GetRenderers().end(); it++) {
- RendererFactoryBase *r = (*it).second;
- if (strcasecmp(name, r->name) == 0) {
- return r->CreateInstance();
- }
- }
- return NULL;
- }
-
- /**
- * Create an instance of this Renderer-class.
- */
- virtual Renderer *CreateInstance() = 0;
-};
-
-/**
- * A template factory, so ->GetBpp() works correctly. This because else some compiler will complain.
- */
-template <class T>
-class RendererFactory: public RendererFactoryBase {
-public:
- RendererFactory() { this->RegisterRenderer(((T *)this)->GetName()); }
-
- /**
- * Get the name for this renderer.
- */
- const char *GetName();
-};
-
-
-#endif /* RENDERER_HPP */