#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/images/pixel.h>
ViewModel* GetViewModel();
/**
+ * @brief Set the font client.
+ *
+ * Set the font client used in the update/render process of the text model.
+ *
+ * @param[in] fontClient The font client used by the Typesetter.
+ */
+ void SetFontClient(TextAbstraction::FontClient& fontClient);
+
+ /**
* @brief Renders the text.
*
* Does the following operations:
*/
PixelData Render(const Vector2& size, Toolkit::DevelText::TextDirection::Type textDirection, RenderBehaviour behaviour = RENDER_TEXT_AND_STYLES, bool ignoreHorizontalAlignment = false, Pixel::Format pixelFormat = Pixel::RGBA8888);
-private:
/**
- * @brief Private constructor.
+ * @brief After the Render, use the pixel information of the given cutoutBuffer to make the part where the pixel is drawn transparent.
*
- * @param[in] model Pointer to the text's data model.
+ * @param[in] size The renderer size.
+ * @param[in] textDirection The direction of the text.
+ * @param[in] cutoutBuffer The buffer to use pixel information to cutout.
+ * @param[in] behaviour The behaviour of how to render the text (i.e. whether to render the text only or the styles only or both).
+ * @param[in] ignoreHorizontalAlignment Whether to ignore the horizontal alignment (i.e. always render as if HORIZONTAL_ALIGN_BEGIN).
+ * @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
+ * @param[in] originAlpha The original alpha of text.
+ *
+ * @return A pixel data with the text rendered.
*/
- Typesetter(const ModelInterface* const model);
-
- // Declared private and left undefined to avoid copies.
- Typesetter(const Typesetter& handle);
-
- // Declared private and left undefined to avoid copies.
- Typesetter& operator=(const Typesetter& handle);
+ PixelData RenderWithCutout(const Vector2& size, Toolkit::DevelText::TextDirection::Type textDirection, Devel::PixelBuffer cutoutBuffer, RenderBehaviour behaviour = RENDER_TEXT_AND_STYLES, bool ignoreHorizontalAlignment = false, Pixel::Format pixelFormat = Pixel::RGBA8888, float originAlpha = 1.f);
/**
- * @brief Create & draw the image buffer for the given range of the glyphs in the given style.
+ * @brief Renders the text, return as Devel::PixelBuffer.
*
- * Does the following operations:
- * - Retrieves the data buffers from the text model.
- * - Creates the pixel data used to generate the final image with the given size.
- * - Traverse the visible glyphs, retrieve their bitmaps and compose the final pixel data.
+ * This function is used to obtain the PixelBuffer required for cutout.
*
- * @param[in] bufferWidth The width of the image buffer.
- * @param[in] bufferHeight The height of the image buffer.
- * @param[in] style The style of the text.
- * @param[in] ignoreHorizontalAlignment Whether to ignore the horizontal alignment, not ignored by default.
+ * @param[in] size The renderer size.
+ * @param[in] textDirection The direction of the text.
+ * @param[in] cutoutBuffer The buffer to use pixel information to cutout.
+ * @param[in] behaviour The behaviour of how to render the text (i.e. whether to render the text only or the styles only or both).
+ * @param[in] ignoreHorizontalAlignment Whether to ignore the horizontal alignment (i.e. always render as if HORIZONTAL_ALIGN_BEGIN).
* @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
- * @param[in] horizontalOffset The horizontal offset to be added to the glyph's position.
- * @param[in] verticalOffset The vertical offset to be added to the glyph's position.
- * @param[in] fromGlyphIndex The index of the first glyph within the text to be drawn
- * @param[in] toGlyphIndex The index of the last glyph within the text to be drawn
*
- * @return An image buffer with the text.
+ * @return A pixel data with the text rendered.
*/
- Devel::PixelBuffer CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Typesetter::Style style, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset, TextAbstraction::GlyphIndex fromGlyphIndex, TextAbstraction::GlyphIndex toGlyphIndex);
+ Devel::PixelBuffer RenderWithPixelBuffer(const Vector2& size, Toolkit::DevelText::TextDirection::Type textDirection, RenderBehaviour behaviour = RENDER_TEXT_AND_STYLES, bool ignoreHorizontalAlignment = false, Pixel::Format pixelFormat = Pixel::RGBA8888);
/**
- * @brief Create an initialized image buffer.
- *
- * Creates the pixel data used to generate the final image with the given size.
+ * @brief Create & draw the image buffer of single background color.
*
* @param[in] bufferWidth The width of the image buffer.
* @param[in] bufferHeight The height of the image buffer.
- * @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
+ * @param[in] backgroundColor The backgroundColor of image buffer.
*
- * @return An image buffer.
+ * @return An image buffer with the text.
*/
- Devel::PixelBuffer CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Pixel::Format pixelFormat);
+ Devel::PixelBuffer CreateFullBackgroundBuffer(const uint32_t bufferWidth, const uint32_t bufferHeight, const Vector4& backgroundColor);
/**
- * @brief Combine the two RGBA image buffers together.
+ * @brief Set Mask for two pixel buffer.
*
- * The top layer buffer will blend over the bottom layer buffer:
- * - If the pixel is not fully opaque from either buffer, it will be blended with
- * the pixel from the other buffer and copied to the combined buffer.
- * - If the pixels from both buffers are fully opaque, the pixels from the top layer
- * buffer will be copied to the combined buffer.
+ * The alpha value of bottomPixelBuffer is decreased as the alpha value of topPixelBuffer is higher.
*
- * @param[in] topPixelBuffer The top layer buffer.
- * @param[in] bottomPixelBuffer The bottom layer buffer.
+ * @param[in, out] topPixelBuffer The top layer buffer.
+ * @param[in, out] bottomPixelBuffer The bottom layer buffer.
* @param[in] bufferWidth The width of the image buffer.
* @param[in] bufferHeight The height of the image buffer.
+ * @param[in] originAlpha The original alpha value of the text.
+ */
+ void SetMaskForImageBuffer(Devel::PixelBuffer& __restrict__ topPixelBuffer, Devel::PixelBuffer& __restrict__ bottomPixelBuffer, const uint32_t bufferWidth, const uint32_t bufferHeight, float originAlpha);
+
+private:
+ /**
+ * @brief Private constructor.
*
- * @return The combined image buffer with the text.
- *
+ * @param[in] model Pointer to the text's data model.
*/
- Devel::PixelBuffer CombineImageBuffer(Devel::PixelBuffer topPixelBuffer, Devel::PixelBuffer bottomPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeightbool);
+ Typesetter(const ModelInterface* const model);
+
+ // Declared private and left undefined to avoid copies.
+ Typesetter(const Typesetter& handle);
+
+ // Declared private and left undefined to avoid copies.
+ Typesetter& operator=(const Typesetter& handle);
/**
- * @brief Apply behaviour of tags if the markup-processor is enabled.
+ * @brief Create & draw the image buffer for the given range of the glyphs in the given style.
+ *
+ * Does the following operations:
+ * - Retrieves the data buffers from the text model.
+ * - Creates the pixel data used to generate the final image with the given size.
+ * - Traverse the visible glyphs, retrieve their bitmaps and compose the final pixel data.
*
- * @param[in] topPixelBuffer The top layer buffer.
* @param[in] bufferWidth The width of the image buffer.
* @param[in] bufferHeight The height of the image buffer.
+ * @param[in] style The style of the text.
* @param[in] ignoreHorizontalAlignment Whether to ignore the horizontal alignment, not ignored by default.
* @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
* @param[in] horizontalOffset The horizontal offset to be added to the glyph's position.
* @param[in] verticalOffset The vertical offset to be added to the glyph's position.
+ * @param[in] fromGlyphIndex The index of the first glyph within the text to be drawn
+ * @param[in] toGlyphIndex The index of the last glyph within the text to be drawn
*
- * @return The image buffer with the markup.
+ * @return An image buffer with the text.
*/
- Devel::PixelBuffer ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+ Devel::PixelBuffer CreateImageBuffer(const uint32_t bufferWidth, const uint32_t bufferHeight, const Typesetter::Style style, const bool ignoreHorizontalAlignment, const Pixel::Format pixelFormat, const int32_t horizontalOffset, const int32_t verticalOffset, const TextAbstraction::GlyphIndex fromGlyphIndex, const TextAbstraction::GlyphIndex toGlyphIndex);
/**
* @brief Apply markup underline tags.
*
* @return The image buffer with the markup.
*/
- Devel::PixelBuffer ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+ Devel::PixelBuffer ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t bufferWidth, const uint32_t bufferHeight, const bool ignoreHorizontalAlignment, const Pixel::Format pixelFormat, const int32_t horizontalOffset, const int32_t verticalOffset);
/**
* @brief Apply markup strikethrough tags.
*
* @return The image buffer with the markup.
*/
- Devel::PixelBuffer ApplyStrikethroughMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+ Devel::PixelBuffer ApplyStrikethroughMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t bufferWidth, const uint32_t bufferHeight, const bool ignoreHorizontalAlignment, const Pixel::Format pixelFormat, const int32_t horizontalOffset, const int32_t verticalOffset);
protected:
/**
virtual ~Typesetter();
private:
- ViewModel* mModel;
+ ViewModel* mModel;
+ TextAbstraction::FontClient mFontClient;
};
} // namespace Text
} // namespace Dali
-#endif // DALI_TOOLKIT_TEXT_TYPESETTER_H
\ No newline at end of file
+#endif // DALI_TOOLKIT_TEXT_TYPESETTER_H