CCGroupCommand.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef _CC_GROUPCOMMAND_H_
  22. #define _CC_GROUPCOMMAND_H_
  23. #include <vector>
  24. #include <unordered_map>
  25. #include "base/CCRef.h"
  26. #include "renderer/CCRenderCommand.h"
  27. /**
  28. * @addtogroup renderer
  29. * @{
  30. */
  31. NS_CC_BEGIN
  32. //Used for internal
  33. class GroupCommandManager : public Ref
  34. {
  35. public:
  36. int getGroupID();
  37. void releaseGroupID(int groupID);
  38. protected:
  39. friend class Renderer;
  40. GroupCommandManager();
  41. ~GroupCommandManager();
  42. bool init();
  43. std::unordered_map<int, bool> _groupMapping;
  44. std::vector<int> _unusedIDs;
  45. };
  46. /**
  47. GroupCommand is used to group several command together, and more, it can be nested.
  48. So it is used to generate the hierarchy for the rendcommands. Every group command will be assigned by a group ID.
  49. */
  50. class CC_DLL GroupCommand : public RenderCommand
  51. {
  52. public:
  53. /**@{
  54. Constructor and Destructor.
  55. */
  56. GroupCommand();
  57. ~GroupCommand();
  58. /**@}*/
  59. /**Init function for group command*/
  60. void init(float globalOrder);
  61. /**called by renderer, get the group ID.*/
  62. int getRenderQueueID() const { return _renderQueueID; }
  63. protected:
  64. int _renderQueueID;
  65. };
  66. NS_CC_END
  67. /**
  68. end of support group
  69. @}
  70. */
  71. #endif //_CC_GROUPCOMMAND_H_