BsRenderTexturePool.h 989 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "BsBansheeRendererPrerequisites.h"
  3. #include "BsPixelUtil.h"
  4. namespace BansheeEngine
  5. {
  6. class RenderTexturePool;
  7. struct PooledRenderTexture
  8. {
  9. PooledRenderTexture(RenderTexturePool* pool);
  10. ~PooledRenderTexture();
  11. SPtr<RenderTextureCore> texture;
  12. private:
  13. friend class RenderTexturePool;
  14. RenderTexturePool* mPool;
  15. bool mIsFree;
  16. };
  17. class RenderTexturePool
  18. {
  19. public:
  20. ~RenderTexturePool();
  21. SPtr<PooledRenderTexture> get(PixelFormat format, UINT32 width, UINT32 height, bool hwGamma = false, UINT32 samples = 0);
  22. void free(const SPtr<PooledRenderTexture>& texture);
  23. private:
  24. friend struct PooledRenderTexture;
  25. void _registerTexture(const SPtr<PooledRenderTexture>& texture);
  26. void _unregisterTexture(PooledRenderTexture* texture);
  27. bool matches(const SPtr<TextureCore>& texture, PixelFormat format, UINT32 width, UINT32 height, bool hwGamma, UINT32 samples);
  28. Map<PooledRenderTexture*, SPtr<PooledRenderTexture>> mTextures;
  29. };
  30. }