DALI_TEST_CHECK(!baseFragShader.compare(fragShader));
END_TEST;
}
+
+int UtcDaliTextureGetPixelFormat(void)
+{
+ TestApplication application;
+ uint32_t width(64);
+ uint32_t height(64);
+
+ Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
+
+ texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, width, height);
+ DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
+
+ texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::L8, width, height);
+ DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::L8, TEST_LOCATION);
+
+ texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::CHROMINANCE_U, width, height);
+ DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
+
+ END_TEST;
+}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
namespace Internal
{
-TexturePtr Texture::New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height)
+TexturePtr Texture::New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height)
{
constexpr auto max_value = std::numeric_limits<uint16_t>::max();
DALI_ASSERT_ALWAYS((width < max_value) && (height < max_value) && "Size out of range");
}
bool Texture::Upload(PixelDataPtr pixelData,
- unsigned int layer,
- unsigned int mipmap,
- unsigned int xOffset,
- unsigned int yOffset,
- unsigned int width,
- unsigned int height)
+ uint32_t layer,
+ uint32_t mipmap,
+ uint32_t xOffset,
+ uint32_t yOffset,
+ uint32_t width,
+ uint32_t height)
{
constexpr auto max_value = std::numeric_limits<uint16_t>::max();
DALI_ASSERT_ALWAYS(layer < max_value &&
}
else
{
- unsigned int pixelDataSize = pixelData->GetWidth() * pixelData->GetHeight();
+ uint32_t pixelDataSize = pixelData->GetWidth() * pixelData->GetHeight();
if(pixelData->GetBuffer() == nullptr || pixelDataSize == 0)
{
DALI_LOG_ERROR("PixelData is empty\n");
}
}
-unsigned int Texture::GetWidth() const
+uint32_t Texture::GetWidth() const
{
return mSize.GetWidth();
}
-unsigned int Texture::GetHeight() const
+uint32_t Texture::GetHeight() const
{
return mSize.GetHeight();
}
+Pixel::Format Texture::GetPixelFormat() const
+{
+ return mFormat;
+}
+
bool Texture::IsNative() const
{
return static_cast<bool>(mNativeImage);
#define DALI_INTERNAL_NEW_TEXTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param[in] height The height of the texture
* @return A smart-pointer to the newly allocated Texture.
*/
- static TexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height);
+ static TexturePtr New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height);
/**
* @brief Creates a new Texture from a native image
* @copydoc Dali::Texture::Upload()
*/
bool Upload(PixelDataPtr pixelData,
- unsigned int layer,
- unsigned int mipmap,
- unsigned int xOffset,
- unsigned int yOffset,
- unsigned int width,
- unsigned int height);
+ uint32_t layer,
+ uint32_t mipmap,
+ uint32_t xOffset,
+ uint32_t yOffset,
+ uint32_t width,
+ uint32_t height);
/**
* @copydoc Dali::Texture::GenerateMipmaps()
/**
* @copydoc Dali::Texture::GetWidth()
*/
- unsigned int GetWidth() const;
+ uint32_t GetWidth() const;
/**
* @copydoc Dali::Texture::GetHeight()
*/
- unsigned int GetHeight() const;
+ uint32_t GetHeight() const;
+
+ /**
+ * @copydoc Dali::Texture::GetPixelFormat()
+ */
+ Pixel::Format GetPixelFormat() const;
/**
* @brief Determine if the texture is a native image
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use *this file except in compliance with the License.
return GetImplementation(*this).GetHeight();
}
+Pixel::Format Texture::GetPixelFormat() const
+{
+ return GetImplementation(*this).GetPixelFormat();
+}
+
Texture::Texture(Internal::Texture* pointer)
: BaseHandle(pointer)
{
#define DALI_TEXTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
uint32_t GetHeight() const;
+ /**
+ * @brief Returns the pixel format of the texture.
+ *
+ * @SINCE_2_1.29
+ * @return The pixel format of the texture
+ */
+ Pixel::Format GetPixelFormat() const;
+
public:
/**
* @brief The constructor.