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.
19 #include <dali/internal/event/images/pixel-data-impl.h>
21 #include <dali/integration-api/debug.h>
23 #if defined(DEBUG_ENABLED)
24 Debug::Filter* gPixelDataLogFilter = Debug::Filter::New(Debug::NoLogging, false, "DALI_LOG_PIXEL_DATA_SIZE");
31 #if defined(DEBUG_ENABLED)
32 // Only track data allocation if debug is enabled
33 uint32_t PixelData::gPixelDataAllocationTotal{0};
36 PixelData::PixelData(uint8_t* buffer,
41 Pixel::Format pixelFormat,
42 Dali::PixelData::ReleaseFunction releaseFunction,
43 bool releaseAfterUpload)
45 mBufferSize(bufferSize),
49 mPixelFormat(pixelFormat),
50 mReleaseFunction(releaseFunction),
51 mReleaseAfterUpload(releaseAfterUpload)
53 DALI_LOG_INFO(gPixelDataLogFilter, Debug::Concise, "Allocated PixelData of size %u\n", bufferSize);
54 #if defined(DEBUG_ENABLED)
55 gPixelDataAllocationTotal += mBufferSize;
59 PixelData::~PixelData()
61 ReleasePixelDataBuffer();
64 PixelDataPtr PixelData::New(uint8_t* buffer,
69 Pixel::Format pixelFormat,
70 Dali::PixelData::ReleaseFunction releaseFunction,
71 bool releaseAfterUpload)
73 return new PixelData(buffer, bufferSize, width, height, stride, pixelFormat, releaseFunction, releaseAfterUpload);
76 uint32_t PixelData::GetWidth() const
81 uint32_t PixelData::GetHeight() const
86 Pixel::Format PixelData::GetPixelFormat() const
91 uint8_t* PixelData::GetBuffer() const
96 uint32_t PixelData::GetBufferSize() const
101 void PixelData::ReleasePixelDataBuffer()
105 if(mReleaseFunction == Dali::PixelData::FREE)
114 #if defined(DEBUG_ENABLED)
115 gPixelDataAllocationTotal -= mBufferSize;
120 Dali::Integration::PixelDataBuffer PixelData::GetPixelDataBuffer() const
122 Dali::Integration::PixelDataBuffer pixelDataBuffer(mBuffer, mBufferSize, mWidth, mHeight, mStride);
123 return pixelDataBuffer;
126 uint32_t PixelData::GetStride() const
131 } // namespace Internal