D3D11RenderSurface.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../../Graphics/GraphicsDefs.h"
  24. #include "../../Graphics/Viewport.h"
  25. namespace Atomic
  26. {
  27. class Texture;
  28. /// %Color or depth-stencil surface that can be rendered into.
  29. class ATOMIC_API RenderSurface : public RefCounted
  30. {
  31. friend class Texture2D;
  32. friend class TextureCube;
  33. REFCOUNTED(RenderSurface)
  34. public:
  35. /// Construct with parent texture.
  36. RenderSurface(Texture* parentTexture);
  37. /// Destruct.
  38. ~RenderSurface();
  39. /// Set number of viewports.
  40. void SetNumViewports(unsigned num);
  41. /// Set viewport.
  42. void SetViewport(unsigned index, Viewport* viewport);
  43. /// Set viewport update mode. Default is to update when visible.
  44. void SetUpdateMode(RenderSurfaceUpdateMode mode);
  45. /// Set linked color rendertarget.
  46. void SetLinkedRenderTarget(RenderSurface* renderTarget);
  47. /// Set linked depth-stencil surface.
  48. void SetLinkedDepthStencil(RenderSurface* depthStencil);
  49. /// Queue manual update of the viewport(s).
  50. void QueueUpdate();
  51. /// Release surface.
  52. void Release();
  53. /// Return parent texture.
  54. Texture* GetParentTexture() const { return parentTexture_; }
  55. /// Return Direct3D rendertarget or depth-stencil view.
  56. void* GetRenderTargetView() const { return renderTargetView_; }
  57. /// Return width.
  58. int GetWidth() const;
  59. /// Return height.
  60. int GetHeight() const;
  61. /// Return usage.
  62. TextureUsage GetUsage() const;
  63. /// Return number of viewports.
  64. unsigned GetNumViewports() const { return viewports_.Size(); }
  65. /// Return viewport by index.
  66. Viewport* GetViewport(unsigned index) const;
  67. /// Return viewport update mode.
  68. RenderSurfaceUpdateMode GetUpdateMode() const { return updateMode_; }
  69. /// Return linked color rendertarget.
  70. RenderSurface* GetLinkedRenderTarget() const { return linkedRenderTarget_; }
  71. /// Return linked depth-stencil surface.
  72. RenderSurface* GetLinkedDepthStencil() const { return linkedDepthStencil_; }
  73. /// Clear update flag. Called by Renderer.
  74. void WasUpdated();
  75. private:
  76. /// Parent texture.
  77. Texture* parentTexture_;
  78. /// Direct3D rendertarget or depth-stencil view.
  79. void* renderTargetView_;
  80. /// Viewports.
  81. Vector<SharedPtr<Viewport> > viewports_;
  82. /// Linked color buffer.
  83. WeakPtr<RenderSurface> linkedRenderTarget_;
  84. /// Linked depth buffer.
  85. WeakPtr<RenderSurface> linkedDepthStencil_;
  86. /// Update mode for viewports.
  87. RenderSurfaceUpdateMode updateMode_;
  88. /// Update queued flag.
  89. bool updateQueued_;
  90. };
  91. }