00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef header_dynamic_provider
00022 #define header_dynamic_provider
00023
00024 #include "generic_surfaceprovider.h"
00025
00026 class CL_DynamicProvider : public CL_SurfaceProvider_Generic
00027 {
00028 public:
00029
00030 static CL_Surface *create(int width, int height, int no_sprs, EPixelFormat type = PAL8, int transcol = -1)
00031 {
00032 return CL_Surface::create(new CL_DynamicProvider(width, height, no_sprs, type, transcol), true);
00033 }
00034
00035 static CL_Surface *create(int width, int height, int no_sprs, int red_mask, int green_mask, int blue_mask,
00036 int alpha_mask, int transcol = -1)
00037 {
00038 return CL_Surface::create(new CL_DynamicProvider(width, height, no_sprs, red_mask, green_mask,
00039 blue_mask, alpha_mask, transcol), true);
00040 }
00041
00042 CL_DynamicProvider(int width, int height, int no_sprs, EPixelFormat type = PAL8, int trans_col = -1)
00043 {
00044 this->width = width;
00045 this->height = height;
00046 this->no_sprs = no_sprs;
00047 this->trans_col = trans_col;
00048 data = NULL;
00049 pixelformat = type;
00050 bpp = get_bytes_pr_pixel();
00051 data = new unsigned char[width * height * no_sprs * bpp];
00052
00053 }
00054
00055
00056 CL_DynamicProvider(int width, int height, int no_sprs, int red_mask, int green_mask, int blue_mask,
00057 int alpha_mask, int transcol = -1)
00058 {
00059 this->width = width;
00060 this->height = height;
00061 this->no_sprs = no_sprs;
00062 this->trans_col = trans_col;
00063 this->red_mask = red_mask;
00064 this->green_mask = green_mask;
00065 this->blue_mask = blue_mask;
00066 this->alpha_mask = alpha_mask;
00067
00068 data = NULL;
00069 pixelformat = CUSTOM;
00070 bpp = get_bytes_pr_pixel();
00071
00072 data = new unsigned char[width * height * no_sprs * bpp];
00073
00074 }
00075
00076
00077 virtual ~CL_DynamicProvider() { delete[] data; }
00078
00079
00080
00081 virtual int get_width() const { return width; }
00082 virtual int get_height() const { return height; }
00083 virtual int get_no_sprs() const { return no_sprs; }
00084 virtual EPixelFormat get_pixel_format() const { return pixelformat; }
00085
00086
00087 virtual CL_Palette *get_palette() const { return NULL; }
00088
00089
00090 virtual int get_transcol() const { return trans_col; }
00091
00092
00093 virtual void *get_data() const { cl_assert(data!=NULL); return data; }
00094
00095
00096
00097
00098 virtual void perform_lock() { }
00099 virtual void perform_unlock() { }
00100
00101 private:
00102
00103 int width, height, no_sprs, trans_col;
00104 int red_mask, green_mask, blue_mask, alpha_mask;
00105 EPixelFormat pixelformat;
00106 unsigned char *data;
00107 int bpp;
00108 };
00109
00110 #endif