2 * Copyright (c) 2022 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)
44 mBufferSize(bufferSize),
48 mPixelFormat(pixelFormat),
49 mReleaseFunction(releaseFunction)
51 DALI_LOG_INFO(gPixelDataLogFilter, Debug::Concise, "Allocated PixelData of size %u\n", bufferSize);
52 #if defined(DEBUG_ENABLED)
53 gPixelDataAllocationTotal += mBufferSize;
57 PixelData::~PixelData()
61 if(mReleaseFunction == Dali::PixelData::FREE)
69 #if defined(DEBUG_ENABLED)
70 gPixelDataAllocationTotal -= mBufferSize;
75 PixelDataPtr PixelData::New(uint8_t* buffer,
80 Pixel::Format pixelFormat,
81 Dali::PixelData::ReleaseFunction releaseFunction)
83 return new PixelData(buffer, bufferSize, width, height, stride, pixelFormat, releaseFunction);
86 uint32_t PixelData::GetWidth() const
91 uint32_t PixelData::GetHeight() const
96 Pixel::Format PixelData::GetPixelFormat() const
101 uint8_t* PixelData::GetBuffer() const
106 uint32_t PixelData::GetBufferSize() const
111 DevelPixelData::PixelDataBuffer PixelData::ReleaseBuffer()
113 DevelPixelData::PixelDataBuffer pixelDataBuffer(mBuffer, mBufferSize, mReleaseFunction);
115 return pixelDataBuffer;
118 uint32_t PixelData::GetStride() const
123 } // namespace Internal