3
0

EditorCommon.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <BuilderSettings/BuilderSettingManager.h>
  10. #include <BuilderSettings/TextureSettings.h>
  11. #include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
  12. #include <Processing/PixelFormatInfo.h>
  13. #include <Atom/ImageProcessing/ImageObject.h>
  14. #include <AzCore/std/smart_ptr/make_shared.h>
  15. AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
  16. #include <QImage>
  17. #include <QWidget>
  18. #include <QMainWindow>
  19. #include <QApplication>
  20. AZ_POP_DISABLE_WARNING
  21. namespace ImageProcessingAtomEditor
  22. {
  23. class EditorHelper
  24. {
  25. public:
  26. static const char* s_PixelFormatString[ImageProcessingAtom::EPixelFormat::ePixelFormat_Count];
  27. static void InitPixelFormatString();
  28. static const AZStd::string GetFileSizeString(size_t fileSizeInBytes);
  29. static const AZStd::string ToReadablePlatformString(const AZStd::string& platformRawStr);
  30. private:
  31. static bool s_IsPixelFormatStringInited;
  32. };
  33. struct ResolutionInfo
  34. {
  35. AZ::u32 width = 0;
  36. AZ::u32 height = 0;
  37. AZ::u32 arrayCount = 1;
  38. AZ::u32 reduce = 0;
  39. AZ::u32 mipCount = 0;
  40. };
  41. struct EditorTextureSetting
  42. {
  43. AZStd::string m_textureName = "";
  44. AZStd::string m_fullPath = "";
  45. ImageProcessingAtom::MultiplatformTextureSettings m_settingsMap;
  46. bool m_overrideFromPreset = false;
  47. bool m_modified = false;
  48. ImageProcessingAtom::IImageObjectPtr m_img;
  49. EditorTextureSetting(const AZ::Uuid& sourceTextureId);
  50. EditorTextureSetting(const AZStd::string& texturePath);
  51. ~EditorTextureSetting() = default;
  52. void InitFromPath(const AZStd::string& texturePath);
  53. void SetIsOverrided();
  54. void SetToPreset(const ImageProcessingAtom::PresetName& presetName);
  55. //Get the texture setting on certain platform
  56. ImageProcessingAtom::TextureSettings& GetMultiplatformTextureSetting(const AZStd::string& platform = "");
  57. //Gets the final resolution/reduce/mip count for a texture on a certain platform
  58. //@param wantedReduce indicates the reduce level that's preferred
  59. //@return successfully get the value or not
  60. bool GetFinalInfoForTextureOnPlatform(const AZStd::string& platform, AZ::u32 wantedReduce, ResolutionInfo& outResolutionInfo);
  61. //Refresh the mip setting when the mip map setting is enabled/disabled.
  62. //@return whether the mipmap is enabled or not.
  63. bool RefreshMipSetting(bool enableMip);
  64. //Propagate non platform specific settings from the first setting to all the settings stored in m_settingsMap
  65. void PropagateCommonSettings();
  66. //Returns a list of calculated final resolution info based on different base reduce levels
  67. AZStd::list<ResolutionInfo> GetResolutionInfo(AZStd::string platform, AZ::u32& minReduce, AZ::u32& maxReduce);
  68. //Returns a list of calculated final resolution info based on different mipmap levels
  69. AZStd::list<ResolutionInfo> GetResolutionInfoForMipmap(AZStd::string platform);
  70. };
  71. class ImageProcessingEditorInteralNotifications
  72. : public AZ::EBusTraits
  73. {
  74. public:
  75. //////////////////////////////////////////////////////////////////////////
  76. // EBusTraits overrides
  77. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
  78. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  79. /////////////////////////////////////////////////////////////////////////
  80. //! Used to inform the settings changed across widgets
  81. virtual void OnEditorSettingsChanged(bool needRefresh, const AZStd::string& platform) = 0;
  82. };
  83. using EditorInternalNotificationBus = AZ::EBus<ImageProcessingEditorInteralNotifications>;
  84. } //namespace ImageProcessingAtomEditor