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_CANVASRESOURCE_INCLUDED
00034 #define KYRA_CANVASRESOURCE_INCLUDED
00035
00036
00037 #ifdef _MSC_VER
00038
00039 #pragma warning( disable : 4530 )
00040 #pragma warning( disable : 4786 )
00041 #endif
00042
00043 #include <vector>
00044
00045 #include "kyraresource.h"
00046 #include "../engine/krmath.h"
00047 #include "../util/glcirclelist.h"
00048 #include "pixelblock.h"
00049
00050 class KrCanvas;
00051
00055 class KrCanvasResource : public KrResource
00056 {
00057 public:
00076 KrCanvasResource( const std::string& name,
00077 int width,
00078 int height,
00079 int alphaSupport );
00080
00081 virtual ~KrCanvasResource();
00082
00083 virtual U32 Type() { return KYRATAG_CANVAS; }
00084 virtual const std::string& TypeName() { return canvasName; }
00085 virtual KrCanvasResource* ToCanvasResource(){ return this; }
00086
00087 int Width() { return pixelBlock.Width(); }
00088 int Height() { return pixelBlock.Height(); }
00089 KrRGBA* Pixels() { return pixelBlock.Pixels(); }
00090 int Alpha() { return pixelBlock.Alpha(); }
00091
00092
00093
00094
00095
00096
00097
00098
00099 void Draw( KrPaintInfo* paintInfo,
00100 const KrMatrix2& matrix,
00101 const KrColorTransform& cForm,
00102 const grinliz::Rectangle2I& clipping,
00103 int quality );
00104
00109 void Refresh();
00110
00111
00112
00113
00114
00115 bool HitTestTransformed( int x, int y, int hitFlags );
00116
00117 void CalculateBounds( const KrMatrix2& xForm, grinliz::Rectangle2I* bounds ) const;
00118
00119
00120 virtual void CacheScale( GlFixed xScale, GlFixed yScale ) {}
00121 virtual bool IsScaleCached( GlFixed xScale, GlFixed yScale ) { return false; }
00122 virtual void FreeScaleCache() {}
00123
00124
00125 virtual KrCollisionMap* GetCollisionMap( KrImage* state, int window );
00126
00127
00128 void AddCanvas( KrCanvas* canvas );
00129 void RemoveCanvas( KrCanvas* canvas );
00130
00131 private:
00132 static const std::string canvasName;
00133 static int canvasId;
00134
00135 KrPixelBlock pixelBlock;
00136 int numClients;
00137 GlCircleList<KrCanvas*> clients;
00138 std::vector<KrCollisionMap*> collisionMaps;
00139 };
00140
00141
00142 #endif