Address review feedback

Signed-off-by: nvsickle <nvsickle@amazon.com>
main
nvsickle 5 years ago
parent dd20a598b2
commit 21dbe8b48f

@ -69,7 +69,7 @@ namespace AzFramework
//! Toggle the full screen state of the window. //! Toggle the full screen state of the window.
virtual void ToggleFullScreenState() = 0; virtual void ToggleFullScreenState() = 0;
//! Returns a scalar multiplier representing how dots-per-inch this window has, compared //! Returns a scalar multiplier representing how many dots-per-inch this window has, compared
//! to a "standard" value of 96, the default for Windows in a DPI unaware setting. This can //! to a "standard" value of 96, the default for Windows in a DPI unaware setting. This can
//! be used to scale user interface elements to ensure legibility on high density displays. //! be used to scale user interface elements to ensure legibility on high density displays.
virtual float GetDpiScaleFactor() const = 0; virtual float GetDpiScaleFactor() const = 0;

@ -65,8 +65,7 @@ namespace AzFramework
NativeWindowImpl_Win32::NativeWindowImpl_Win32() NativeWindowImpl_Win32::NativeWindowImpl_Win32()
{ {
// Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607 // Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607
auto user32module = LoadLibraryA("user32.dll"); if (auto user32module = LoadLibraryA("user32.dll"))
if (user32module)
{ {
m_getDpiFunction = reinterpret_cast<GetDpiForWindowType*>(GetProcAddress(user32module, "GetDpiForWindow")); m_getDpiFunction = reinterpret_cast<GetDpiForWindowType*>(GetProcAddress(user32module, "GetDpiForWindow"));
} }
@ -255,6 +254,7 @@ namespace AzFramework
{ {
const float newScaleFactor = nativeWindowImpl->GetDpiScaleFactor(); const float newScaleFactor = nativeWindowImpl->GetDpiScaleFactor();
WindowNotificationBus::Event(nativeWindowImpl->GetWindowHandle(), &WindowNotificationBus::Events::OnDpiScaleFactorChanged, newScaleFactor); WindowNotificationBus::Event(nativeWindowImpl->GetWindowHandle(), &WindowNotificationBus::Events::OnDpiScaleFactorChanged, newScaleFactor);
break;
} }
default: default:
return DefWindowProc(hWnd, message, wParam, lParam); return DefWindowProc(hWnd, message, wParam, lParam);

@ -65,15 +65,15 @@ namespace AZ
ConstViewPtr GetDefaultView() const; ConstViewPtr GetDefaultView() const;
//! Gets the current size of the viewport. //! Gets the current size of the viewport.
//! This value is cached and updated on-demand, so may be performantly queried. //! This value is cached and updated on-demand, so may be efficiently queried.
AzFramework::WindowSize GetViewportSize() const; AzFramework::WindowSize GetViewportSize() const;
//! Gets the screen DPI scaling factor. //! Gets the screen DPI scaling factor.
//! This value is cached and updated on-demand, so may be performantly queried. //! This value is cached and updated on-demand, so may be efficiently queried.
//! \see AzFramework::WindowRequests::GetDpiScaleFactor //! \see AzFramework::WindowRequests::GetDpiScaleFactor
float GetDpiScalingFactor() const; float GetDpiScalingFactor() const;
// SceneNotificationBus interface // SceneNotificationBus interface overrides...
//! Ensures our default view remains set when our scene's render pipelines are modified. //! Ensures our default view remains set when our scene's render pipelines are modified.
void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override; void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override;
//! Ensures our default view remains set when our scene's render pipelines are modified. //! Ensures our default view remains set when our scene's render pipelines are modified.
@ -81,7 +81,7 @@ namespace AZ
//! OnBeginPrepareRender is forwarded to our RenderTick notification to allow subscribers to do rendering. //! OnBeginPrepareRender is forwarded to our RenderTick notification to allow subscribers to do rendering.
void OnBeginPrepareRender() override; void OnBeginPrepareRender() override;
//WindowNotificationBus interface // WindowNotificationBus interface overrides...
//! Used to fire a notification when our window resizes. //! Used to fire a notification when our window resizes.
void OnWindowResized(uint32_t width, uint32_t height) override; void OnWindowResized(uint32_t width, uint32_t height) override;
//! Used to fire a notification when our window DPI changes. //! Used to fire a notification when our window DPI changes.
@ -119,7 +119,7 @@ namespace AZ
//! Notifies consumers when this ViewportContext is about to be destroyed. //! Notifies consumers when this ViewportContext is about to be destroyed.
void ConnectAboutToBeDestroyedHandler(ViewportIdEvent::Handler& handler); void ConnectAboutToBeDestroyedHandler(ViewportIdEvent::Handler& handler);
// ViewportRequestBus interface // ViewportRequestBus interface overrides...
//! Gets the current camera's view matrix. //! Gets the current camera's view matrix.
const AZ::Matrix4x4& GetCameraViewMatrix() const override; const AZ::Matrix4x4& GetCameraViewMatrix() const override;
//! Sets the current camera's view matrix. //! Sets the current camera's view matrix.

@ -10,7 +10,6 @@
#include <Atom/RPI.Public/ViewportContextBus.h> #include <Atom/RPI.Public/ViewportContextBus.h>
#include <Atom/RPI.Public/ViewportContextManager.h> #include <Atom/RPI.Public/ViewportContextManager.h>
#include <Atom/RPI.Public/View.h> #include <Atom/RPI.Public/View.h>
#include "..\..\Include\Atom\RPI.Public\ViewportContext.h"
namespace AZ namespace AZ
{ {

@ -55,7 +55,7 @@ namespace AZ
auto onSizeChanged = [this, viewportId](AzFramework::WindowSize size) auto onSizeChanged = [this, viewportId](AzFramework::WindowSize size)
{ {
// Ensure we emit OnViewportSizeChanged with the correct name. // Ensure we emit OnViewportSizeChanged with the correct name.
auto viewportContext = this->GetViewportContextById(viewportId); auto viewportContext = GetViewportContextById(viewportId);
if (viewportContext) if (viewportContext)
{ {
ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportSizeChanged, size); ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportSizeChanged, size);
@ -65,7 +65,7 @@ namespace AZ
auto onDpiScalingChanged = [this, viewportId](float dpiScalingFactor) auto onDpiScalingChanged = [this, viewportId](float dpiScalingFactor)
{ {
// Ensure we emit OnViewportDpiScalingChanged with the correct name. // Ensure we emit OnViewportDpiScalingChanged with the correct name.
auto viewportContext = this->GetViewportContextById(viewportId); auto viewportContext = GetViewportContextById(viewportId);
if (viewportContext) if (viewportContext)
{ {
ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportDpiScalingChanged, dpiScalingFactor); ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportDpiScalingChanged, dpiScalingFactor);

@ -157,7 +157,7 @@ namespace AZ::Render
auto viewportSize = viewportContext->GetViewportSize(); auto viewportSize = viewportContext->GetViewportSize();
m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding); m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding);
m_drawParams.m_color = AZ::Colors::White; m_drawParams.m_color = AZ::Colors::White;
m_drawParams.m_scale = AZ::Vector2(0.7f * viewportContext->GetDpiScalingFactor()); m_drawParams.m_scale = AZ::Vector2(BaseFontSize * viewportContext->GetDpiScalingFactor());
m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right; m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right;
m_drawParams.m_monospace = false; m_drawParams.m_monospace = false;
m_drawParams.m_depthTest = false; m_drawParams.m_depthTest = false;

@ -60,6 +60,8 @@ namespace AZ
void DrawPassInfo(); void DrawPassInfo();
void DrawFramerate(); void DrawFramerate();
static constexpr float BaseFontSize = 0.7f;
AZStd::string m_rendererDescription; AZStd::string m_rendererDescription;
AzFramework::TextDrawParameters m_drawParams; AzFramework::TextDrawParameters m_drawParams;
AzFramework::FontDrawInterface* m_fontDrawInterface = nullptr; AzFramework::FontDrawInterface* m_fontDrawInterface = nullptr;

@ -50,7 +50,8 @@ namespace AZ
{ {
ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect(); ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect();
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get(); auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get();
AZ_Assert(atomViewportRequests, "AtomViewportContextRequests interface not found!");
const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName(); const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName();
AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName); AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName);
@ -105,7 +106,7 @@ namespace AZ
// Let our ImguiAtomSystemComponent know once we successfully connect and update the viewport size. // Let our ImguiAtomSystemComponent know once we successfully connect and update the viewport size.
if (!m_initialized) if (!m_initialized)
{ {
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get(); auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get();
auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext(); auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext();
OnViewportDpiScalingChanged(defaultViewportContext->GetDpiScalingFactor()); OnViewportDpiScalingChanged(defaultViewportContext->GetDpiScalingFactor());
m_initialized = true; m_initialized = true;

Loading…
Cancel
Save