Merge branch 'main' into ly-as-sdk/LYN-2948
This commit is contained in:
@@ -236,8 +236,6 @@ namespace AzFramework
|
||||
// Archive classes relies on the FileIOBase DirectInstance to close
|
||||
// files properly
|
||||
m_directFileIO.reset();
|
||||
|
||||
// The AZ::Console skips destruction and always leaks to allow it to be used in static memory
|
||||
}
|
||||
|
||||
void Application::Start(const Descriptor& descriptor, const StartupParameters& startupParameters)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace AZ::IO
|
||||
ePakPriorityPakOnly = 2
|
||||
};
|
||||
|
||||
// variables that control behavior of Archive/StreamEngine subsystems
|
||||
// variables that control behavior of the Archive subsystem
|
||||
struct ArchiveVars
|
||||
{
|
||||
#if defined(_RELEASE)
|
||||
|
||||
@@ -881,7 +881,7 @@ namespace AzFramework
|
||||
serializeContext->ClassDeprecate("NetBindable", "{80206665-D429-4703-B42E-94434F82F381}");
|
||||
|
||||
serializeContext->Class<TransformComponent, AZ::Component>()
|
||||
->Version(4, &TransformComponentVersionConverter)
|
||||
->Version(5, &TransformComponentVersionConverter)
|
||||
->Field("Parent", &TransformComponent::m_parentId)
|
||||
->Field("Transform", &TransformComponent::m_worldTM)
|
||||
->Field("LocalTransform", &TransformComponent::m_localTM)
|
||||
|
||||
@@ -40,17 +40,18 @@ namespace AzFramework
|
||||
//! Standard parameters for drawing text on screen
|
||||
struct TextDrawParameters
|
||||
{
|
||||
ViewportId m_drawViewportId = InvalidViewportId; //! Viewport to draw into
|
||||
AZ::Vector3 m_position; //! world space position for 3d draws, screen space x,y,depth for 2d.
|
||||
AZ::Color m_color = AZ::Colors::White; //! Color to draw the text
|
||||
AZ::Vector2 m_scale = AZ::Vector2(1.0f); //! font scale
|
||||
TextHorizontalAlignment m_hAlign = TextHorizontalAlignment::Left; //! Horizontal text alignment
|
||||
TextVerticalAlignment m_vAlign = TextVerticalAlignment::Top; //! Vertical text alignment
|
||||
bool m_monospace = false; //! disable character proportional spacing
|
||||
bool m_depthTest = false; //! Test character against the depth buffer
|
||||
bool m_virtual800x600ScreenSize = true; //! Text placement and size are scaled relative to a virtual 800x600 resolution
|
||||
bool m_scaleWithWindow = false; //! Font gets bigger as the window gets bigger
|
||||
bool m_multiline = true; //! text respects ascii newline characters
|
||||
ViewportId m_drawViewportId = InvalidViewportId; //!< Viewport to draw into
|
||||
AZ::Vector3 m_position; //!< world space position for 3d draws, screen space x,y,depth for 2d.
|
||||
AZ::Color m_color = AZ::Colors::White; //!< Color to draw the text
|
||||
AZ::Vector2 m_scale = AZ::Vector2(1.0f); //!< font scale
|
||||
float m_lineSpacing; //!< Spacing between new lines, as a percentage of m_scale.
|
||||
TextHorizontalAlignment m_hAlign = TextHorizontalAlignment::Left; //!< Horizontal text alignment
|
||||
TextVerticalAlignment m_vAlign = TextVerticalAlignment::Top; //!< Vertical text alignment
|
||||
bool m_monospace = false; //!< disable character proportional spacing
|
||||
bool m_depthTest = false; //!< Test character against the depth buffer
|
||||
bool m_virtual800x600ScreenSize = true; //!< Text placement and size are scaled relative to a virtual 800x600 resolution
|
||||
bool m_scaleWithWindow = false; //!< Font gets bigger as the window gets bigger
|
||||
bool m_multiline = true; //!< text respects ascii newline characters
|
||||
};
|
||||
|
||||
class FontDrawInterface
|
||||
@@ -63,10 +64,13 @@ namespace AzFramework
|
||||
|
||||
virtual void DrawScreenAlignedText2d(
|
||||
const TextDrawParameters& params,
|
||||
const AZStd::string_view& string) = 0;
|
||||
AZStd::string_view text) = 0;
|
||||
virtual void DrawScreenAlignedText3d(
|
||||
const TextDrawParameters& params,
|
||||
const AZStd::string_view& string) = 0;
|
||||
AZStd::string_view text) = 0;
|
||||
virtual AZ::Vector2 GetTextSize(
|
||||
const TextDrawParameters& params,
|
||||
AZStd::string_view text) = 0;
|
||||
};
|
||||
|
||||
class FontQueryInterface
|
||||
|
||||
@@ -979,7 +979,7 @@ namespace AzFramework
|
||||
};
|
||||
|
||||
serializeContext->Class<ScriptComponent, AZ::Component>()
|
||||
->Version(3, converter)
|
||||
->Version(4, converter)
|
||||
->Field("ContextID", &ScriptComponent::m_contextId)
|
||||
->Field("Properties", &ScriptComponent::m_properties)
|
||||
->Field("Script", &ScriptComponent::m_script)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Description : Ebus for querying thermal information of the device.
|
||||
|
||||
#pragma once
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
|
||||
// The different types of temperature sensor that could be available on the device.
|
||||
enum class ThermalSensorType : int
|
||||
{
|
||||
CPU = 0,
|
||||
GPU,
|
||||
Battery,
|
||||
Count
|
||||
};
|
||||
|
||||
// Handles requests for thermal information
|
||||
class ThermalInfoHandler : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
|
||||
virtual ~ThermalInfoHandler() = default;
|
||||
|
||||
/**
|
||||
* Returns the current temperature of a specific sensor in Celcius degrees.
|
||||
* If the type of sensor is not available on the device it returns 0.
|
||||
*
|
||||
* \param sensor The sensor type.
|
||||
*/
|
||||
virtual float GetSensorTemp(ThermalSensorType sensor) = 0;
|
||||
|
||||
/**
|
||||
* Returns the temperature that is considered as overheating for a specific sensor.
|
||||
* The value returned is in Celcius degrees.
|
||||
*
|
||||
* \param sensor The sensor type.
|
||||
*/
|
||||
virtual float GetSensorOverheatingTemp(ThermalSensorType sensor) = 0;
|
||||
};
|
||||
|
||||
using ThermalInfoRequestsBus = AZ::EBus<ThermalInfoHandler>;
|
||||
|
||||
|
||||
@@ -296,6 +296,7 @@ set(FILES
|
||||
Spawnable/SpawnableSystemComponent.cpp
|
||||
Terrain/TerrainDataRequestBus.h
|
||||
Terrain/TerrainDataRequestBus.cpp
|
||||
Thermal/ThermalInfo.h
|
||||
Platform/PlatformDefaults.h
|
||||
Windowing/WindowBus.h
|
||||
Windowing/NativeWindow.cpp
|
||||
|
||||
+6
@@ -13,6 +13,7 @@
|
||||
#include <AzFramework/API/ApplicationAPI_Platform.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
|
||||
#include <AzFramework/Thermal/ThermalInfo_Android.h>
|
||||
|
||||
#include <AzCore/Android/AndroidEnv.h>
|
||||
#include <AzCore/Android/JNI/Object.h>
|
||||
@@ -95,6 +96,7 @@ namespace AzFramework
|
||||
private:
|
||||
AndroidEventDispatcher* m_eventDispatcher;
|
||||
ApplicationLifecycleEvents::Event m_lastEvent;
|
||||
AZStd::unique_ptr<ThermalInfoHandler> m_thermalInfoHandler;
|
||||
|
||||
AZStd::atomic<bool> m_requestResponseReceived;
|
||||
AZStd::unique_ptr<AZ::Android::JNI::Object> m_lumberyardActivity;
|
||||
@@ -125,6 +127,10 @@ namespace AzFramework
|
||||
AndroidLifecycleEvents::Bus::Handler::BusConnect();
|
||||
AndroidAppRequests::Bus::Handler::BusConnect();
|
||||
PermissionRequestResultNotification::Bus::Handler::BusConnect();
|
||||
|
||||
#if !defined(AZ_RELEASE_BUILD)
|
||||
m_thermalInfoHandler = AZStd::make_unique<ThermalInfoAndroidHandler>();
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(AZ_RELEASE_BUILD)
|
||||
#include "ThermalInfo_Android.h"
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
ThermalInfoAndroidHandler::ThermalInfoAndroidHandler()
|
||||
{
|
||||
static_assert(AZ_ARRAY_SIZE(m_temperatureFiles) == static_cast<int>(ThermalSensorType::Count), "Thermal count does not match temperature array size");
|
||||
ThermalInfoRequestsBus::Handler::BusConnect();
|
||||
memset(m_temperatureFiles, 0, sizeof(m_temperatureFiles));
|
||||
|
||||
const int sensorCount = static_cast<int>(ThermalSensorType::Count);
|
||||
const char* sensorTypes[sensorCount] = { "cpu", "gpu", "battery" };
|
||||
const int maxStringLen = 128;
|
||||
char tempString[maxStringLen];
|
||||
const char* thermalPath = "/sys/class/thermal";
|
||||
// List the elements from the thermal folder to get the thermal_zones available on the device
|
||||
DIR* directory = opendir(thermalPath);
|
||||
if (directory)
|
||||
{
|
||||
struct dirent* item;
|
||||
const char* thermalPrefix = "thermal_zone";
|
||||
// List all items of the directory and find the one that start with thermal_zone (thermal_zone0, thermal_zone1, etc)
|
||||
while ((item = readdir(directory)) != nullptr)
|
||||
{
|
||||
if (strncmp(item->d_name, thermalPrefix, strlen(thermalPrefix)) == 0)
|
||||
{
|
||||
// Try to deduce the type of sensor. For this we read the "type" file of the thermal zone.
|
||||
// This "type" is a string set by the manufacturer, so it can be anything.
|
||||
AZStd::string path = AZStd::string::format("%s/%s/type", thermalPath, item->d_name);
|
||||
FILE* sensorTypeFile = fopen(path.c_str(), "r");
|
||||
if (sensorTypeFile)
|
||||
{
|
||||
if (fscanf(sensorTypeFile, "%s", tempString))
|
||||
{
|
||||
for (int i = 0; i < sensorCount; ++i)
|
||||
{
|
||||
if (m_temperatureFiles[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t foundPos = AzFramework::StringFunc::Find(tempString, sensorTypes[i]);
|
||||
if (foundPos != AZStd::string::npos)
|
||||
{
|
||||
path = AZStd::string::format("%s/%s/temp", thermalPath, item->d_name);
|
||||
m_temperatureFiles[i] = fopen(path.c_str(), "r");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(sensorTypeFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(directory);
|
||||
}
|
||||
|
||||
int cpuSensorIndex = static_cast<int>(ThermalSensorType::CPU);
|
||||
if (!m_temperatureFiles[cpuSensorIndex])
|
||||
{
|
||||
// If we didn't find the CPU sensor just assume it's the first one.
|
||||
AZStd::string path = AZStd::string::format("%s/thermal_zone0/temp", thermalPath);
|
||||
m_temperatureFiles[cpuSensorIndex] = fopen(path.c_str(), "r");
|
||||
}
|
||||
}
|
||||
|
||||
ThermalInfoAndroidHandler::~ThermalInfoAndroidHandler()
|
||||
{
|
||||
ThermalInfoRequestsBus::Handler::BusDisconnect();
|
||||
for (int i = 0; i < static_cast<int>(ThermalSensorType::Count); ++i)
|
||||
{
|
||||
if (m_temperatureFiles[i])
|
||||
{
|
||||
fclose(m_temperatureFiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float ThermalInfoAndroidHandler::GetSensorTemp(ThermalSensorType sensor)
|
||||
{
|
||||
FILE* tempFile = m_temperatureFiles[static_cast<int>(sensor)];
|
||||
if (!tempFile)
|
||||
{
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
fseek(tempFile, 0, SEEK_SET);
|
||||
float temperature = 0.f;
|
||||
fscanf(tempFile, "%f", &temperature);
|
||||
temperature /= 1000.0f;
|
||||
return temperature;
|
||||
}
|
||||
|
||||
float ThermalInfoAndroidHandler::GetSensorOverheatingTemp(ThermalSensorType sensor)
|
||||
{
|
||||
const int overheatingTemperatures[static_cast<int>(ThermalSensorType::Count)] =
|
||||
{
|
||||
70, // CPU
|
||||
70, // GPU
|
||||
40 // Battery
|
||||
};
|
||||
|
||||
return overheatingTemperatures[static_cast<int>(sensor)];
|
||||
}
|
||||
|
||||
#endif // !defined(AZ_RELEASE_BUILD)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(AZ_RELEASE_BUILD)
|
||||
#include <AzFramework/Thermal/ThermalInfo.h>
|
||||
|
||||
class ThermalInfoAndroidHandler : public ThermalInfoRequestsBus::Handler
|
||||
{
|
||||
public:
|
||||
ThermalInfoAndroidHandler();
|
||||
~ThermalInfoAndroidHandler() override;
|
||||
|
||||
float GetSensorTemp(ThermalSensorType sensor) override;
|
||||
float GetSensorOverheatingTemp(ThermalSensorType sensor) override;
|
||||
|
||||
private:
|
||||
FILE* m_temperatureFiles[static_cast<int>(ThermalSensorType::Count)];
|
||||
};
|
||||
#endif // !defined(AZ_RELEASE_BUILD)
|
||||
@@ -36,4 +36,6 @@ set(FILES
|
||||
AzFramework/Process/ProcessCommon.h
|
||||
AzFramework/Process/ProcessWatcher_Android.cpp
|
||||
AzFramework/Process/ProcessCommunicator_Android.cpp
|
||||
AzFramework/Thermal/ThermalInfo_Android.cpp
|
||||
AzFramework/Thermal/ThermalInfo_Android.h
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user