| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // Copyright (c) 2008-2017 the Urho3D project.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- #pragma once
- #include "../../Math/Color.h"
- #include "../../Math/Rect.h"
- #include "../GraphicsDefs.h"
- namespace Atomic
- {
- class PixelShader;
- class Graphics;
- class Matrix3x4;
- class Texture;
- class Text3DText;
- static const unsigned TEXT3D_VERTEX_SIZE = 6;
- /// Text rendering draw call.
- class ATOMIC_API Text3DBatch
- {
- public:
- /// Construct with defaults.
- Text3DBatch();
- /// Construct.
- Text3DBatch(Text3DText* element, BlendMode blendMode, const IntRect& scissor, Texture* texture, PODVector<float>* vertexData);
- /// Set new color for the batch. Overrides gradient.
- void SetColor(const Color& color);
- /// Restore UI element's default color.
- void SetDefaultColor();
- /// Add a quad.
- void AddQuad(float x, float y, float width, float height, int texOffsetX, int texOffsetY, int texWidth = 0, int texHeight = 0);
- /// Add a quad using a transform matrix.
- void AddQuad(const Matrix3x4& transform, int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth = 0,
- int texHeight = 0);
- /// Add a quad with tiled texture.
- void AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight, bool tiled);
- /// Add a quad with freeform points and UVs. Uses the current color, not gradient. Points should be specified in clockwise order.
- void AddQuad(const Matrix3x4& transform, const IntVector2& a, const IntVector2& b, const IntVector2& c, const IntVector2& d,
- const IntVector2& texA, const IntVector2& texB, const IntVector2& texC, const IntVector2& texD);
- /// Add a quad with freeform points, UVs and colors. Points should be specified in clockwise order.
- void AddQuad(const Matrix3x4& transform, const IntVector2& a, const IntVector2& b, const IntVector2& c, const IntVector2& d,
- const IntVector2& texA, const IntVector2& texB, const IntVector2& texC, const IntVector2& texD, const Color& colA,
- const Color& colB, const Color& colC, const Color& colD);
- /// Merge with another batch.
- bool Merge(const Text3DBatch& batch);
- /// Return an interpolated color for the element.
- unsigned GetInterpolatedColor(float x, float y);
- /// Add or merge a batch.
- static void AddOrMerge(const Text3DBatch& batch, PODVector<Text3DBatch>& batches);
- /// Element this batch represents.
- Text3DText* element_;
- /// Blending mode.
- BlendMode blendMode_;
- /// Scissor rectangle.
- IntRect scissor_;
- /// Texture.
- Texture* texture_;
- /// Inverse texture size.
- Vector2 invTextureSize_;
- /// Current color. By default calculated from the element.
- unsigned color_;
- /// Vertex data.
- PODVector<float>* vertexData_;
- /// Vertex data start index.
- unsigned vertexStart_;
- /// Vertex data end index.
- unsigned vertexEnd_;
- /// Position adjustment vector for pixel-perfect rendering. Initialized by UI.
- static Vector3 posAdjust;
- /// Gradient flag.
- bool useGradient_;
- };
- }
|