[AT-SPI] Rework intercepting key events
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / plugin / embedded-item.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <dali/internal/text/text-abstraction/plugin/embedded-item.h>
18
19 #include <dali/internal/text/text-abstraction/plugin/font-client-utils.h>
20
21 namespace Dali::TextAbstraction::Internal
22 {
23 void EmbeddedItem::GetGlyphMetrics(GlyphInfo& glyph)
24 {
25   glyph.width       = static_cast<float>(width);
26   glyph.height      = static_cast<float>(height);
27   glyph.xBearing    = 0.f;
28   glyph.yBearing    = glyph.height;
29   glyph.advance     = glyph.width;
30   glyph.scaleFactor = 1.f;
31 }
32
33 void EmbeddedItem::CreateBitmap(const std::vector<PixelBufferCacheItem>& pixelBufferCache,
34                                 Dali::TextAbstraction::GlyphBufferData&  data)
35 {
36   data.width  = width;
37   data.height = height;
38   if(0u != pixelBufferId)
39   {
40     Devel::PixelBuffer pixelBuffer = pixelBufferCache[pixelBufferId - 1u].pixelBuffer;
41     if(pixelBuffer)
42     {
43       ConvertBitmap(data, pixelBuffer.GetWidth(), pixelBuffer.GetHeight(), pixelBuffer.GetBuffer(), pixelBuffer.GetPixelFormat());
44     }
45   }
46   else
47   {
48     data.isBufferOwned   = true;
49     data.compressionType = Dali::TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION;
50
51     // Creates the output buffer
52     const uint32_t bufferSize = data.width * data.height * 4u;
53     data.buffer               = (uint8_t*)malloc(bufferSize); // @note The caller is responsible for deallocating the bitmap data using free.
54
55     memset(data.buffer, 0u, bufferSize);
56
57     // Just creates a void buffer. Doesn't matter what pixel format is set as is the application code the responsible of filling it.
58   }
59 }
60
61 } // namespace Dali::TextAbstraction::Internal