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 <clutter/clutter.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_NONE = 0,
00058 TEXTURE_RGB_FLAG_BGR = 1 << 1,
00059 TEXTURE_RGB_FLAG_PREMULT = 1 << 2,
00060 TEXTURE_YUV_FLAG_YUV2 = 1 << 3
00061 };
00062
00064 inline TextureFlags operator|(TextureFlags lhs, TextureFlags rhs)
00065 { return static_cast<TextureFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
00066
00068 inline TextureFlags operator&(TextureFlags lhs, TextureFlags rhs)
00069 { return static_cast<TextureFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
00070
00072 inline TextureFlags operator^(TextureFlags lhs, TextureFlags rhs)
00073 { return static_cast<TextureFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
00074
00076 inline TextureFlags operator~(TextureFlags flags)
00077 { return static_cast<TextureFlags>(~static_cast<unsigned>(flags)); }
00078
00080 inline TextureFlags& operator|=(TextureFlags& lhs, TextureFlags rhs)
00081 { return (lhs = static_cast<TextureFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
00082
00084 inline TextureFlags& operator&=(TextureFlags& lhs, TextureFlags rhs)
00085 { return (lhs = static_cast<TextureFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
00086
00088 inline TextureFlags& operator^=(TextureFlags& lhs, TextureFlags rhs)
00089 { return (lhs = static_cast<TextureFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
00090
00091 }
00092
00093
00094 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00095 namespace Glib
00096 {
00097
00098 template <>
00099 class Value<Clutter::TextureFlags> : public Glib::Value_Flags<Clutter::TextureFlags>
00100 {
00101 public:
00102 static GType value_type() G_GNUC_CONST;
00103 };
00104
00105 }
00106 #endif
00107
00108
00109 namespace Clutter
00110 {
00111
00115 enum TextureQuality
00116 {
00117 TEXTURE_QUALITY_LOW,
00118 TEXTURE_QUALITY_MEDIUM,
00119 TEXTURE_QUALITY_HIGH
00120 };
00121
00122 }
00123
00124
00125 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00126 namespace Glib
00127 {
00128
00129 template <>
00130 class Value<Clutter::TextureQuality> : public Glib::Value_Enum<Clutter::TextureQuality>
00131 {
00132 public:
00133 static GType value_type() G_GNUC_CONST;
00134 };
00135
00136 }
00137 #endif
00138
00139
00140 namespace Clutter
00141 {
00142
00143
00146 class TextureError : public Glib::Error
00147 {
00148 public:
00149 enum Code
00150 {
00151 OUT_OF_MEMORY,
00152 NO_YUV,
00153 BAD_FORMAT
00154 };
00155
00156 TextureError(Code error_code, const Glib::ustring& error_message);
00157 explicit TextureError(GError* gobject);
00158 Code code() const;
00159
00160 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00161 private:
00162
00163 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00164 static void throw_func(GError* gobject);
00165 #else
00166
00167 static std::auto_ptr<Glib::Error> throw_func(GError* gobject);
00168 #endif //GLIBMM_EXCEPTIONS_ENABLED
00169
00170 friend void wrap_init();
00171 #endif
00172 };
00173
00174 }
00175
00176 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00177 namespace Glib
00178 {
00179
00180 template <>
00181 class Value<Clutter::TextureError::Code> : public Glib::Value_Enum<Clutter::TextureError::Code>
00182 {
00183 public:
00184 static GType value_type() G_GNUC_CONST;
00185 };
00186
00187 }
00188 #endif
00189
00190
00191 namespace Clutter
00192 {
00193
00194
00195 class Texture : public Actor
00196 {
00197
00198 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00199
00200 public:
00201 typedef Texture CppObjectType;
00202 typedef Texture_Class CppClassType;
00203 typedef ClutterTexture BaseObjectType;
00204 typedef ClutterTextureClass BaseClassType;
00205
00206 private: friend class Texture_Class;
00207 static CppClassType texture_class_;
00208
00209 private:
00210
00211 Texture(const Texture&);
00212 Texture& operator=(const Texture&);
00213
00214 protected:
00215 explicit Texture(const Glib::ConstructParams& construct_params);
00216 explicit Texture(ClutterTexture* castitem);
00217
00218 #endif
00219
00220 public:
00221 virtual ~Texture();
00222
00223 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00224 static GType get_type() G_GNUC_CONST;
00225 static GType get_base_type() G_GNUC_CONST;
00226 #endif
00227
00229 ClutterTexture* gobj() { return reinterpret_cast<ClutterTexture*>(gobject_); }
00230
00232 const ClutterTexture* gobj() const { return reinterpret_cast<ClutterTexture*>(gobject_); }
00233
00235 ClutterTexture* gobj_copy();
00236
00237 private:
00238
00239
00240 protected:
00241 Texture();
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 public:
00253
00254
00255 static Glib::RefPtr<Texture> create();
00256
00257 static Glib::RefPtr<Texture> create_from_file(const std::string& filename);
00258
00259
00260
00275 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00276 bool set_from_file(const std::string& filename);
00277 #else
00278 bool set_from_file(const std::string& filename, std::auto_ptr<Glib::Error>& error);
00279 #endif //GLIBMM_EXCEPTIONS_ENABLED
00280
00281
00295 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00296 bool set_from_rgb_data(const guchar* data, bool has_alpha, int width, int height, int rowstride, int bpp, TextureFlags flags);
00297 #else
00298 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);
00299 #endif //GLIBMM_EXCEPTIONS_ENABLED
00300
00301
00312 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00313 bool set_from_yuv_data(const guchar* data, int width, int height, TextureFlags flags);
00314 #else
00315 bool set_from_yuv_data(const guchar* data, int width, int height, TextureFlags flags, std::auto_ptr<Glib::Error>& error);
00316 #endif //GLIBMM_EXCEPTIONS_ENABLED
00317
00318
00334 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00335 bool set_area_from_rgb_data(const guchar* data, bool has_alpha, int x, int y, int width, int height, int rowstride, int bpp, TextureFlags flags);
00336 #else
00337 bool set_area_from_rgb_data(const guchar* data, bool has_alpha, int x, int y, int width, int height, int rowstride, int bpp, TextureFlags flags, std::auto_ptr<Glib::Error>& error);
00338 #endif //GLIBMM_EXCEPTIONS_ENABLED
00339
00340
00345 void get_base_size(int& width, int& height) const;
00346
00347
00361 CoglPixelFormat get_pixel_format() const;
00362
00363
00369 TextureQuality get_filter_quality() const;
00370
00383 void set_filter_quality(TextureQuality filter_quality);
00384
00385
00393 int get_amx_tile_waste() const;
00394
00395
00396
00397
00410 CoglHandle get_cogl_texture() const;
00411
00425 void set_cogl_texture(CoglHandle handle);
00426
00430 CoglHandle get_cogl_material() const;
00431
00439 void set_cogl_material(CoglHandle handle);
00440
00441
00448 bool get_sync_size() const;
00449
00457 void set_sync_size(bool sync_size=true);
00458
00459
00467 void get_repeat(bool& repeat_x, bool& repeat_y) const;
00468
00476 void set_repeat(bool repeat_x=true, bool repeat_y=true);
00477
00478
00485 bool get_keep_aspect_ratio() const;
00486
00493 void set_keep_aspect_ratio(bool keep_aspect=true);
00494
00495
00502 bool get_load_async() const;
00503
00515 void set_load_async(bool load_async=true);
00516
00517
00524 bool get_load_data_async() const;
00525
00538 void set_load_data_async(bool load_async=true);
00539
00540
00541
00542
00548 Glib::SignalProxy2< void,int,int > signal_size_change();
00549
00550
00556 Glib::SignalProxy0< void > signal_pixbuf_change();
00557
00558
00559
00560 #ifdef GLIBMM_PROPERTIES_ENABLED
00561
00567 Glib::PropertyProxy<CoglHandle> property_cogl_texture() ;
00568 #endif //#GLIBMM_PROPERTIES_ENABLED
00569
00570 #ifdef GLIBMM_PROPERTIES_ENABLED
00571
00577 Glib::PropertyProxy_ReadOnly<CoglHandle> property_cogl_texture() const;
00578 #endif //#GLIBMM_PROPERTIES_ENABLED
00579
00580 #ifdef GLIBMM_PROPERTIES_ENABLED
00581
00587 Glib::PropertyProxy_ReadOnly<bool> property_disable_slicing() const;
00588 #endif //#GLIBMM_PROPERTIES_ENABLED
00589
00590
00591 #ifdef GLIBMM_PROPERTIES_ENABLED
00592
00598 Glib::PropertyProxy_WriteOnly<std::string> property_filename() ;
00599 #endif //#GLIBMM_PROPERTIES_ENABLED
00600
00601
00602 #ifdef GLIBMM_PROPERTIES_ENABLED
00603
00609 Glib::PropertyProxy<TextureQuality> property_filter_quality() ;
00610 #endif //#GLIBMM_PROPERTIES_ENABLED
00611
00612 #ifdef GLIBMM_PROPERTIES_ENABLED
00613
00619 Glib::PropertyProxy_ReadOnly<TextureQuality> property_filter_quality() const;
00620 #endif //#GLIBMM_PROPERTIES_ENABLED
00621
00622 #ifdef GLIBMM_PROPERTIES_ENABLED
00623
00629 Glib::PropertyProxy<bool> property_keep_aspect_ratio() ;
00630 #endif //#GLIBMM_PROPERTIES_ENABLED
00631
00632 #ifdef GLIBMM_PROPERTIES_ENABLED
00633
00639 Glib::PropertyProxy_ReadOnly<bool> property_keep_aspect_ratio() const;
00640 #endif //#GLIBMM_PROPERTIES_ENABLED
00641
00642 #ifdef GLIBMM_PROPERTIES_ENABLED
00643
00649 Glib::PropertyProxy_WriteOnly<bool> property_load_async() ;
00650 #endif //#GLIBMM_PROPERTIES_ENABLED
00651
00652
00653 #ifdef GLIBMM_PROPERTIES_ENABLED
00654
00660 Glib::PropertyProxy_WriteOnly<bool> property_load_data_async() ;
00661 #endif //#GLIBMM_PROPERTIES_ENABLED
00662
00663
00664 #ifdef GLIBMM_PROPERTIES_ENABLED
00665
00671 Glib::PropertyProxy_ReadOnly<int> property_pixel_format() const;
00672 #endif //#GLIBMM_PROPERTIES_ENABLED
00673
00674
00675 #ifdef GLIBMM_PROPERTIES_ENABLED
00676
00682 Glib::PropertyProxy<bool> property_repeat_x() ;
00683 #endif //#GLIBMM_PROPERTIES_ENABLED
00684
00685 #ifdef GLIBMM_PROPERTIES_ENABLED
00686
00692 Glib::PropertyProxy_ReadOnly<bool> property_repeat_x() const;
00693 #endif //#GLIBMM_PROPERTIES_ENABLED
00694
00695 #ifdef GLIBMM_PROPERTIES_ENABLED
00696
00702 Glib::PropertyProxy<bool> property_repeat_y() ;
00703 #endif //#GLIBMM_PROPERTIES_ENABLED
00704
00705 #ifdef GLIBMM_PROPERTIES_ENABLED
00706
00712 Glib::PropertyProxy_ReadOnly<bool> property_repeat_y() const;
00713 #endif //#GLIBMM_PROPERTIES_ENABLED
00714
00715 #ifdef GLIBMM_PROPERTIES_ENABLED
00716
00722 Glib::PropertyProxy<bool> property_sync_size() ;
00723 #endif //#GLIBMM_PROPERTIES_ENABLED
00724
00725 #ifdef GLIBMM_PROPERTIES_ENABLED
00726
00732 Glib::PropertyProxy_ReadOnly<bool> property_sync_size() const;
00733 #endif //#GLIBMM_PROPERTIES_ENABLED
00734
00735 #ifdef GLIBMM_PROPERTIES_ENABLED
00736
00742 Glib::PropertyProxy_ReadOnly<int> property_tile_waste() const;
00743 #endif //#GLIBMM_PROPERTIES_ENABLED
00744
00745
00746 public:
00747
00748 public:
00749
00750 #ifdef GLIBMM_VFUNCS_ENABLED
00751 #endif //GLIBMM_VFUNCS_ENABLED
00752
00753 protected:
00754
00755 #ifdef GLIBMM_VFUNCS_ENABLED
00756 #endif //GLIBMM_VFUNCS_ENABLED
00757
00758
00759 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00760 virtual void on_size_change(int width, int height);
00761 virtual void on_pixbuf_change();
00762 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00763
00764
00765 };
00766
00767 }
00768
00769
00770 namespace Glib
00771 {
00780 Glib::RefPtr<Clutter::Texture> wrap(ClutterTexture* object, bool take_copy = false);
00781 }
00782
00783
00784 #endif
00785