UIBatch.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // Copyright (c) 2008-2013 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 "Color.h"
  24. #include "GraphicsDefs.h"
  25. #include "Rect.h"
  26. namespace Urho3D
  27. {
  28. class PixelShader;
  29. class Graphics;
  30. class Matrix3x4;
  31. class ShaderVariation;
  32. class Texture;
  33. class UIElement;
  34. static const unsigned UI_VERTEX_SIZE = 6;
  35. /// %UI rendering draw call.
  36. class URHO3D_API UIBatch
  37. {
  38. public:
  39. /// Construct with defaults.
  40. UIBatch();
  41. /// Construct.
  42. UIBatch(UIElement* element, BlendMode blendMode, const IntRect& scissor, Texture* texture, PODVector<float>* vertexData);
  43. /// Add a quad.
  44. void AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth = 0, int texHeight = 0, Color* color = 0);
  45. /// Add a quad using a transform matrix.
  46. void AddQuad(const Matrix3x4& transform, int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth = 0, int texHeight = 0, Color* color = 0);
  47. /// Add a quad with tiled texture.
  48. void AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight, bool tiled);
  49. /// Add a quad with custom color.
  50. void AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight, const Color& color);
  51. /// Merge with another batch.
  52. bool Merge(const UIBatch& batch);
  53. /// Return an interpolated color for the UI element.
  54. unsigned GetInterpolatedColor(int x, int y);
  55. /// Add or merge a batch.
  56. static void AddOrMerge(const UIBatch& batch, PODVector<UIBatch>& batches);
  57. /// Element this batch represents.
  58. UIElement* element_;
  59. /// Blending mode.
  60. BlendMode blendMode_;
  61. /// Scissor rectangle.
  62. IntRect scissor_;
  63. /// Texture.
  64. Texture* texture_;
  65. /// Inverse texture size.
  66. Vector2 invTextureSize_;
  67. /// Element color if not using a gradient.
  68. unsigned fixedColor_;
  69. /// Vertex data.
  70. PODVector<float>* vertexData_;
  71. /// Vertex data start index.
  72. unsigned vertexStart_;
  73. /// Vertex data end index.
  74. unsigned vertexEnd_;
  75. };
  76. }