00001
00002
00003 #ifndef _CLUTTERMM_TEXTURE_H
00004 #define _CLUTTERMM_TEXTURE_H
00005
00006
00007 #include <glibmm.h>
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <cluttermm/actor.h>
00027 #include <cluttermm/types.h>
00028 #include <gdkmm/pixbuf.h>
00029
00030
00031 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00032 typedef struct _ClutterTexture ClutterTexture;
00033 typedef struct _ClutterTextureClass ClutterTextureClass;
00034 #endif
00035
00036
00037 namespace Clutter
00038 { class Texture_Class; }
00039 namespace Clutter
00040 {
00041
00055 enum TextureFlags
00056 {
00057 TEXTURE_RGB_FLAG_BGR = 1 << 1,
00058 TEXTURE_RGB_FLAG_PREMULT = 1 << 2,
00059 TEXTURE_YUV_FLAG_YUV2 = 1 << 3
00060 };
00061
00063 inline TextureFlags operator|(TextureFlags lhs, TextureFlags rhs)
00064 { return static_cast<TextureFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
00065
00067 inline TextureFlags operator&(TextureFlags lhs, TextureFlags rhs)
00068 { return static_cast<TextureFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
00069
00071 inline TextureFlags operator^(TextureFlags lhs, TextureFlags rhs)
00072 { return static_cast<TextureFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
00073
00075 inline TextureFlags operator~(TextureFlags flags)
00076 { return static_cast<TextureFlags>(~static_cast<unsigned>(flags)); }
00077
00079 inline TextureFlags& operator|=(TextureFlags& lhs, TextureFlags rhs)
00080 { return (lhs = static_cast<TextureFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
00081
00083 inline TextureFlags& operator&=(TextureFlags& lhs, TextureFlags rhs)
00084 { return (lhs = static_cast<TextureFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
00085
00087 inline TextureFlags& operator^=(TextureFlags& lhs, TextureFlags rhs)
00088 { return (lhs = static_cast<TextureFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
00089
00090
00093 class TextureError : public Glib::Error
00094 {
00095 public:
00096 enum Code
00097 {
00098 OUT_OF_MEMORY,
00099 NO_YUV
00100 };
00101
00102 TextureError(Code error_code, const Glib::ustring& error_message);
00103 explicit TextureError(GError* gobject);
00104 Code code() const;
00105
00106 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00107 private:
00108
00109 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00110 static void throw_func(GError* gobject);
00111 #else
00112
00113 static std::auto_ptr<Glib::Error> throw_func(GError* gobject);
00114 #endif //GLIBMM_EXCEPTIONS_ENABLED
00115
00116 friend void wrap_init();
00117 #endif
00118 };
00119
00120 }
00121
00122 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00123 namespace Glib
00124 {
00125
00126 template <>
00127 class Value<Clutter::TextureError::Code> : public Glib::Value_Enum<Clutter::TextureError::Code>
00128 {
00129 public:
00130 static GType value_type() G_GNUC_CONST;
00131 };
00132
00133 }
00134 #endif
00135
00136
00137 namespace Clutter
00138 {
00139
00140
00141 class Texture :
00142 public Actor
00143 {
00144
00145 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00146
00147 public:
00148 typedef Texture CppObjectType;
00149 typedef Texture_Class CppClassType;
00150 typedef ClutterTexture BaseObjectType;
00151 typedef ClutterTextureClass BaseClassType;
00152
00153 private: friend class Texture_Class;
00154 static CppClassType texture_class_;
00155
00156 private:
00157
00158 Texture(const Texture&);
00159 Texture& operator=(const Texture&);
00160
00161 protected:
00162 explicit Texture(const Glib::ConstructParams& construct_params);
00163 explicit Texture(ClutterTexture* castitem);
00164
00165 #endif
00166
00167 public:
00168 virtual ~Texture();
00169
00170 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00171 static GType get_type() G_GNUC_CONST;
00172 static GType get_base_type() G_GNUC_CONST;
00173 #endif
00174
00176 ClutterTexture* gobj() { return reinterpret_cast<ClutterTexture*>(gobject_); }
00177
00179 const ClutterTexture* gobj() const { return reinterpret_cast<ClutterTexture*>(gobject_); }
00180
00182 ClutterTexture* gobj_copy();
00183
00184 private:
00185
00186
00187 protected:
00188 Texture();
00189 explicit Texture(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
00190
00191 public:
00192
00193
00194 static Glib::RefPtr<Texture> create();
00195
00196
00197 static Glib::RefPtr<Texture> create(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
00198 ;
00199
00200
00208 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00209 bool set_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
00210 #else
00211 bool set_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, std::auto_ptr<Glib::Error>& error);
00212 #endif //GLIBMM_EXCEPTIONS_ENABLED
00213
00214
00219 Glib::RefPtr<Gdk::Pixbuf> get_pixbuf() const;
00220
00225 void get_base_size(gint& width, gint& height) const;
00226
00241 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00242 bool set_from_rgb_data(const guchar* data, bool has_alpha, int width, int height, int rowstride, int bpp, TextureFlags flags);
00243 #else
00244 bool set_from_rgb_data(const guchar* data, bool has_alpha, int width, int height, int rowstride, int bpp, TextureFlags flags, std::auto_ptr<Glib::Error>& error);
00245 #endif //GLIBMM_EXCEPTIONS_ENABLED
00246
00247
00260 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00261 bool set_from_yuv_data(const guchar* data, int width, int height, TextureFlags flags);
00262 #else
00263 bool set_from_yuv_data(const guchar* data, int width, int height, TextureFlags flags, std::auto_ptr<Glib::Error>& error);
00264 #endif //GLIBMM_EXCEPTIONS_ENABLED
00265
00266
00272 Glib::SignalProxy2< void,gint,gint > signal_size_change();
00273
00274
00280 Glib::SignalProxy0< void > signal_pixbuf_change();
00281
00282
00283 protected:
00284
00291 bool is_tiled() const;
00292
00300 void get_n_tiles(gint& n_x_tiles, gint& n_y_tiles);
00301
00311 void get_y_tile_detail(int y_index, int& pos, int& size, int& waste) const;
00312
00322 void get_x_tile_detail(int x_index, int& pos, int& size, int& waste) const;
00323
00330 bool has_generated_tiles() const;
00331
00338 void bind_tile(int index);
00339
00340
00341 public:
00342
00343 public:
00344
00345 #ifdef GLIBMM_VFUNCS_ENABLED
00346 #endif //GLIBMM_VFUNCS_ENABLED
00347
00348 protected:
00349
00350 #ifdef GLIBMM_VFUNCS_ENABLED
00351 #endif //GLIBMM_VFUNCS_ENABLED
00352
00353
00354 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00355 virtual void on_size_change(gint width, gint height);
00356 virtual void on_pixbuf_change();
00357 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00358
00359
00360 };
00361
00362 }
00363
00364
00365
00366
00367 namespace Glib
00368 {
00377 Glib::RefPtr<Clutter::Texture> wrap(ClutterTexture* object, bool take_copy = false);
00378 }
00379
00380
00381 #endif
00382