Commit a4afa0989d89c05e833b28c210e59aad5fa084ad
1 parent
7223cb68
Added ASTC Native file format loader
ASTC can be wrapped in a KTX file, but also has its own native file format. This patch provides support for the native ASTC file format (.astc). Textures can be generated using tools (Eg. Mali texture compression tool). Note: ASTC is "OpenGL friendly" in that the textures are pre-flipped vertically. In DALi there is currently not a differenciation between different texture compression formats in that the data (once the header is extracted) is given to the hardware as-is. For this reason textures must currently be pre-flipped vertically (before compression) when using the native .astc file format with DALI. An example .astc file is included as part of the unit tests. Change-Id: I8604fba28bfb83b0deff8689fd5d7cfb8ac770bb
Showing
5 changed files
with
25 additions
and
17 deletions
build/tizen/CMakeLists.txt
| ... | ... | @@ -42,15 +42,16 @@ SET(DALI_EXAMPLE_BIN \\"${BINDIR}/\\") |
| 42 | 42 | SET(DALI_LOCALE_DIR \\"${LOCALE_DIR}\\") |
| 43 | 43 | SET(DALI_LANG \\"${LANG}\\") |
| 44 | 44 | |
| 45 | -FILE(GLOB LOCAL_IMAGES_PNG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.png") | |
| 46 | -FILE(GLOB LOCAL_IMAGES_JPG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.jpg") | |
| 47 | -FILE(GLOB LOCAL_IMAGES_GIF RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.gif") | |
| 48 | -FILE(GLOB LOCAL_IMAGES_BMP RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.bmp") | |
| 49 | -FILE(GLOB LOCAL_IMAGES_ICO RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.ico") | |
| 45 | +FILE(GLOB LOCAL_IMAGES_PNG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.png") | |
| 46 | +FILE(GLOB LOCAL_IMAGES_JPG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.jpg") | |
| 47 | +FILE(GLOB LOCAL_IMAGES_GIF RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.gif") | |
| 48 | +FILE(GLOB LOCAL_IMAGES_BMP RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.bmp") | |
| 49 | +FILE(GLOB LOCAL_IMAGES_ICO RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.ico") | |
| 50 | 50 | FILE(GLOB LOCAL_IMAGES_WBMP RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.wbmp") |
| 51 | -FILE(GLOB LOCAL_IMAGES_KTX RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.ktx") | |
| 51 | +FILE(GLOB LOCAL_IMAGES_KTX RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.ktx") | |
| 52 | +FILE(GLOB LOCAL_IMAGES_ASTC RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.astc") | |
| 52 | 53 | |
| 53 | -SET(LOCAL_IMAGES_LIST ${LOCAL_IMAGES_PNG};${LOCAL_IMAGES_JPG};${LOCAL_IMAGES_GIF};${LOCAL_IMAGES_BMP};${LOCAL_IMAGES_ICO};${LOCAL_IMAGES_WBMP};${LOCAL_IMAGES_KTX}) | |
| 54 | +SET(LOCAL_IMAGES_LIST ${LOCAL_IMAGES_PNG};${LOCAL_IMAGES_JPG};${LOCAL_IMAGES_GIF};${LOCAL_IMAGES_BMP};${LOCAL_IMAGES_ICO};${LOCAL_IMAGES_WBMP};${LOCAL_IMAGES_KTX};${LOCAL_IMAGES_ASTC}) | |
| 54 | 55 | FOREACH(flag ${LOCAL_IMAGES_LIST}) |
| 55 | 56 | INSTALL(FILES ${LOCAL_IMAGES_DIR}/${flag} DESTINATION ${IMAGES_DIR}) |
| 56 | 57 | ENDFOREACH(flag) | ... | ... |
examples/compressed-texture-formats/compressed-texture-formats-example.cpp
| ... | ... | @@ -20,9 +20,9 @@ |
| 20 | 20 | using namespace Dali; |
| 21 | 21 | using Dali::Toolkit::TextLabel; |
| 22 | 22 | |
| 23 | -const char* IMAGE_FILENAME_ETC = DALI_IMAGE_DIR "tx-etc1.ktx"; | |
| 24 | -const char* IMAGE_FILENAME_ASTC_LINEAR = DALI_IMAGE_DIR "tx-astc-4x4-linear.ktx"; | |
| 25 | -const char* IMAGE_FILENAME_ASTC_SRGB = DALI_IMAGE_DIR "tx-astc-4x4-srgb.ktx"; | |
| 23 | +const char* IMAGE_FILENAME_ETC = DALI_IMAGE_DIR "tx-etc1.ktx"; | |
| 24 | +const char* IMAGE_FILENAME_ASTC_LINEAR = DALI_IMAGE_DIR "tx-astc-4x4-linear.ktx"; | |
| 25 | +const char* IMAGE_FILENAME_ASTC_LINEAR_NATIVE = DALI_IMAGE_DIR "tx-astc-4x4-linear-native.astc"; | |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @brief This example shows 3 images, each of a different compressed texture type. |
| ... | ... | @@ -57,28 +57,35 @@ public: |
| 57 | 57 | table.SetAnchorPoint( AnchorPoint::CENTER ); |
| 58 | 58 | table.SetParentOrigin( ParentOrigin::CENTER ); |
| 59 | 59 | table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 60 | - table.SetFitHeight( 0u ); | |
| 61 | - table.SetFitHeight( 1u ); | |
| 62 | - table.SetFitHeight( 2u ); | |
| 63 | 60 | table.SetRelativeWidth( 0u, 0.5f ); |
| 64 | 61 | table.SetRelativeWidth( 1u, 0.5f ); |
| 62 | + table.SetRelativeHeight( 0u, 1.0f / 3.0f ); | |
| 63 | + table.SetRelativeHeight( 1u, 1.0f / 3.0f ); | |
| 64 | + table.SetRelativeHeight( 2u, 1.0f / 3.0f ); | |
| 65 | + | |
| 65 | 66 | |
| 66 | 67 | // Add text labels. |
| 67 | - TextLabel textLabel = TextLabel::New( "ETC1:" ); | |
| 68 | + TextLabel textLabel = TextLabel::New( "ETC1 (KTX):" ); | |
| 68 | 69 | textLabel.SetAnchorPoint( AnchorPoint::CENTER ); |
| 69 | 70 | textLabel.SetParentOrigin( ParentOrigin::CENTER ); |
| 71 | + textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 72 | + textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); | |
| 70 | 73 | table.AddChild( textLabel, Toolkit::TableView::CellPosition( 0u, 0u ) ); |
| 71 | 74 | table.SetCellAlignment( Toolkit::TableView::CellPosition( 0u, 0u ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER ); |
| 72 | 75 | |
| 73 | - textLabel = TextLabel::New( "ASTC 4x4 linear:" ); | |
| 76 | + textLabel = TextLabel::New( "ASTC (KTX) 4x4 linear:" ); | |
| 74 | 77 | textLabel.SetAnchorPoint( AnchorPoint::CENTER ); |
| 75 | 78 | textLabel.SetParentOrigin( ParentOrigin::CENTER ); |
| 79 | + textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 80 | + textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); | |
| 76 | 81 | table.AddChild( textLabel, Toolkit::TableView::CellPosition( 1u, 0u ) ); |
| 77 | 82 | table.SetCellAlignment( Toolkit::TableView::CellPosition( 1u, 0u ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER ); |
| 78 | 83 | |
| 79 | - textLabel = TextLabel::New( "ASTC 4x4 sRGB:" ); | |
| 84 | + textLabel = TextLabel::New( "ASTC (Native) 4x4 linear:" ); | |
| 80 | 85 | textLabel.SetAnchorPoint( AnchorPoint::CENTER ); |
| 81 | 86 | textLabel.SetParentOrigin( ParentOrigin::CENTER ); |
| 87 | + textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 88 | + textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); | |
| 82 | 89 | table.AddChild( textLabel, Toolkit::TableView::CellPosition( 2u, 0u ) ); |
| 83 | 90 | table.SetCellAlignment( Toolkit::TableView::CellPosition( 2u, 0u ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER ); |
| 84 | 91 | |
| ... | ... | @@ -93,7 +100,7 @@ public: |
| 93 | 100 | imageView.SetParentOrigin( ParentOrigin::CENTER ); |
| 94 | 101 | table.AddChild( imageView, Toolkit::TableView::CellPosition( 1u, 1u ) ); |
| 95 | 102 | |
| 96 | - imageView = Toolkit::ImageView::New( ResourceImage::New( IMAGE_FILENAME_ASTC_SRGB ) ); | |
| 103 | + imageView = Toolkit::ImageView::New( ResourceImage::New( IMAGE_FILENAME_ASTC_LINEAR_NATIVE ) ); | |
| 97 | 104 | imageView.SetAnchorPoint( AnchorPoint::CENTER ); |
| 98 | 105 | imageView.SetParentOrigin( ParentOrigin::CENTER ); |
| 99 | 106 | table.AddChild( imageView, Toolkit::TableView::CellPosition( 2u, 1u ) ); | ... | ... |
resources/images/tx-astc-4x4-linear-native.astc
0 → 100644
No preview for this file type
resources/images/tx-astc-4x4-linear.ktx
No preview for this file type
resources/images/tx-astc-4x4-srgb.ktx
No preview for this file type