return mModel;
}
+Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Pixel::Format pixelFormat)
+{
+ Devel::PixelBuffer imageBuffer = Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat);
+
+ if(Pixel::RGBA8888 == pixelFormat)
+ {
+ const unsigned int bufferSizeInt = bufferWidth * bufferHeight;
+ const unsigned int bufferSizeChar = 4u * bufferSizeInt;
+ memset(imageBuffer.GetBuffer(), 0u, bufferSizeChar);
+ }
+ else
+ {
+ memset(imageBuffer.GetBuffer(), 0, bufferWidth * bufferHeight);
+ }
+
+ return imageBuffer;
+}
+
PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirection::Type textDirection, RenderBehaviour behaviour, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat)
{
// @todo. This initial implementation for a TextLabel has only one visible page.
}
else
{
- backgroundImageBuffer = Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat);
+ backgroundImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, pixelFormat);
}
if(backgroundMarkupSet)
glyphData.verticalOffset = verticalOffset;
glyphData.width = bufferWidth;
glyphData.height = bufferHeight;
- glyphData.bitmapBuffer = Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat);
+ glyphData.bitmapBuffer = CreateImageBuffer(bufferWidth, bufferHeight, pixelFormat);
glyphData.horizontalOffset = 0;
- if(Pixel::RGBA8888 == pixelFormat)
- {
- const unsigned int bufferSizeInt = bufferWidth * bufferHeight;
- const unsigned int bufferSizeChar = 4u * bufferSizeInt;
- memset(glyphData.bitmapBuffer.GetBuffer(), 0u, bufferSizeChar);
- }
- else
- {
- memset(glyphData.bitmapBuffer.GetBuffer(), 0, bufferWidth * bufferHeight);
- }
-
// Get a handle of the font client. Used to retrieve the bitmaps of the glyphs.
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
Length hyphenIndex = 0;
Typesetter& operator=(const Typesetter& handle);
/**
- * @brief Create the image buffer for the given range of the glyphs in the given style.
+ * @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.
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);
/**
+ * @brief Create an initialized image buffer.
+ *
+ * Creates the pixel data used to generate the final image with the given size.
+ *
+ * @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).
+ *
+ * @return An image buffer.
+ */
+ Devel::PixelBuffer CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Pixel::Format pixelFormat);
+
+ /**
* @brief Combine the two RGBA image buffers together.
*
* The top layer buffer will blend over the bottom layer buffer:
// Get the background color of the character.
// The color index zero is reserved for the default background color (i.e. Color::TRANSPARENT)
- const ColorIndex backgroundColorIndex = (nullptr == backgroundColorsBuffer) ? 0u : *(backgroundColorIndicesBuffer + i);
- const Vector4& backgroundColor = (0u == backgroundColorIndex) ? defaultBackgroundColor : *(backgroundColorsBuffer + backgroundColorIndex - 1u);
+ const bool isMarkupBackground = mView.IsMarkupBackgroundColorSet();
+ const ColorIndex backgroundColorIndex = isMarkupBackground ? *(backgroundColorIndicesBuffer + i) : 0u;
+ const bool isDefaultBackgroundColor = (0u == backgroundColorIndex);
+ const Vector4& backgroundColor = isDefaultBackgroundColor ? defaultBackgroundColor : *(backgroundColorsBuffer + backgroundColorIndex - 1u);
mModel->mVisualModel->GetNumberOfLines(i, 1, lineIndex, numberOfLines);
Length lineHeight = lineRun[lineIndex].ascender + -(lineRun[lineIndex].descender) + lineRun[lineIndex].lineSpacing;
bool const Model::IsMarkupBackgroundColorSet() const
{
- return (mVisualModel->mBackgroundColorIndices.Count() > 0);
+ return (mVisualModel->mBackgroundColors.Count() > 0);
}
const Vector4& Model::GetDefaultColor() const
{
if(mImpl->mVisualModel)
{
- return (mImpl->mVisualModel->mBackgroundColorIndices.Count() > 0);
+ return (mImpl->mVisualModel->mBackgroundColors.Count() > 0);
}
return false;