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
00033 #ifndef KYRA_TILERESOURCE_INCLUDED
00034 #define KYRA_TILERESOURCE_INCLUDED
00035
00036 #ifdef _MSC_VER
00037
00038 #pragma warning( disable : 4530 )
00039 #pragma warning( disable : 4786 )
00040 #endif
00041
00042 #include <vector>
00043 #include "kyraresource.h"
00044 #include "../engine/krmath.h"
00045 #include "pixelblock.h"
00046
00050 class KrTileResource : public KrResource
00051 {
00052 public:
00053
00054 KrTileResource( U32 size, SDL_RWops* data );
00055
00056 KrTileResource( const std::string& name,
00057 KrPaintInfo* surface,
00058 int x, int y, int size );
00059
00060 virtual ~KrTileResource();
00061
00062 virtual U32 Type() { return KYRATAG_TILE; }
00063 virtual const std::string& TypeName() { return tileName; }
00064 virtual KrTileResource* ToTileResource(){ return this; }
00065
00067 int Size() const { return pixelBlock[0]->Width(); }
00069 bool Alpha() { return pixelBlock[0]->Alpha(); }
00070
00071
00072 void Draw( KrPaintInfo* paintInfo,
00073 const KrMatrix2& matrix,
00074 int rotation,
00075 const KrColorTransform& cForm,
00076 const grinliz::Rectangle2I& clipping,
00077 int quality );
00078
00079
00080
00081
00082
00083 bool HitTestTransformed( int rotation, int x, int y, int hitFlags );
00084
00085 void CalculateBounds( const KrMatrix2&, grinliz::Rectangle2I* bounds ) const;
00086
00087 virtual void CacheScale( GlFixed xScale, GlFixed yScale );
00088 virtual bool IsScaleCached( GlFixed xScale, GlFixed yScale );
00089 virtual void FreeScaleCache();
00090
00091 virtual void Save( KrEncoder* );
00092
00093 KrRGBA* GetPixels(const int nRotation, int& nPitchX, int& nPitchY);
00094
00095 private:
00096 struct CachedBlock
00097 {
00098 GlFixed xScale,
00099 yScale;
00100 KrPixelBlock* pixelBlock;
00101
00102 bool operator==( const CachedBlock& rhs ) { GLASSERT( 0 ); return false; }
00103 };
00104 std::vector< CachedBlock > cache;
00105
00106 void CalcSourceAndPitch( KrPixelBlock* pblock, int rotation, KrRGBA** source, int* sPitchX, int* sPitchY );
00107
00108 static const std::string tileName;
00109 KrPixelBlock* pixelBlock[4];
00110 };
00111
00112
00113 #endif