summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6da98d4)
Use API that Upload sub image of PixelData.
By this code, we can reduce one of useless memcpy.
Change-Id: Ib4048116d98fef00ec454379d77137be135f3f56
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/images/pixel-data-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/images/pixel-data-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
+#include <dali/devel-api/rendering/texture-devel.h>
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
#include <dali/integration-api/debug.h>
#include <string.h>
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
#include <dali/integration-api/debug.h>
#include <string.h>
const bool markupStrikethroughEnabled = markupProcessorEnabled && mController->GetTextModel()->IsMarkupStrikethroughSet();
const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled() || markupUnderlineEnabled;
const bool strikethroughEnabled = mController->GetTextModel()->IsStrikethroughEnabled() || markupStrikethroughEnabled;
const bool markupStrikethroughEnabled = markupProcessorEnabled && mController->GetTextModel()->IsMarkupStrikethroughSet();
const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled() || markupUnderlineEnabled;
const bool strikethroughEnabled = mController->GetTextModel()->IsStrikethroughEnabled() || markupStrikethroughEnabled;
- const bool styleEnabled = (shadowEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled);
- const bool isOverlayStyle = underlineEnabled || strikethroughEnabled;
+ const bool styleEnabled = (shadowEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled);
+ const bool isOverlayStyle = underlineEnabled || strikethroughEnabled;
AddRenderer(control, relayoutSize, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle);
AddRenderer(control, relayoutSize, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle);
textureSet.SetSampler(textureSetIndex, sampler);
}
textureSet.SetSampler(textureSetIndex, sampler);
}
-PixelData TextVisual::ConvertToPixelData(unsigned char* buffer, int width, int height, int offsetPosition, const Pixel::Format textPixelFormat)
+void TextVisual::AddTilingTexture(TextureSet& textureSet, TilingInfo& tilingInfo, PixelData& data, Sampler& sampler, unsigned int textureSetIndex)
- int bpp = Pixel::GetBytesPerPixel(textPixelFormat);
- unsigned int bufferSize = width * height * bpp;
- unsigned char* dstBuffer = static_cast<unsigned char*>(malloc(bufferSize));
- memcpy(dstBuffer, buffer + offsetPosition * bpp, bufferSize);
- PixelData pixelData = Dali::PixelData::New(dstBuffer,
- bufferSize,
- width,
- height,
- textPixelFormat,
- Dali::PixelData::FREE);
- return pixelData;
+ Texture texture = Texture::New(Dali::TextureType::TEXTURE_2D,
+ tilingInfo.textPixelFormat,
+ tilingInfo.width,
+ tilingInfo.height);
+ DevelTexture::UploadSubPixelData(texture, data, 0u, tilingInfo.offsetHeight, tilingInfo.width, tilingInfo.height);
+
+ textureSet.SetTexture(textureSetIndex, texture);
+ textureSet.SetSampler(textureSetIndex, sampler);
}
void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler)
{
}
void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler)
{
- TextureSet textureSet = TextureSet::New();
- unsigned int textureSetIndex = 0u;
+ TextureSet textureSet = TextureSet::New();
+ uint32_t textureSetIndex = 0u;
// Convert the buffer to pixel data to make it a texture.
// Convert the buffer to pixel data to make it a texture.
- PixelData data = ConvertToPixelData(info.textBuffer, info.width, info.height, info.offsetPosition, info.textPixelFormat);
- AddTexture(textureSet, data, sampler, textureSetIndex);
+ AddTilingTexture(textureSet, info, info.textPixelData, sampler, textureSetIndex);
- if(mTextShaderFeatureCache.IsEnabledStyle() && info.styleBuffer)
+ if(mTextShaderFeatureCache.IsEnabledStyle() && info.stylePixelData)
- PixelData styleData = ConvertToPixelData(info.styleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
- AddTexture(textureSet, styleData, sampler, textureSetIndex);
+ AddTilingTexture(textureSet, info, info.stylePixelData, sampler, textureSetIndex);
- if(mTextShaderFeatureCache.IsEnabledOverlay() && info.overlayStyleBuffer)
+ if(mTextShaderFeatureCache.IsEnabledOverlay() && info.overlayStylePixelData)
- PixelData overlayStyleData = ConvertToPixelData(info.overlayStyleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
- AddTexture(textureSet, overlayStyleData, sampler, textureSetIndex);
+ AddTilingTexture(textureSet, info, info.overlayStylePixelData, sampler, textureSetIndex);
- if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor() && info.maskBuffer)
+ if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor() && info.maskPixelData)
- PixelData maskData = ConvertToPixelData(info.maskBuffer, info.width, info.height, info.offsetPosition, Pixel::L8);
- AddTexture(textureSet, maskData, sampler, textureSetIndex);
+ AddTilingTexture(textureSet, info, info.maskPixelData, sampler, textureSetIndex);
+ ++textureSetIndex;
}
renderer.SetTextures(textureSet);
}
renderer.SetTextures(textureSet);
// Set size and offset for the tiling.
renderer.SetProperty(VisualRenderer::Property::TRANSFORM_SIZE, Vector2(info.width, info.height));
// Set size and offset for the tiling.
renderer.SetProperty(VisualRenderer::Property::TRANSFORM_SIZE, Vector2(info.width, info.height));
- renderer.SetProperty(VisualRenderer::Property::TRANSFORM_OFFSET, Vector2(info.offSet.x, info.offSet.y));
+ renderer.SetProperty(VisualRenderer::Property::TRANSFORM_OFFSET, info.transformOffset);
renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
renderer.RegisterProperty("uHasMultipleTextColors", static_cast<float>(mTextShaderFeatureCache.IsEnabledMultiColor()));
renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
renderer.RegisterProperty("uHasMultipleTextColors", static_cast<float>(mTextShaderFeatureCache.IsEnabledMultiColor()));
// Set information for creating textures.
TilingInfo info(verifiedWidth, maxTextureSize, textPixelFormat);
// Set information for creating textures.
TilingInfo info(verifiedWidth, maxTextureSize, textPixelFormat);
- // Get the buffer of text.
- Dali::DevelPixelData::PixelDataBuffer textPixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(data);
- info.textBuffer = textPixelData.buffer;
+ // Get the pixel data of text.
+ info.textPixelData = data;
if(mTextShaderFeatureCache.IsEnabledStyle())
{
// Create RGBA texture for all the text styles (without the text itself)
if(mTextShaderFeatureCache.IsEnabledStyle())
{
// Create RGBA texture for all the text styles (without the text itself)
- PixelData styleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888);
- Dali::DevelPixelData::PixelDataBuffer stylePixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(styleData);
- info.styleBuffer = stylePixelData.buffer;
+ info.stylePixelData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888);
}
if(mTextShaderFeatureCache.IsEnabledOverlay())
{
// Create RGBA texture for all the overlay styles
}
if(mTextShaderFeatureCache.IsEnabledOverlay())
{
// Create RGBA texture for all the overlay styles
- PixelData overlayStyleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_OVERLAY_STYLE, false, Pixel::RGBA8888);
- Dali::DevelPixelData::PixelDataBuffer overlayStylePixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(overlayStyleData);
- info.overlayStyleBuffer = overlayStylePixelData.buffer;
+ info.overlayStylePixelData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_OVERLAY_STYLE, false, Pixel::RGBA8888);
}
if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor())
{
// Create a L8 texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation
}
if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor())
{
// Create a L8 texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation
- PixelData maskData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_MASK, false, Pixel::L8);
- Dali::DevelPixelData::PixelDataBuffer maskPixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(maskData);
- info.maskBuffer = maskPixelData.buffer;
+ info.maskPixelData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_MASK, false, Pixel::L8);
}
// Get the current offset for recalculate the offset when tiling.
}
// Get the current offset for recalculate the offset when tiling.
Property::Value* offsetValue = retMap.Find(Dali::Toolkit::Visual::Transform::Property::OFFSET);
if(offsetValue)
{
Property::Value* offsetValue = retMap.Find(Dali::Toolkit::Visual::Transform::Property::OFFSET);
if(offsetValue)
{
- offsetValue->Get(info.offSet);
+ offsetValue->Get(info.transformOffset);
}
// Create a textureset in the default renderer.
}
// Create a textureset in the default renderer.
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
- int offsetPosition = verifiedWidth * maxTextureSize;
// Create a renderer by cutting maxTextureSize.
while(verifiedHeight > 0)
{
VisualRenderer tilingRenderer = VisualRenderer::New(geometry, shader);
tilingRenderer.SetProperty(Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::CONTENT);
// New offset position of buffer for tiling.
// Create a renderer by cutting maxTextureSize.
while(verifiedHeight > 0)
{
VisualRenderer tilingRenderer = VisualRenderer::New(geometry, shader);
tilingRenderer.SetProperty(Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::CONTENT);
// New offset position of buffer for tiling.
- info.offsetPosition += offsetPosition;
+ info.offsetHeight += maxTextureSize;
// New height for tiling.
info.height = (verifiedHeight - maxTextureSize) > 0 ? maxTextureSize : verifiedHeight;
// New offset for tiling.
// New height for tiling.
info.height = (verifiedHeight - maxTextureSize) > 0 ? maxTextureSize : verifiedHeight;
// New offset for tiling.
- info.offSet.y += maxTextureSize;
+ info.transformOffset.y += maxTextureSize;
// Create a textureset int the new tiling renderer.
CreateTextureSet(info, tilingRenderer, sampler);
// Create a textureset int the new tiling renderer.
CreateTextureSet(info, tilingRenderer, sampler);
// Create a texture for the text without any styles
PixelData data = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_STYLES, false, textPixelFormat);
// Create a texture for the text without any styles
PixelData data = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_STYLES, false, textPixelFormat);
- // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
- // In that case, create a texture. TODO: should tile the text.
- unsigned int textureSetIndex = 0u;
+ uint32_t textureSetIndex = 0u;
AddTexture(textureSet, data, sampler, textureSetIndex);
++textureSetIndex;
AddTexture(textureSet, data, sampler, textureSetIndex);
++textureSetIndex;
private:
struct TilingInfo
{
private:
struct TilingInfo
{
- unsigned char* textBuffer;
- unsigned char* styleBuffer;
- unsigned char* overlayStyleBuffer;
- unsigned char* maskBuffer;
- int width;
- int height;
- Pixel::Format textPixelFormat;
- int offsetPosition;
- Vector2 offSet;
-
- TilingInfo(int width, int height, Pixel::Format textPixelFormat)
- : textBuffer(NULL),
- styleBuffer(NULL),
- overlayStyleBuffer(NULL),
- maskBuffer(NULL),
+ PixelData textPixelData;
+ PixelData stylePixelData;
+ PixelData overlayStylePixelData;
+ PixelData maskPixelData;
+ int32_t width;
+ int32_t height;
+ Pixel::Format textPixelFormat;
+ uint32_t offsetHeight;
+ Vector2 transformOffset;
+
+ TilingInfo(int32_t width, int32_t height, Pixel::Format textPixelFormat)
+ : textPixelData(),
+ stylePixelData(),
+ overlayStylePixelData(),
+ maskPixelData(),
width(width),
height(height),
textPixelFormat(textPixelFormat),
width(width),
height(height),
textPixelFormat(textPixelFormat),
- offsetPosition(0),
- offSet(0.f, 0.f)
+ offsetHeight(0u),
+ transformOffset(0.f, 0.f)
- if(textBuffer)
- {
- free(textBuffer);
- }
- if(styleBuffer)
- {
- free(styleBuffer);
- }
- if(overlayStyleBuffer)
- {
- free(overlayStyleBuffer);
- }
- if(maskBuffer)
- {
- free(maskBuffer);
- }
/**
* @brief Create a texture in textureSet and add it.
* @param[in] textureSet The textureSet to which the texture will be added.
/**
* @brief Create a texture in textureSet and add it.
* @param[in] textureSet The textureSet to which the texture will be added.
- * @param[in] data The PixelData to be uploaded to texture
+ * @param[in] data The PixelData to be uploaded to texture.
* @param[in] sampler The sampler.
* @param[in] textureSetIndex The Index of TextureSet.
*/
void AddTexture(TextureSet& textureSet, PixelData& data, Sampler& sampler, unsigned int textureSetIndex);
/**
* @param[in] sampler The sampler.
* @param[in] textureSetIndex The Index of TextureSet.
*/
void AddTexture(TextureSet& textureSet, PixelData& data, Sampler& sampler, unsigned int textureSetIndex);
/**
- * @brief Convert the buffer to pixelData.
- * @param[in] buffer The Buffer to be converted to pixelData.
- * @param[in] width The width of pixel data.
- * @param[in] height The height of pixel data.
- * @param[in] offsetPosition The The buffer's start position.
- * @param[in] textPixelFormat The PixelForma of text.
+ * @brief Create a texture in textureSet and add it.
+ * @param[in] textureSet The textureSet to which the texture will be added.
+ * @param[in] tilingInfo The tiling infomation to be uploaded to texture.
+ * @param[in] data The PixelData to be uploaded to texture.
+ * @param[in] sampler The sampler.
+ * @param[in] textureSetIndex The Index of TextureSet.
- PixelData ConvertToPixelData(unsigned char* buffer, int width, int height, int offsetPosition, const Pixel::Format textPixelFormat);
+ void AddTilingTexture(TextureSet& textureSet, TilingInfo& tilingInfo, PixelData& data, Sampler& sampler, unsigned int textureSetIndex);
/**
* @brief Create the text's texture. It will use cached shader feature for text visual.
/**
* @brief Create the text's texture. It will use cached shader feature for text visual.