00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KYRA_PIXELBLOCK_INCLUDED
00033 #define KYRA_PIXELBLOCK_INCLUDED
00034
00035
00036 #include "../../grinliz/gltypes.h"
00037 #include "../../grinliz/gldebug.h"
00038 #include "../engine/krmath.h"
00039 #include "SDL.h"
00040 #include "painter.h"
00041 #include "ogltexture.h"
00042
00043
00044 class LinearMemoryPool;
00045
00046
00047
00048
00049
00050
00051 class KrPixelBlock
00052 {
00053 public:
00054 KrPixelBlock();
00055 ~KrPixelBlock();
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 void Draw( KrPaintInfo* paintInfo,
00068 const KrMatrix2& matrix,
00069 bool invert,
00070 const KrColorTransform& cForm,
00071 const grinliz::Rectangle2I& clipping,
00072 int quality );
00073
00074
00075 bool Read( SDL_RWops* data );
00076
00077
00078 bool Create( KrPaintInfo* surface,
00079 int x, int y, int width, int height );
00080
00081
00082 bool Create( int width, int height, bool alphaSupport );
00083
00084
00085 bool Write( SDL_RWops* stream );
00086
00087 int Width() const { return size.x; }
00088 int Height() const { return size.y; }
00089 bool Alpha() const { return (flags & ALPHA) != 0; }
00090
00091
00092
00093
00094
00095 KrRGBA* Pixels() { return block; }
00096
00097
00098 KrRGBA* LowerLeftPixels() { return block + (size.y-1) * size.x; }
00099 KrRGBA* LowerRightPixels() { return block + (size.y-1) * size.x + size.x - 1; }
00100 KrRGBA* UpperRightPixels() { return block + size.x - 1; }
00101
00102
00103 void CountComponents( U32* numRGBA );
00104
00105 void CalculateBounds( const KrMatrix2& xForm, grinliz::Rectangle2I* bounds ) const;
00106
00107
00108
00109 #ifdef DEBUG
00110 static U32 numRGBA;
00111 #endif
00112
00113
00114 void LoadNewTexture();
00115
00116 void DrawOpenGL( KrPaintInfo* paintInfo,
00117 const KrMatrix2& matrix,
00118 const KrColorTransform& cForm,
00119 const grinliz::Rectangle2I& clipping,
00120 int rotation );
00121
00122
00123
00124
00125 void DrawScaled( KrPaintInfo* paintInfo,
00126 const KrMatrix2& xForm,
00127 const KrColorTransform& cForm,
00128 const grinliz::Rectangle2I& clipping,
00129 int quality,
00130 bool invert );
00131 void DrawScaledFast( KrPaintInfo* paintInfo,
00132 const KrMatrix2& xForm,
00133 const KrColorTransform& cForm,
00134 const grinliz::Rectangle2I& clipping,
00135 bool invert );
00136 void DrawScaledDown( KrPaintInfo* paintInfo,
00137 const KrMatrix2& xForm,
00138 const KrColorTransform& cForm,
00139 const grinliz::Rectangle2I& clipping );
00140 void DrawScaledLinear( KrPaintInfo* paintInfo,
00141 const KrMatrix2& xForm,
00142 const KrColorTransform& cForm,
00143 const grinliz::Rectangle2I& clipping );
00144
00145 protected:
00146 enum {
00147 ALPHA = 0x01,
00148 MEMORYPOOL = 0x02,
00149 };
00150
00151
00152 U32 flags;
00153 grinliz::Vector2I size;
00154 KrRGBA* block;
00155 KrTexture* texture;
00156 };
00157
00158
00159 #endif