comparison engine/core/video/renderbackend.cpp @ 621:356634098bd9

* Removed the image chunking size variable from engine settings. * Replaced the existing define of PI and added some math related static const variables
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 01 Oct 2010 14:09:47 +0000
parents ad7969d9460b
children 5f381fa34769
comparison
equal deleted inserted replaced
620:853d25234671 621:356634098bd9
28 // First block: files included from the FIFE root src directory 28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder 29 // Second block: files included from the same folder
30 #include "renderbackend.h" 30 #include "renderbackend.h"
31 31
32 namespace FIFE { 32 namespace FIFE {
33 33
34 const unsigned int DEFAULT_CHUNKING_SIZE = 256; 34
35 const unsigned int MAX_CHUNKING_SIZE = 262144; // pixels! 35 RenderBackend::RenderBackend(const SDL_Color& colorkey):
36 36 m_screen(NULL),
37 RenderBackend::RenderBackend(const SDL_Color& colorkey): 37 m_isalphaoptimized(false),
38 m_screen(NULL),
39 m_isalphaoptimized(false),
40 m_chunkingsize(DEFAULT_CHUNKING_SIZE),
41 m_iscolorkeyenabled(false), 38 m_iscolorkeyenabled(false),
42 m_colorkey(colorkey) { 39 m_colorkey(colorkey) {
43 } 40 }
44 41
45 42
53 } 50 }
54 51
55 void RenderBackend::captureScreen(const std::string& filename) { 52 void RenderBackend::captureScreen(const std::string& filename) {
56 m_screen->saveImage(filename); 53 m_screen->saveImage(filename);
57 } 54 }
58 55
59 void RenderBackend::pushClipArea(const Rect& cliparea, bool clear) { 56 void RenderBackend::pushClipArea(const Rect& cliparea, bool clear) {
60 assert(m_screen); 57 assert(m_screen);
61 m_screen->pushClipArea(cliparea, clear); 58 m_screen->pushClipArea(cliparea, clear);
62 } 59 }
63 60
64 void RenderBackend::popClipArea() { 61 void RenderBackend::popClipArea() {
65 assert(m_screen); 62 assert(m_screen);
66 m_screen->popClipArea(); 63 m_screen->popClipArea();
67 } 64 }
68 65
69 const Rect& RenderBackend::getClipArea() const { 66 const Rect& RenderBackend::getClipArea() const {
70 assert(m_screen); 67 assert(m_screen);
71 return m_screen->getClipArea(); 68 return m_screen->getClipArea();
72 } 69 }
73 70
74 SDL_Surface* RenderBackend::getSurface() { 71 SDL_Surface* RenderBackend::getSurface() {
75 assert(m_screen); 72 assert(m_screen);
76 return m_screen->getSurface(); 73 return m_screen->getSurface();
77 } 74 }
78 75
79 unsigned int RenderBackend::getWidth() const { 76 unsigned int RenderBackend::getWidth() const {
80 assert(m_screen); 77 assert(m_screen);
81 return m_screen->getWidth(); 78 return m_screen->getWidth();
82 } 79 }
83 80
84 unsigned int RenderBackend::getHeight() const { 81 unsigned int RenderBackend::getHeight() const {
85 assert(m_screen); 82 assert(m_screen);
86 return m_screen->getHeight(); 83 return m_screen->getHeight();
87 } 84 }
88 85
89 const Rect& RenderBackend::getArea() { 86 const Rect& RenderBackend::getArea() {
90 assert(m_screen); 87 assert(m_screen);
91 SDL_Surface* s = m_screen->getSurface(); 88 SDL_Surface* s = m_screen->getSurface();
92 static Rect r(0, 0, s->w, s->h); 89 static Rect r(0, 0, s->w, s->h);
93 return r; 90 return r;
94 } 91 }
95 92
96 void RenderBackend::getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) { 93 void RenderBackend::getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
97 assert(m_screen); 94 assert(m_screen);
98 m_screen->getPixelRGBA(x, y, r, g, b, a); 95 m_screen->getPixelRGBA(x, y, r, g, b, a);
99 } 96 }
100 97
101 void RenderBackend::saveImage(const std::string& filename) { 98 void RenderBackend::saveImage(const std::string& filename) {
102 assert(m_screen); 99 assert(m_screen);
103 m_screen->saveImage(filename); 100 m_screen->saveImage(filename);
104 } 101 }
105 102
106 void RenderBackend::setAlphaOptimizerEnabled(bool enabled) { 103 void RenderBackend::setAlphaOptimizerEnabled(bool enabled) {
107 assert(m_screen); 104 assert(m_screen);
108 m_screen->setAlphaOptimizerEnabled(enabled); 105 m_screen->setAlphaOptimizerEnabled(enabled);
109 } 106 }
110 107
111 bool RenderBackend::isAlphaOptimizerEnabled() { 108 bool RenderBackend::isAlphaOptimizerEnabled() {
112 assert(m_screen); 109 assert(m_screen);
113 return m_screen->isAlphaOptimizerEnabled(); 110 return m_screen->isAlphaOptimizerEnabled();
114 }
115
116 void RenderBackend::setChunkingSize(unsigned int size) {
117 if (size > MAX_CHUNKING_SIZE) {
118 size = MAX_CHUNKING_SIZE;
119 }
120 m_chunkingsize = 1;
121 while (m_chunkingsize < size) {
122 m_chunkingsize <<= 1;
123 }
124 }
125
126 unsigned int RenderBackend::getChunkingSize() {
127 return m_chunkingsize;
128 } 111 }
129 112
130 void RenderBackend::setColorKeyEnabled(bool colorkeyenable) { 113 void RenderBackend::setColorKeyEnabled(bool colorkeyenable) {
131 m_iscolorkeyenabled = colorkeyenable; 114 m_iscolorkeyenabled = colorkeyenable;
132 } 115 }