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);
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);
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 const byte *getBasePtr(
int x,
int y)
const {
return _pixels + _pixelFormat.pixelsToBytes((y * _width) + x); }
144 byte *getBasePtr(
int x,
int y) {
return _pixels + _pixelFormat.pixelsToBytes((y * _width) + x); }
145 uint32 getSizeInBytes()
const {
return _pixelFormat.pixelsToBytes(_width * _height); }
148 void copyFromArray(
const byte *buffer,
int pitch);
149 void copyFromRect(
const byte *buf, uint32 pitch,
int destX,
int destY, uint32 recWidth, uint32 recHeight);
150 void copyToArray(byte *dst,
int pitch);
151 bool allocate(
bool inVram =
false);
153 bool isAllocated()
const {
return (_pixels != 0) ; }
156 static uint32 scaleUpToPowerOfTwo(uint32 size);
157 void print(uint32 mask, uint32 numToPrint = 0);
177 GuRenderer() : _useGlobalScaler(
false), _buffer(0), _palette(0),
178 _blending(
false), _alphaReverse(
false), _colorTest(
false),
179 _keyColor(0), _fullScreen(
false), _stretch(
false), _stretchX(1.0f), _stretchY(1.0f) {}
181 _useGlobalScaler(
false), _buffer(buffer), _palette(palette),
182 _blending(
false), _alphaReverse(
false), _colorTest(
false),
183 _keyColor(0), _fullScreen(
false), _stretch(
false), _stretchX(1.0f), _stretchY(1.0f) {}
184 static void setDisplayManager(
DisplayManager *dm) { _displayManager = dm; }
187 void setDrawSize(uint32 width, uint32 height) {
188 _drawSize.width = width;
189 _drawSize.height = height;
191 void setDrawWholeBuffer() {
193 _drawSize.width = _buffer->getSourceWidth();
194 _drawSize.height = _buffer->getSourceHeight();
196 void setBuffer(
Buffer *buffer) { _buffer = buffer; }
197 void setPalette(
Palette *palette) { _palette = palette; }
198 void setOffsetOnScreen(
int x,
int y) { _offsetOnScreen.x = x; _offsetOnScreen.y = y; }
199 void setOffsetInBuffer(uint32 x, uint32 y) { _offsetInBuffer.x = x; _offsetInBuffer.y = y; }
200 void setColorTest(
bool value) { _colorTest = value; }
201 void setKeyColor(uint32 value) { _keyColor = value; }
202 void setAlphaBlending(
bool value) { _blending = value; }
203 void setAlphaReverse(
bool value) { _alphaReverse = value; }
204 void setFullScreen(
bool value) { _fullScreen = value; }
205 void setUseGlobalScaler(
bool value) { _useGlobalScaler = value; }
206 void setStretch(
bool active) { _stretch = active; }
207 void setStretchXY(
float x,
float y) { _stretchX = x; _stretchY = y; }
209 static void cacheInvalidate(
void *pointer, uint32 size);
215 void fillVertices(
Vertex *vertices);
216 void guProgramDrawBehavior();
218 void guLoadTexture();
219 void guLoadPalette();
220 void guProgramTextureFormat();
221 void guProgramTextureBitDepth();
222 void guDrawVertices(
Vertex *vertices);
224 uint32 convertToGuPixelFormat(PSPPixelFormat::Type format);
225 float scaleSourceToOutput(
bool x,
float offset);
226 float stretch(
bool x,
float size);
229 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:231
uint32 _height
True allocated height.
Definition: display_client.h:163
bool _stretch
Speeds up for fullscreen rendering
Definition: display_client.h:242
Definition: display_client.h:58
bool _useGlobalScaler
Where in the texture to draw
Definition: display_client.h:232
float _stretchX
Whether zooming is activated
Definition: display_client.h:243
bool _blending
Actual size to draw out of the Buffer
Definition: display_client.h:237
Definition: display_manager.h:72
Dimensions _sourceSize
Original size of the buffer.
Definition: display_client.h:165
bool _colorTest
0 counts as full alpha
Definition: display_client.h:239
Point _offsetOnScreen
For rendering textures > 512 pixels
Definition: display_client.h:230
Definition: display_manager.h:103
Definition: display_client.h:174
uint32 _width
True allocated width.
Definition: display_client.h:162
Definition: display_client.h:53
PSPPixelFormat _pixelFormat
Format of the buffer.
Definition: display_client.h:166
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:164
Definition: display_client.h:40
bool _fullScreen
Color to test against for color test. in 32 bits.
Definition: display_client.h:241
Buffer * _buffer
Scale to the output size on screen
Definition: display_client.h:233
Definition: atari-screen.h:42