22 #ifndef PSP_GRAPHICS_H 23 #define PSP_GRAPHICS_H 25 #include "common/singleton.h" 26 #include "graphics/surface.h" 27 #include "common/system.h" 28 #include "backends/platform/psp/memory.h" 29 #include "backends/platform/psp/psppixelformat.h" 31 #define MAX_TEXTURE_SIZE 512 43 bool isVisible() {
return true; }
44 bool isDirty() {
return true; }
61 Point() : x(0), y(0) {}
80 Palette() : _values(0), _numOfEntries(0) {}
81 virtual ~
Palette() { deallocate(); }
85 void setPixelFormats(PSPPixelFormat::Type paletteType, PSPPixelFormat::Type bufferType,
bool swapRedBlue =
false);
86 void setNumOfEntries(uint32 num) { _numOfEntries = num; }
87 uint32 getNumOfEntries()
const {
return _numOfEntries; }
88 uint32 getSizeInBytes()
const {
return _pixelFormat.pixelsToBytes(_numOfEntries); }
89 void set(byte *values) { setPartial(values, 0, _numOfEntries); }
90 void setPartial(
const byte *colors, uint start, uint num,
bool supportsAlpha =
false);
91 void getPartial(byte *colors, uint start, uint num)
const;
92 uint32 getRawColorAt(uint32 position)
const;
93 uint32 getRGBAColorAt(uint32 position)
const;
94 void setSingleColorRGBA(uint32 num, byte r, byte g, byte b, byte a);
95 void setColorPositionAlpha(uint32 position,
bool alpha);
96 const byte *getRawValues()
const {
return _values; }
97 byte *getRawValues() {
return _values; }
98 bool isAllocated()
const {
return (_values != 0); }
99 PSPPixelFormat::Type getPixelFormat()
const {
return _pixelFormat.format; }
100 void print(uint32 numToPrint = 0);
120 Buffer() : _pixels(0), _width(0), _height(0) {}
121 virtual ~
Buffer() { deallocate(); }
124 void setSize(uint32 width, uint32 height, HowToSize textureOrSource = kSizeByTextureSize);
125 void setBitsPerPixel(uint32 bits) { _pixelFormat.bitsPerPixel = bits; }
126 void setBytesPerPixel(uint32 bytes) { setBitsPerPixel(bytes << 3); }
127 void setPixelFormat(PSPPixelFormat::Type type,
bool swapRedBlue =
false);
130 uint32 getWidth()
const {
return _width; }
131 uint32 getWidthInBytes()
const {
return _pixelFormat.pixelsToBytes(getWidth()); }
132 uint32 getHeight()
const {
return _height; }
133 uint32 getSourceWidth()
const {
return _sourceSize.width; }
134 uint32 getSourceWidthInBytes()
const {
return _pixelFormat.pixelsToBytes(_sourceSize.width); }
135 uint32 getSourceHeight()
const {
return _sourceSize.height; }
136 uint32 getTextureWidth()
const {
return _textureSize.width; }
137 uint32 getTextureHeight()
const {
return _textureSize.height; }
138 PSPPixelFormat::Type getPixelFormat()
const {
return _pixelFormat.format; }
139 uint32 getBitsPerPixel()
const {
return _pixelFormat.bitsPerPixel; }
140 uint32 getBytesPerPixel()
const {
return getBitsPerPixel() >> 3; }
141 const byte *getPixels()
const {
return _pixels; }
142 byte *getPixels() {
return _pixels; }
143 uint32 getSizeInBytes()
const {
return _pixelFormat.pixelsToBytes(_width * _height); }
146 void copyFromArray(
const byte *buffer,
int pitch);
147 void copyFromRect(
const byte *buf, uint32 pitch,
int destX,
int destY, uint32 recWidth, uint32 recHeight);
148 void copyToArray(byte *dst,
int pitch);
149 bool allocate(
bool inVram =
false);
151 bool isAllocated()
const {
return (_pixels != 0) ; }
154 static uint32 scaleUpToPowerOfTwo(uint32 size);
155 void print(uint32 mask, uint32 numToPrint = 0);
175 GuRenderer() : _useGlobalScaler(
false), _buffer(0), _palette(0),
176 _blending(
false), _alphaReverse(
false), _colorTest(
false),
177 _keyColor(0), _fullScreen(
false), _stretch(
false), _stretchX(1.0f), _stretchY(1.0f) {}
179 _useGlobalScaler(
false), _buffer(buffer), _palette(palette),
180 _blending(
false), _alphaReverse(
false), _colorTest(
false),
181 _keyColor(0), _fullScreen(
false), _stretch(
false), _stretchX(1.0f), _stretchY(1.0f) {}
182 static void setDisplayManager(
DisplayManager *dm) { _displayManager = dm; }
185 void setDrawSize(uint32 width, uint32 height) {
186 _drawSize.width = width;
187 _drawSize.height = height;
189 void setDrawWholeBuffer() {
191 _drawSize.width = _buffer->getSourceWidth();
192 _drawSize.height = _buffer->getSourceHeight();
194 void setBuffer(
Buffer *buffer) { _buffer = buffer; }
195 void setPalette(
Palette *palette) { _palette = palette; }
196 void setOffsetOnScreen(
int x,
int y) { _offsetOnScreen.x = x; _offsetOnScreen.y = y; }
197 void setOffsetInBuffer(uint32 x, uint32 y) { _offsetInBuffer.x = x; _offsetInBuffer.y = y; }
198 void setColorTest(
bool value) { _colorTest = value; }
199 void setKeyColor(uint32 value) { _keyColor = _buffer->
_pixelFormat.convertTo32BitColor(value); }
200 void setAlphaBlending(
bool value) { _blending = value; }
201 void setAlphaReverse(
bool value) { _alphaReverse = value; }
202 void setFullScreen(
bool value) { _fullScreen = value; }
203 void setUseGlobalScaler(
bool value) { _useGlobalScaler = value; }
204 void setStretch(
bool active) { _stretch = active; }
205 void setStretchXY(
float x,
float y) { _stretchX = x; _stretchY = y; }
207 static void cacheInvalidate(
void *pointer, uint32 size);
213 void fillVertices(
Vertex *vertices);
214 void guProgramDrawBehavior();
216 void guLoadTexture();
217 void guLoadPalette();
218 void guProgramTextureFormat();
219 void guProgramTextureBitDepth();
220 void guDrawVertices(
Vertex *vertices);
222 uint32 convertToGuPixelFormat(PSPPixelFormat::Type format);
223 float scaleSourceToOutput(
bool x,
float offset);
224 float stretch(
bool x,
float size);
227 Point _textureLoadOffset;
PSPPixelFormat _pixelFormat
pixel format of the palette data
Definition: display_client.h:105
Point _offsetInBuffer
Where on screen to draw
Definition: display_client.h:229
uint32 _height
True allocated height.
Definition: display_client.h:161
bool _stretch
Speeds up for fullscreen rendering
Definition: display_client.h:240
Definition: display_client.h:58
bool _useGlobalScaler
Where in the texture to draw
Definition: display_client.h:230
float _stretchX
Whether zooming is activated
Definition: display_client.h:241
bool _blending
Actual size to draw out of the Buffer
Definition: display_client.h:235
Definition: display_manager.h:72
Dimensions _sourceSize
Original size of the buffer.
Definition: display_client.h:163
bool _colorTest
0 counts as full alpha
Definition: display_client.h:237
Point _offsetOnScreen
For rendering textures > 512 pixels
Definition: display_client.h:228
Definition: display_manager.h:103
Definition: display_client.h:172
uint32 _width
True allocated width.
Definition: display_client.h:160
Definition: display_client.h:53
PSPPixelFormat _pixelFormat
Format of the buffer.
Definition: display_client.h:164
uint32 _numOfEntries
number of palette entries
Definition: display_client.h:104
Definition: display_client.h:113
byte * _values
array of palette data
Definition: display_client.h:103
Definition: display_client.h:67
Dimensions _textureSize
Size rounded up to power of 2. Used for drawing.
Definition: display_client.h:162
Definition: display_client.h:40
bool _fullScreen
Color to test against for color test. in 32 bits.
Definition: display_client.h:239
Buffer * _buffer
Scale to the output size on screen
Definition: display_client.h:231
Definition: atari-screen.h:44