2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <dali/internal/text/text-abstraction/plugin/embedded-item.h>
19 #include <dali/internal/text/text-abstraction/plugin/font-client-utils.h>
21 #include <dali/integration-api/debug.h>
23 namespace Dali::TextAbstraction::Internal
25 void EmbeddedItem::GetGlyphMetrics(GlyphInfo& glyph)
27 glyph.width = static_cast<float>(width);
28 glyph.height = static_cast<float>(height);
30 glyph.yBearing = glyph.height;
31 glyph.advance = glyph.width;
32 glyph.scaleFactor = 1.f;
35 void EmbeddedItem::CreateBitmap(const std::vector<PixelBufferCacheItem>& pixelBufferCache,
36 Dali::TextAbstraction::GlyphBufferData& data)
40 if(0u != pixelBufferId)
42 Devel::PixelBuffer pixelBuffer = pixelBufferCache[pixelBufferId - 1u].pixelBuffer;
45 ConvertBitmap(data, pixelBuffer.GetWidth(), pixelBuffer.GetHeight(), pixelBuffer.GetBuffer(), pixelBuffer.GetPixelFormat());
50 data.isBufferOwned = true;
51 data.compressionType = Dali::TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION;
53 // Creates the output buffer
54 const uint32_t bufferSize = data.width * data.height * 4u;
55 data.buffer = (uint8_t*)malloc(bufferSize); // @note The caller is responsible for deallocating the bitmap data using free.
56 if(DALI_UNLIKELY(!data.buffer))
58 DALI_LOG_ERROR("malloc is failed. request malloc size : %u\n", bufferSize);
62 memset(data.buffer, 0u, bufferSize);
65 // Just creates a void buffer. Doesn't matter what pixel format is set as is the application code the responsible of filling it.
69 } // namespace Dali::TextAbstraction::Internal