CCTexture2D.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /****************************************************************************
  2. Copyright (c) 2008 Apple Inc. All Rights Reserved.
  3. Copyright (c) 2010-2012 cocos2d-x.org
  4. Copyright (c) 2013-2016 Chukong Technologies Inc.
  5. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  6. http://www.cocos2d-x.org
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. ****************************************************************************/
  23. #ifndef __CCTEXTURE2D_H__
  24. #define __CCTEXTURE2D_H__
  25. #include <string>
  26. #include <map>
  27. #include <unordered_map>
  28. #include "base/CCRef.h"
  29. #include "math/CCGeometry.h"
  30. #include "base/ccTypes.h"
  31. NS_CC_BEGIN
  32. class Image;
  33. class NinePatchInfo;
  34. class SpriteFrame;
  35. typedef struct _MipmapInfo MipmapInfo;
  36. namespace ui
  37. {
  38. class Scale9Sprite;
  39. }
  40. /**
  41. * @addtogroup _2d
  42. * @{
  43. */
  44. //CONSTANTS:
  45. class GLProgram;
  46. //CLASS INTERFACES:
  47. /**
  48. * @brief Texture2D class. This class allows to easily create OpenGL 2D textures from images, text or raw data.
  49. * The created Texture2D object will always have power-of-two dimensions.
  50. * Depending on how you create the Texture2D object, the actual image area of the texture might be smaller than the texture dimensions i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0).
  51. * Be aware that the content of the generated textures will be upside-down!
  52. */
  53. class CC_DLL Texture2D : public Ref
  54. {
  55. public:
  56. /** @typedef Texture2D::PixelFormat
  57. Possible texture pixel formats
  58. */
  59. enum class PixelFormat
  60. {
  61. //! auto detect the type
  62. AUTO,
  63. //! 32-bit texture: BGRA8888
  64. BGRA8888,
  65. //! 32-bit texture: RGBA8888
  66. RGBA8888,
  67. //! 24-bit texture: RGBA888
  68. RGB888,
  69. //! 16-bit texture without Alpha channel
  70. RGB565,
  71. //! 8-bit textures used as masks
  72. A8,
  73. //! 8-bit intensity texture
  74. I8,
  75. //! 16-bit textures used as masks
  76. AI88,
  77. //! 16-bit textures: RGBA4444
  78. RGBA4444,
  79. //! 16-bit textures: RGB5A1
  80. RGB5A1,
  81. //! 4-bit PVRTC-compressed texture: PVRTC4
  82. PVRTC4,
  83. //! 4-bit PVRTC-compressed texture: PVRTC4 (has alpha channel)
  84. PVRTC4A,
  85. //! 2-bit PVRTC-compressed texture: PVRTC2
  86. PVRTC2,
  87. //! 2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel)
  88. PVRTC2A,
  89. //! ETC-compressed texture: ETC
  90. ETC,
  91. //! S3TC-compressed texture: S3TC_Dxt1
  92. S3TC_DXT1,
  93. //! S3TC-compressed texture: S3TC_Dxt3
  94. S3TC_DXT3,
  95. //! S3TC-compressed texture: S3TC_Dxt5
  96. S3TC_DXT5,
  97. //! ATITC-compressed texture: ATC_RGB
  98. ATC_RGB,
  99. //! ATITC-compressed texture: ATC_EXPLICIT_ALPHA
  100. ATC_EXPLICIT_ALPHA,
  101. //! ATITC-compressed texture: ATC_INTERPOLATED_ALPHA
  102. ATC_INTERPOLATED_ALPHA,
  103. //! Default texture format: AUTO
  104. DEFAULT = AUTO,
  105. NONE = -1
  106. };
  107. struct PixelFormatInfo {
  108. PixelFormatInfo(GLenum anInternalFormat, GLenum aFormat, GLenum aType, int aBpp, bool aCompressed, bool anAlpha)
  109. : internalFormat(anInternalFormat)
  110. , format(aFormat)
  111. , type(aType)
  112. , bpp(aBpp)
  113. , compressed(aCompressed)
  114. , alpha(anAlpha)
  115. {}
  116. GLenum internalFormat;
  117. GLenum format;
  118. GLenum type;
  119. int bpp;
  120. bool compressed;
  121. bool alpha;
  122. };
  123. typedef std::map<Texture2D::PixelFormat, const PixelFormatInfo> PixelFormatInfoMap;
  124. /**
  125. Extension to set the Min / Mag filter
  126. */
  127. typedef struct _TexParams {
  128. GLuint minFilter;
  129. GLuint magFilter;
  130. GLuint wrapS;
  131. GLuint wrapT;
  132. }TexParams;
  133. public:
  134. /** sets the default pixel format for UIImagescontains alpha channel.
  135. @param format
  136. If the UIImage contains alpha channel, then the options are:
  137. - generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one)
  138. - generate 24-bit textures: Texture2D::PixelFormat::RGB888
  139. - generate 16-bit textures: Texture2D::PixelFormat::RGBA4444
  140. - generate 16-bit textures: Texture2D::PixelFormat::RGB5A1
  141. - generate 16-bit textures: Texture2D::PixelFormat::RGB565
  142. - generate 8-bit textures: Texture2D::PixelFormat::A8 (only use it if you use just 1 color)
  143. How does it work ?
  144. - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture)
  145. - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.
  146. This parameter is not valid for PVR / PVR.CCZ images.
  147. @since v0.8
  148. */
  149. static void setDefaultAlphaPixelFormat(Texture2D::PixelFormat format);
  150. /** Returns the alpha pixel format.
  151. @since v0.8
  152. */
  153. static Texture2D::PixelFormat getDefaultAlphaPixelFormat();
  154. CC_DEPRECATED_ATTRIBUTE static Texture2D::PixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); };
  155. /** Treats (or not) PVR files as if they have alpha premultiplied.
  156. @param haveAlphaPremultiplied
  157. Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
  158. possible load them as if they have (or not) the alpha channel premultiplied.
  159. By default it is disabled.
  160. deprecated, please use Image::setPVRImagesHavePremultipliedAlpha() instead.
  161. @since v0.99.5
  162. */
  163. CC_DEPRECATED_ATTRIBUTE static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
  164. public:
  165. /**
  166. * @js ctor
  167. */
  168. Texture2D();
  169. /**
  170. * @js NA
  171. * @lua NA
  172. */
  173. virtual ~Texture2D();
  174. /**
  175. Get texture name, dimensions and coordinates message by a string.
  176. * @js NA
  177. * @lua NA
  178. */
  179. virtual std::string getDescription() const;
  180. /** Release only the gl texture.
  181. * @js NA
  182. * @lua NA
  183. */
  184. void releaseGLTexture();
  185. /** Initializes with a texture2d with data.
  186. @param data Specifies a pointer to the image data in memory.
  187. @param dataLen The image data length.
  188. @param pixelFormat The image pixelFormat.
  189. @param pixelsWide The image width.
  190. @param pixelsHigh The image height.
  191. @param contentSize The image content size.
  192. * @js NA
  193. * @lua NA
  194. */
  195. bool initWithData(const void *data, ssize_t dataLen, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize);
  196. /** Initializes with mipmaps.
  197. @param mipmaps Specifies a pointer to the image data in memory.
  198. @param mipmapsNum The mipmaps number.
  199. @param pixelFormat The image pixelFormat.
  200. @param pixelsWide The image width.
  201. @param pixelsHigh The image height.
  202. */
  203. bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh);
  204. /** Update with texture data.
  205. @param data Specifies a pointer to the image data in memory.
  206. @param offsetX Specifies a texel offset in the x direction within the texture array.
  207. @param offsetY Specifies a texel offset in the y direction within the texture array.
  208. @param width Specifies the width of the texture subimage.
  209. @param height Specifies the height of the texture subimage.
  210. */
  211. bool updateWithData(const void *data,int offsetX,int offsetY,int width,int height);
  212. /**
  213. Drawing extensions to make it easy to draw basic quads using a Texture2D object.
  214. These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.
  215. */
  216. /** Draws a texture at a given point. */
  217. void drawAtPoint(const Vec2& point);
  218. /** Draws a texture inside a rect.*/
  219. void drawInRect(const Rect& rect);
  220. /**
  221. Extensions to make it easy to create a Texture2D object from an image file.
  222. */
  223. /**
  224. Initializes a texture from a UIImage object.
  225. We will use the format you specified with setDefaultAlphaPixelFormat to convert the image for texture.
  226. NOTE: It will not convert the pvr image file.
  227. @param image An UIImage object.
  228. */
  229. bool initWithImage(Image * image);
  230. /**
  231. Initializes a texture from a UIImage object.
  232. We will use the format you passed to the function to convert the image format to the texture format.
  233. If you pass PixelFormat::Automatic, we will auto detect the image render type and use that type for texture to render.
  234. @param image An UIImage object.
  235. @param format Texture pixel formats.
  236. **/
  237. bool initWithImage(Image * image, PixelFormat format);
  238. /** Initializes a texture from a string with dimensions, alignment, font name and font size.
  239. @param text A null terminated string.
  240. @param fontName The font name.
  241. @param fontSize The font size.
  242. @param dimensions The font dimension.
  243. @param hAlignment The font horizontal text alignment type.
  244. @param vAlignment The font vertical text alignment type.
  245. @param enableWrap Whether enable text wrap or not.
  246. @param overflow Whether shrink font size when content larger than the dimensions.
  247. */
  248. bool initWithString(const char *text, const std::string &fontName, float fontSize, const Size& dimensions = Size(0, 0), TextHAlignment hAlignment = TextHAlignment::CENTER, TextVAlignment vAlignment = TextVAlignment::TOP, bool enableWrap = true, int overflow = 0);
  249. /** Initializes a texture from a string using a text definition.
  250. @param text A null terminated string.
  251. @param textDefinition A FontDefinition object contains font attributes.
  252. */
  253. bool initWithString(const char *text, const FontDefinition& textDefinition);
  254. /** Sets the min filter, mag filter, wrap s and wrap t texture parameters.
  255. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
  256. @warning Calling this method could allocate additional texture memory.
  257. @since v0.8
  258. * @code
  259. * When this function bound into js or lua,the input parameter will be changed
  260. * In js: var setBlendFunc(var arg1, var arg2, var arg3, var arg4)
  261. * In lua: local setBlendFunc(local arg1, local arg2, local arg3, local arg4)
  262. * @endcode
  263. */
  264. void setTexParameters(const TexParams& texParams);
  265. /**
  266. * @js NA
  267. * @lua NA
  268. */
  269. CC_DEPRECATED_ATTRIBUTE void setTexParameters(const TexParams* texParams) { return setTexParameters(*texParams); };
  270. /** Sets antialias texture parameters:
  271. - GL_TEXTURE_MIN_FILTER = GL_LINEAR
  272. - GL_TEXTURE_MAG_FILTER = GL_LINEAR
  273. @warning Calling this method could allocate additional texture memory.
  274. @since v0.8
  275. */
  276. void setAntiAliasTexParameters();
  277. /** Sets alias texture parameters:
  278. - GL_TEXTURE_MIN_FILTER = GL_NEAREST
  279. - GL_TEXTURE_MAG_FILTER = GL_NEAREST
  280. @warning Calling this method could allocate additional texture memory.
  281. @since v0.8
  282. */
  283. void setAliasTexParameters();
  284. /** Generates mipmap images for the texture.
  285. It only works if the texture size is POT (power of 2).
  286. @since v0.99.0
  287. */
  288. void generateMipmap();
  289. /** Returns the pixel format.
  290. @since v2.0
  291. */
  292. const char* getStringForFormat() const;
  293. CC_DEPRECATED_ATTRIBUTE const char* stringForFormat() const { return getStringForFormat(); };
  294. /** Returns the bits-per-pixel of the in-memory OpenGL texture
  295. @since v1.0
  296. */
  297. unsigned int getBitsPerPixelForFormat() const;
  298. CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat() const { return getBitsPerPixelForFormat(); };
  299. /** Helper functions that returns bits per pixels for a given format.
  300. @since v2.0
  301. */
  302. unsigned int getBitsPerPixelForFormat(Texture2D::PixelFormat format) const;
  303. CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2D::PixelFormat format) const { return getBitsPerPixelForFormat(format); };
  304. /** Get content size. */
  305. const Size& getContentSizeInPixels();
  306. /** Whether or not the texture has their Alpha premultiplied. */
  307. bool hasPremultipliedAlpha() const;
  308. /** Whether or not the texture has mip maps.*/
  309. bool hasMipmaps() const;
  310. /** Gets the pixel format of the texture. */
  311. Texture2D::PixelFormat getPixelFormat() const;
  312. /** Gets the width of the texture in pixels. */
  313. int getPixelsWide() const;
  314. /** Gets the height of the texture in pixels. */
  315. int getPixelsHigh() const;
  316. /** Gets the texture name. */
  317. GLuint getName() const;
  318. /** Gets max S. */
  319. GLfloat getMaxS() const;
  320. /** Sets max S. */
  321. void setMaxS(GLfloat maxS);
  322. /** Gets max T. */
  323. GLfloat getMaxT() const;
  324. /** Sets max T. */
  325. void setMaxT(GLfloat maxT);
  326. /** Get the texture content size.*/
  327. Size getContentSize() const;
  328. /** Set a shader program to the texture.
  329. It's used by drawAtPoint and drawInRect
  330. */
  331. void setGLProgram(GLProgram* program);
  332. /** Get a shader program from the texture.*/
  333. GLProgram* getGLProgram() const;
  334. std::string getPath()const { return _filePath; }
  335. void setAlphaTexture(Texture2D* alphaTexture);
  336. Texture2D* getAlphaTexture() const;
  337. GLuint getAlphaTextureName() const;
  338. public:
  339. /** Get pixel info map, the key-value pairs is PixelFormat and PixelFormatInfo.*/
  340. static const PixelFormatInfoMap& getPixelFormatInfoMap();
  341. private:
  342. /**
  343. * A struct for storing 9-patch image capInsets.
  344. */
  345. class NinePatchInfo
  346. {
  347. public:
  348. Rect capInsetSize;
  349. std::unordered_map<SpriteFrame*, Rect> capInsetMap;
  350. };
  351. /**
  352. * Whether the texture contains a 9-patch capInset info or not.
  353. *
  354. * @return True is Texture contains a 9-patch info, false otherwise.
  355. */
  356. bool isContain9PatchInfo()const;
  357. /**
  358. * Get spriteFrame capInset, If spriteFrame can't be found in 9-patch info map,
  359. * then single 9-patch texture capInset will be returned.
  360. * If the arg is nullptr, the capInset of single 9-patch texture will be returned.
  361. *
  362. * @param spriteFrame A SpriteFrame object pointer.
  363. *
  364. * @return The capInset of the SpriteFrame object.
  365. */
  366. const Rect& getSpriteFrameCapInset(SpriteFrame* spriteFrame)const;
  367. /**
  368. * Remove the spriteFrame capInset info when the spriteFrame is removed.
  369. *
  370. * @param spriteFrame A SpriteFrame object pointer.
  371. */
  372. void removeSpriteFrameCapInset(SpriteFrame* spriteFrame);
  373. /**
  374. * Add capInset for sprite atlas.
  375. * When handling single texture, pass nullptr in the first arg.
  376. *
  377. * @param spritframe The sprite frame object.
  378. * @param capInsets The parsed capInset from a .9 patch image.
  379. */
  380. void addSpriteFrameCapInset(SpriteFrame* spritframe, const Rect& capInsets);
  381. /**convert functions*/
  382. /**
  383. Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you.
  384. It will return the converted format to you. if the outData != data, you must delete it manually.
  385. */
  386. static PixelFormat convertDataToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
  387. static PixelFormat convertI8ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
  388. static PixelFormat convertAI88ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
  389. static PixelFormat convertRGB888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
  390. static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
  391. //I8 to XXX
  392. static void convertI8ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  393. static void convertI8ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  394. static void convertI8ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  395. static void convertI8ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  396. static void convertI8ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  397. static void convertI8ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  398. //AI88 to XXX
  399. static void convertAI88ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  400. static void convertAI88ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  401. static void convertAI88ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  402. static void convertAI88ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  403. static void convertAI88ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  404. static void convertAI88ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  405. static void convertAI88ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  406. //RGB888 to XXX
  407. static void convertRGB888ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  408. static void convertRGB888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  409. static void convertRGB888ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  410. static void convertRGB888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  411. static void convertRGB888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  412. static void convertRGB888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  413. static void convertRGB888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  414. //RGBA8888 to XXX
  415. static void convertRGBA8888ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  416. static void convertRGBA8888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  417. static void convertRGBA8888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  418. static void convertRGBA8888ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  419. static void convertRGBA8888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  420. static void convertRGBA8888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  421. static void convertRGBA8888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
  422. protected:
  423. /** pixel format of the texture */
  424. Texture2D::PixelFormat _pixelFormat;
  425. /** width in pixels */
  426. int _pixelsWide;
  427. /** height in pixels */
  428. int _pixelsHigh;
  429. /** texture name */
  430. GLuint _name;
  431. /** texture max S */
  432. GLfloat _maxS;
  433. /** texture max T */
  434. GLfloat _maxT;
  435. /** content size */
  436. Size _contentSize;
  437. /** whether or not the texture has their Alpha premultiplied */
  438. bool _hasPremultipliedAlpha;
  439. /** whether or not the texture has mip maps*/
  440. bool _hasMipmaps;
  441. /** shader program used by drawAtPoint and drawInRect */
  442. GLProgram* _shaderProgram;
  443. static const PixelFormatInfoMap _pixelFormatInfoTables;
  444. bool _antialiasEnabled;
  445. NinePatchInfo* _ninePatchInfo;
  446. friend class SpriteFrameCache;
  447. friend class TextureCache;
  448. friend class ui::Scale9Sprite;
  449. bool _valid;
  450. std::string _filePath;
  451. Texture2D* _alphaTexture;
  452. };
  453. // end of textures group
  454. /// @}
  455. NS_CC_END
  456. #endif //__CCTEXTURE2D_H__