Initial phase of UI Canvas Editor rendering with Atom (#164)
* Move Draw2d.h to Include folder * Initial phase of UI Canvas Editor rendering with Atom * Simplify Draw2d by removing BeginDraw2d/EndDraw2d which is no longer needed * Fix compile errors for non-unity builds
This commit is contained in:
+207
-105
@@ -10,17 +10,24 @@
|
||||
*
|
||||
*/
|
||||
#include "LyShine_precompiled.h"
|
||||
#include "Draw2d.h"
|
||||
#include "IFont.h"
|
||||
#include "IRenderer.h"
|
||||
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/MatrixUtils.h>
|
||||
|
||||
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
#include <Atom/RPI.Public/Shader/Shader.h>
|
||||
#include <Atom/RPI.Public/Image/StreamingImage.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom/RPI.Public/ViewportContextBus.h>
|
||||
|
||||
static const int g_defaultBlendState = GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA;
|
||||
static const int g_defaultBaseState = GS_NODEPTHTEST;
|
||||
|
||||
static const int g_2dModeNotStarted = -1;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LOCAL STATIC FUNCTIONS
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -37,9 +44,9 @@ static AZ::u32 PackARGB8888(const AZ::Color& color)
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
CDraw2d::CDraw2d()
|
||||
CDraw2d::CDraw2d(AZ::RPI::ViewportContextPtr viewportContext)
|
||||
: m_deferCalls(false)
|
||||
, m_nestLevelAtWhichStarted2dMode(g_2dModeNotStarted)
|
||||
, m_viewportContext(viewportContext)
|
||||
{
|
||||
// These default options are set here and never change. They are stored so that if a null options
|
||||
// structure is passed into the draw functions then this default one can be used instead
|
||||
@@ -57,78 +64,75 @@ CDraw2d::CDraw2d()
|
||||
m_defaultTextOptions.dropShadowColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
m_defaultTextOptions.rotation = 0.0f;
|
||||
m_defaultTextOptions.baseState = g_defaultBaseState;
|
||||
|
||||
AZ::Render::Bootstrap::NotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
CDraw2d::~CDraw2d()
|
||||
{
|
||||
AZ::Render::Bootstrap::NotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::BeginDraw2d(bool deferCalls)
|
||||
void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapScene)
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
AZ::Vector2 viewportSize(
|
||||
static_cast<float>(renderer->GetOverlayWidth()),
|
||||
static_cast<float>(renderer->GetOverlayHeight()));
|
||||
BeginDraw2d(viewportSize, deferCalls);
|
||||
}
|
||||
// At this point the RPI is ready for use
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::BeginDraw2d(AZ::Vector2 viewportSize, bool deferCalls)
|
||||
{
|
||||
// So that nested calls to BeginDraw2d/EndDraw2d do not end 2D drawmode prematurely we only
|
||||
// switch to 2D mode once and do not do it again until the corresponding call to EndDraw2d
|
||||
// is processed.
|
||||
// It may seem overkill to allow nested calls rather than just asserting in that case. But
|
||||
// a) it is more flexible to do so
|
||||
// b) it can be useful to draw some debug primitives in deferred mode while rendering a
|
||||
// canvas in non-deferred mode for example
|
||||
// Load the shader to be used for 2d drawing
|
||||
const char* shaderFilepath = "Shaders/SimpleTextured.azshader";
|
||||
AZ::Data::Instance<AZ::RPI::Shader> shader = AZ::RPI::LoadShader(shaderFilepath);
|
||||
|
||||
// Push the current state of the m_deferCalls onto a stack to support nested calls
|
||||
m_deferCallsFlagStack.push(m_deferCalls);
|
||||
|
||||
m_deferCalls = deferCalls;
|
||||
|
||||
// if this is the outermost call with non-deferred rendering then switch to 2D mode
|
||||
if (!m_deferCalls && m_nestLevelAtWhichStarted2dMode == g_2dModeNotStarted)
|
||||
// Set scene to be associated with the dynamic draw context
|
||||
AZ::RPI::ScenePtr scene;
|
||||
if (m_viewportContext)
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
|
||||
renderer->SetCullMode(R_CULL_DISABLE);
|
||||
|
||||
renderer->Set2DMode(static_cast<uint32>(viewportSize.GetX()), static_cast<uint32>(viewportSize.GetY()), m_backupSceneMatrices);
|
||||
|
||||
renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
renderer->SetState(g_defaultBlendState | g_defaultBaseState);
|
||||
|
||||
// remember the nesting level that we turned on 2D mode so we can turn it off as
|
||||
// we unwind the stack
|
||||
m_nestLevelAtWhichStarted2dMode = m_deferCallsFlagStack.size();
|
||||
// Use scene associated with the specified viewport context
|
||||
scene = m_viewportContext->GetRenderScene();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::EndDraw2d()
|
||||
{
|
||||
// if we are ending a non-deferred series of calls and we turned on 2D draw mode when we started
|
||||
// this series then turn it off.
|
||||
if (!m_deferCalls && m_nestLevelAtWhichStarted2dMode == m_deferCallsFlagStack.size())
|
||||
else
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
renderer->Unset2DMode(m_backupSceneMatrices);
|
||||
m_nestLevelAtWhichStarted2dMode = -1;
|
||||
// No viewport context specified, use default scene
|
||||
scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene();
|
||||
}
|
||||
AZ_Assert(scene != nullptr, "Attempting to create a DynamicDrawContext for a viewport context that has not been associated with a scene yet.");
|
||||
|
||||
// unwind the nesting stack
|
||||
m_deferCalls = m_deferCallsFlagStack.top();
|
||||
m_deferCallsFlagStack.pop();
|
||||
// Create and initialize a DynamicDrawContext for 2d drawing
|
||||
m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(scene.get());
|
||||
AZ::RPI::ShaderOptionList shaderOptions;
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("true")));
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("false")));
|
||||
m_dynamicDraw->InitShaderWithVariant(shader, &shaderOptions);
|
||||
m_dynamicDraw->InitVertexFormat(
|
||||
{ {"POSITION", AZ::RHI::Format::R32G32B32_FLOAT},
|
||||
{"COLOR", AZ::RHI::Format::B8G8R8A8_UNORM},
|
||||
{"TEXCOORD0", AZ::RHI::Format::R32G32_FLOAT} });
|
||||
m_dynamicDraw->AddDrawStateOptions(AZ::RPI::DynamicDrawContext::DrawStateOptions::PrimitiveType
|
||||
| AZ::RPI::DynamicDrawContext::DrawStateOptions::BlendMode);
|
||||
m_dynamicDraw->EndInit();
|
||||
|
||||
AZ::RHI::TargetBlendState targetBlendState;
|
||||
targetBlendState.m_enable = true;
|
||||
targetBlendState.m_blendSource = AZ::RHI::BlendFactor::AlphaSource;
|
||||
targetBlendState.m_blendDest = AZ::RHI::BlendFactor::AlphaSourceInverse;
|
||||
m_dynamicDraw->SetTarget0BlendState(targetBlendState);
|
||||
|
||||
// Cache draw srg input indices for later use
|
||||
static const char textureIndexName[] = "m_texture";
|
||||
static const char worldToProjIndexName[] = "m_worldToProj";
|
||||
AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> drawSrg = m_dynamicDraw->NewDrawSrg();
|
||||
const AZ::RHI::ShaderResourceGroupLayout* layout = drawSrg->GetAsset()->GetLayout();
|
||||
m_shaderData.m_imageInputIndex = layout->FindShaderInputImageIndex(AZ::Name(textureIndexName));
|
||||
AZ_Error("Draw2d", m_shaderData.m_imageInputIndex.IsValid(), "Failed to find shader input constant %s.",
|
||||
textureIndexName);
|
||||
m_shaderData.m_viewProjInputIndex = layout->FindShaderInputConstantIndex(AZ::Name(worldToProjIndexName));
|
||||
AZ_Error("Draw2d", m_shaderData.m_viewProjInputIndex.IsValid(), "Failed to find shader input constant %s.",
|
||||
worldToProjIndexName);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Draw a textured quad with the top left corner at the given position.
|
||||
void CDraw2d::DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity,
|
||||
void CDraw2d::DrawImage(AZ::Data::Instance<AZ::RPI::Image> image, AZ::Vector2 position, AZ::Vector2 size, float opacity,
|
||||
float rotation, const AZ::Vector2* pivotPoint, const AZ::Vector2* minMaxTexCoords,
|
||||
ImageOptions* imageOptions)
|
||||
{
|
||||
@@ -169,7 +173,7 @@ void CDraw2d::DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float
|
||||
quad.m_texCoords[3].Set(0.0f, 1.0f);
|
||||
}
|
||||
|
||||
quad.m_texId = texId;
|
||||
quad.m_image = image;
|
||||
|
||||
// add the blendMode flags to the base state
|
||||
quad.m_state = blendMode | actualImageOptions->baseState;
|
||||
@@ -185,17 +189,17 @@ void CDraw2d::DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size,
|
||||
void CDraw2d::DrawImageAligned(AZ::Data::Instance<AZ::RPI::Image> image, AZ::Vector2 position, AZ::Vector2 size,
|
||||
HAlign horizontalAlignment, VAlign verticalAlignment,
|
||||
float opacity, float rotation, const AZ::Vector2* minMaxTexCoords, ImageOptions* imageOptions)
|
||||
{
|
||||
AZ::Vector2 alignedPosition = Align(position, size, horizontalAlignment, verticalAlignment);
|
||||
|
||||
DrawImage(texId, alignedPosition, size, opacity, rotation, &position, minMaxTexCoords, imageOptions);
|
||||
DrawImage(image, alignedPosition, size, opacity, rotation, &position, minMaxTexCoords, imageOptions);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::DrawQuad(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState)
|
||||
void CDraw2d::DrawQuad(AZ::Data::Instance<AZ::RPI::Image> image, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState)
|
||||
{
|
||||
int actualBlendMode = (blendMode == -1) ? g_defaultBlendState : blendMode;
|
||||
int actualBaseState = (baseState == -1) ? g_defaultBaseState : baseState;
|
||||
@@ -208,7 +212,7 @@ void CDraw2d::DrawQuad(int texId, VertexPosColUV* verts, int blendMode, Rounding
|
||||
quad.m_texCoords[i] = verts[i].uv;
|
||||
quad.m_packedColors[i] = PackARGB8888(verts[i].color);
|
||||
}
|
||||
quad.m_texId = texId;
|
||||
quad.m_image = image;
|
||||
|
||||
// add the blendMode flags to the base state
|
||||
quad.m_state = actualBlendMode | actualBaseState;
|
||||
@@ -221,9 +225,7 @@ void CDraw2d::DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int
|
||||
{
|
||||
int actualBaseState = (baseState == -1) ? g_defaultBaseState : baseState;
|
||||
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
|
||||
int texId = renderer->GetWhiteTextureId();
|
||||
auto image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
|
||||
int actualBlendMode = (blendMode == -1) ? g_defaultBlendState : blendMode;
|
||||
|
||||
@@ -231,7 +233,7 @@ void CDraw2d::DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int
|
||||
uint32 packedColor = PackARGB8888(color);
|
||||
|
||||
DeferredLine line;
|
||||
line.m_texId = texId;
|
||||
line.m_image = image;
|
||||
|
||||
line.m_points[0] = Draw2dHelper::RoundXY(start, pixelRounding);
|
||||
line.m_points[1] = Draw2dHelper::RoundXY(end, pixelRounding);
|
||||
@@ -250,7 +252,7 @@ void CDraw2d::DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::DrawLineTextured(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState)
|
||||
void CDraw2d::DrawLineTextured(AZ::Data::Instance<AZ::RPI::Image> image, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState)
|
||||
{
|
||||
int actualBaseState = (baseState == -1) ? g_defaultBaseState : baseState;
|
||||
|
||||
@@ -258,7 +260,7 @@ void CDraw2d::DrawLineTextured(int texId, VertexPosColUV* verts, int blendMode,
|
||||
|
||||
// define line
|
||||
DeferredLine line;
|
||||
line.m_texId = texId;
|
||||
line.m_image = image;
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
@@ -327,15 +329,19 @@ AZ::Vector2 CDraw2d::GetTextSize(const char* textString, float pointSize, TextOp
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float CDraw2d::GetViewportWidth() const
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
return (float)renderer->GetOverlayWidth();
|
||||
auto windowContext = GetViewportContext()->GetWindowContext();
|
||||
const AZ::RHI::Viewport& viewport = windowContext->GetViewport();
|
||||
const float viewWidth = viewport.m_maxX - viewport.m_minX;
|
||||
return viewWidth;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float CDraw2d::GetViewportHeight() const
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
return (float)renderer->GetOverlayHeight();
|
||||
auto windowContext = GetViewportContext()->GetWindowContext();
|
||||
const AZ::RHI::Viewport& viewport = windowContext->GetViewport();
|
||||
const float viewHeight = viewport.m_maxY - viewport.m_minY;
|
||||
return viewHeight;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -353,27 +359,28 @@ const CDraw2d::TextOptions& CDraw2d::GetDefaultTextOptions() const
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::RenderDeferredPrimitives()
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
|
||||
// Set up the 2D drawing state
|
||||
renderer->SetCullMode(R_CULL_DISABLE);
|
||||
|
||||
renderer->Set2DMode(renderer->GetOverlayWidth(), renderer->GetOverlayHeight(), m_backupSceneMatrices);
|
||||
renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
renderer->SetState(g_defaultBlendState | g_defaultBaseState);
|
||||
|
||||
// Draw and delete the deferred primitives
|
||||
AZ::RPI::ViewportContextPtr viewportContext = GetViewportContext();
|
||||
for (auto primIter : m_deferredPrimitives)
|
||||
{
|
||||
primIter->Draw();
|
||||
primIter->Draw(m_dynamicDraw, m_shaderData, viewportContext);
|
||||
delete primIter;
|
||||
}
|
||||
|
||||
// clear the list of deferred primitives
|
||||
m_deferredPrimitives.clear();
|
||||
}
|
||||
|
||||
// Reset the render state
|
||||
renderer->Unset2DMode(m_backupSceneMatrices);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::SetDeferPrimitives(bool deferPrimitives)
|
||||
{
|
||||
m_deferCalls = deferPrimitives;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CDraw2d::GetDeferPrimitives()
|
||||
{
|
||||
return m_deferCalls;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -414,6 +421,30 @@ AZ::Vector2 CDraw2d::Align(AZ::Vector2 position, AZ::Vector2 size,
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
AZ::Data::Instance<AZ::RPI::Image> CDraw2d::LoadTexture(const AZStd::string& pathName)
|
||||
{
|
||||
AZStd::string sourceRelativePath(pathName);
|
||||
AZStd::string cacheRelativePath = sourceRelativePath + ".streamingimage";
|
||||
|
||||
// The file may not be in the AssetCatalog at this point if it is still processing or doesn't exist on disk.
|
||||
// Use GenerateAssetIdTEMP instead of GetAssetIdByPath so that it will return a valid AssetId anyways
|
||||
AZ::Data::AssetId streamingImageAssetId;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
streamingImageAssetId, &AZ::Data::AssetCatalogRequestBus::Events::GenerateAssetIdTEMP,
|
||||
sourceRelativePath.c_str());
|
||||
streamingImageAssetId.m_subId = AZ::RPI::StreamingImageAsset::GetImageAssetSubId();
|
||||
|
||||
auto streamingImageAsset = AZ::Data::AssetManager::Instance().FindOrCreateAsset<AZ::RPI::StreamingImageAsset>(streamingImageAssetId, AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
AZ::Data::Instance<AZ::RPI::Image> image = AZ::RPI::StreamingImage::FindOrCreate(streamingImageAsset);
|
||||
if (!image)
|
||||
{
|
||||
AZ_Error("Draw2d", false, "Failed to find or create an image instance from image asset '%s'", streamingImageAsset.GetHint().c_str());
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTECTED MEMBER FUNCTIONS
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -542,7 +573,7 @@ void CDraw2d::DrawOrDeferQuad(const DeferredQuad* quad)
|
||||
}
|
||||
else
|
||||
{
|
||||
quad->Draw();
|
||||
quad->Draw(m_dynamicDraw, m_shaderData, GetViewportContext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,16 +588,33 @@ void CDraw2d::DrawOrDeferLine(const DeferredLine* line)
|
||||
}
|
||||
else
|
||||
{
|
||||
line->Draw();
|
||||
line->Draw(m_dynamicDraw, m_shaderData, GetViewportContext());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
AZ::RPI::ViewportContextPtr CDraw2d::GetViewportContext() const
|
||||
{
|
||||
if (!m_viewportContext)
|
||||
{
|
||||
// Return the default viewport context
|
||||
auto viewContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
return viewContextManager->GetDefaultViewportContext();
|
||||
}
|
||||
|
||||
// Return the user specified viewport context
|
||||
return m_viewportContext;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CDraw2d::DeferredQuad
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::DeferredQuad::Draw() const
|
||||
void CDraw2d::DeferredQuad::Draw(AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> dynamicDraw,
|
||||
const Draw2dShaderData& shaderData,
|
||||
AZ::RPI::ViewportContextPtr viewportContext) const
|
||||
{
|
||||
const int32 NUM_VERTS = 6;
|
||||
|
||||
@@ -585,17 +633,41 @@ void CDraw2d::DeferredQuad::Draw() const
|
||||
vertices[i].st = Vec2(m_texCoords[j].GetX(), m_texCoords[j].GetY());
|
||||
}
|
||||
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
renderer->SetTexture(m_texId);
|
||||
// Set up per draw SRG
|
||||
AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> drawSrg = dynamicDraw->NewDrawSrg();
|
||||
|
||||
// Set the render state, can't rely on this being right because font rendering changes it
|
||||
renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
// Set texture
|
||||
const AZ::RHI::ImageView* imageView = m_image ? m_image->GetImageView() : nullptr;
|
||||
if (!imageView)
|
||||
{
|
||||
// Default to white texture
|
||||
auto image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
imageView = image->GetImageView();
|
||||
}
|
||||
|
||||
// set the desired render state
|
||||
renderer->SetState(m_state);
|
||||
if (imageView)
|
||||
{
|
||||
drawSrg->SetImageView(shaderData.m_imageInputIndex, imageView, 0);
|
||||
}
|
||||
|
||||
// This will end up using DrawPrimitive to render the quad
|
||||
renderer->DrawDynVB(vertices, nullptr, NUM_VERTS, 0, prtTriangleList);
|
||||
// Set projection matrix
|
||||
auto windowContext = viewportContext->GetWindowContext();
|
||||
const AZ::RHI::Viewport& viewport = windowContext->GetViewport();
|
||||
const float viewX = viewport.m_minX;
|
||||
const float viewY = viewport.m_minY;
|
||||
const float viewWidth = viewport.m_maxX - viewport.m_minX;
|
||||
const float viewHeight = viewport.m_maxY - viewport.m_minY;
|
||||
const float zf = viewport.m_minZ;
|
||||
const float zn = viewport.m_maxZ;
|
||||
AZ::Matrix4x4 modelViewProjMat;
|
||||
AZ::MakeOrthographicMatrixRH(modelViewProjMat, viewX, viewX + viewWidth, viewY + viewHeight, viewY, zn, zf);
|
||||
drawSrg->SetConstant(shaderData.m_viewProjInputIndex, modelViewProjMat);
|
||||
|
||||
drawSrg->Compile();
|
||||
|
||||
// Add the primitive to the dynamic draw context for drawing
|
||||
dynamicDraw->SetPrimitiveType(AZ::RHI::PrimitiveTopology::TriangleList);
|
||||
dynamicDraw->DrawLinear(vertices, NUM_VERTS, drawSrg);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -603,7 +675,9 @@ void CDraw2d::DeferredQuad::Draw() const
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::DeferredLine::Draw() const
|
||||
void CDraw2d::DeferredLine::Draw(AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> dynamicDraw,
|
||||
const Draw2dShaderData& shaderData,
|
||||
AZ::RPI::ViewportContextPtr viewportContext) const
|
||||
{
|
||||
const float z = 1.0f; // depth test disabled, if writing Z this will write at far plane
|
||||
|
||||
@@ -618,15 +692,41 @@ void CDraw2d::DeferredLine::Draw() const
|
||||
vertices[i].st = Vec2(m_texCoords[i].GetX(), m_texCoords[i].GetY());
|
||||
}
|
||||
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
renderer->SetTexture(m_texId);
|
||||
// Set up per draw SRG
|
||||
AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> drawSrg = dynamicDraw->NewDrawSrg();
|
||||
|
||||
// Set the render state, can't rely on this being right because font rendering changes it
|
||||
renderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
renderer->SetState(m_state);
|
||||
// Set texture
|
||||
const AZ::RHI::ImageView* imageView = m_image ? m_image->GetImageView() : nullptr;
|
||||
if (!imageView)
|
||||
{
|
||||
// Default to white texture
|
||||
auto image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
imageView = image->GetImageView();
|
||||
}
|
||||
|
||||
// This will end up using DrawPrimitive to render the quad
|
||||
renderer->DrawDynVB(vertices, nullptr, NUM_VERTS, 0, prtLineList);
|
||||
if (imageView)
|
||||
{
|
||||
drawSrg->SetImageView(shaderData.m_imageInputIndex, imageView, 0);
|
||||
}
|
||||
|
||||
// Set projection matrix
|
||||
auto windowContext = viewportContext->GetWindowContext();
|
||||
const AZ::RHI::Viewport& viewport = windowContext->GetViewport();
|
||||
const float viewX = viewport.m_minX;
|
||||
const float viewY = viewport.m_minY;
|
||||
const float viewWidth = viewport.m_maxX - viewport.m_minX;
|
||||
const float viewHeight = viewport.m_maxY - viewport.m_minY;
|
||||
const float zf = viewport.m_minZ;
|
||||
const float zn = viewport.m_maxZ;
|
||||
AZ::Matrix4x4 modelViewProjMat;
|
||||
AZ::MakeOrthographicMatrixRH(modelViewProjMat, viewX, viewX + viewWidth, viewY + viewHeight, viewY, zn, zf);
|
||||
drawSrg->SetConstant(shaderData.m_viewProjInputIndex, modelViewProjMat);
|
||||
|
||||
drawSrg->Compile();
|
||||
|
||||
// Add the primitive to the dynamic draw context for drawing
|
||||
dynamicDraw->SetPrimitiveType(AZ::RHI::PrimitiveTopology::LineList);
|
||||
dynamicDraw->DrawLinear(vertices, NUM_VERTS, drawSrg);
|
||||
}
|
||||
|
||||
|
||||
@@ -635,7 +735,9 @@ void CDraw2d::DeferredLine::Draw() const
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::DeferredText::Draw() const
|
||||
void CDraw2d::DeferredText::Draw([[maybe_unused]] AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> dynamicDraw,
|
||||
[[maybe_unused]] const Draw2dShaderData& shaderData,
|
||||
[[maybe_unused]] AZ::RPI::ViewportContextPtr viewportContext) const
|
||||
{
|
||||
m_font->DrawString(m_position.GetX(), m_position.GetY(), m_string.c_str(), true, m_fontContext);
|
||||
}
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <LyShine/IDraw2d.h>
|
||||
#include <IRenderer.h>
|
||||
#include <stack>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Implementation of IDraw2d interface for 2D drawing in screen space
|
||||
//
|
||||
//! The CDraw2d class implements the IDraw2d interface for drawing 2D images, shapes and text.
|
||||
//! Positions and sizes are specified in pixels in the current 2D viewport.
|
||||
class CDraw2d
|
||||
: public IDraw2d
|
||||
{
|
||||
public: // member functions
|
||||
|
||||
//! Constructor, constructed by the LyShine class
|
||||
CDraw2d();
|
||||
|
||||
// IDraw2d
|
||||
|
||||
~CDraw2d() override;
|
||||
|
||||
//! Start a section of 2D drawing function calls. This will set appropriate render state.
|
||||
void BeginDraw2d(bool deferCalls = false) override;
|
||||
|
||||
//! Start a section of 2D drawing function calls. This will set appropriate render state.
|
||||
//! This variant allows the viewport size to be specified
|
||||
void BeginDraw2d(AZ::Vector2 viewportSize, bool deferCalls = false) override;
|
||||
|
||||
//! End a section of 2D drawing function calls. This will reset some render state.
|
||||
void EndDraw2d() override;
|
||||
|
||||
//! Draw a textured quad, optional rotation is counter-clockwise in degrees.
|
||||
void DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f,
|
||||
float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr,
|
||||
ImageOptions* imageOptions = nullptr) override;
|
||||
|
||||
//! Draw a textured quad where the position specifies the point specified by the alignment. Rotation is around that point.
|
||||
void DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size,
|
||||
HAlign horizontalAlignment, VAlign verticalAlignment,
|
||||
float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr,
|
||||
ImageOptions* imageOptions = nullptr) override;
|
||||
|
||||
//! Draw a textured quad where the position, color and uv of each point is specified explicitly
|
||||
void DrawQuad(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) override;
|
||||
|
||||
//! Draw a line
|
||||
void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int blendMode, Rounding pixelRounding, int baseState) override;
|
||||
|
||||
//! Draw a line textured
|
||||
void DrawLineTextured(int texId, VertexPosColUV* verts, int blendMode, Rounding pixelRounding, int baseState) override;
|
||||
|
||||
//! Draw a text string. Only supports ASCII text.
|
||||
void DrawText(const char* textString, AZ::Vector2 position, float pointSize,
|
||||
float opacity = 1.0f, TextOptions* textOptions = nullptr) override;
|
||||
|
||||
//! Get the width and height (in pixels) that would be used to draw the given text string.
|
||||
AZ::Vector2 GetTextSize(const char* textString, float pointSize, TextOptions* textOptions = nullptr) override;
|
||||
|
||||
//! Get the width of the rendering viewport (in pixels).
|
||||
float GetViewportWidth() const override;
|
||||
|
||||
//! Get the height of the rendering viewport (in pixels).
|
||||
float GetViewportHeight() const override;
|
||||
|
||||
//! Get the default values that would be used if no image options were passed in
|
||||
const ImageOptions& GetDefaultImageOptions() const override;
|
||||
|
||||
//! Get the default values that would be used if no text options were passed in
|
||||
const TextOptions& GetDefaultTextOptions() const override;
|
||||
|
||||
// ~IDraw2d
|
||||
|
||||
//! Render the primitives that have been deferred
|
||||
void RenderDeferredPrimitives();
|
||||
|
||||
private:
|
||||
|
||||
AZ_DISABLE_COPY_MOVE(CDraw2d);
|
||||
|
||||
public: // static member functions
|
||||
|
||||
//! Given a position and size and an alignment return the top left corner of the aligned quad
|
||||
static AZ::Vector2 Align(AZ::Vector2 position, AZ::Vector2 size, HAlign horizontalAlignment, VAlign verticalAlignment);
|
||||
|
||||
protected: // types and constants
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_VERTICES_IN_PRIM = 6
|
||||
};
|
||||
|
||||
class DeferredPrimitive
|
||||
{
|
||||
public:
|
||||
virtual ~DeferredPrimitive() {};
|
||||
virtual void Draw() const = 0;
|
||||
};
|
||||
|
||||
class DeferredQuad
|
||||
: public DeferredPrimitive
|
||||
{
|
||||
public:
|
||||
~DeferredQuad() override {};
|
||||
void Draw() const override;
|
||||
|
||||
AZ::Vector2 m_points[4];
|
||||
AZ::Vector2 m_texCoords[4];
|
||||
uint32 m_packedColors[4];
|
||||
int m_texId;
|
||||
int m_state;
|
||||
};
|
||||
|
||||
class DeferredLine
|
||||
: public DeferredPrimitive
|
||||
{
|
||||
public:
|
||||
~DeferredLine() override {};
|
||||
void Draw() const override;
|
||||
|
||||
int m_texId;
|
||||
AZ::Vector2 m_points[2];
|
||||
AZ::Vector2 m_texCoords[2];
|
||||
uint32 m_packedColors[2];
|
||||
int m_state;
|
||||
};
|
||||
|
||||
class DeferredText
|
||||
: public DeferredPrimitive
|
||||
{
|
||||
public:
|
||||
~DeferredText() override {};
|
||||
void Draw() const override;
|
||||
|
||||
STextDrawContext m_fontContext;
|
||||
IFFont* m_font;
|
||||
AZ::Vector2 m_position;
|
||||
std::string m_string;
|
||||
};
|
||||
|
||||
protected: // member functions
|
||||
|
||||
//! Rotate an array of points around the z-axis at the pivot point.
|
||||
//
|
||||
//! Angle is in degrees counter-clockwise
|
||||
void RotatePointsAboutPivot(AZ::Vector2* points, int numPoints, AZ::Vector2 pivot, float angle) const;
|
||||
|
||||
//! Helper function to render a text string
|
||||
void DrawTextInternal(const char* textString, IFFont* font, unsigned int effectIndex,
|
||||
AZ::Vector2 position, float pointSize, AZ::Color color, float rotation,
|
||||
HAlign horizontalAlignment, VAlign verticalAlignment, int baseState);
|
||||
|
||||
//! Draw or defer a quad
|
||||
void DrawOrDeferQuad(const DeferredQuad* quad);
|
||||
|
||||
//! Draw or defer a line
|
||||
void DrawOrDeferLine(const DeferredLine* line);
|
||||
|
||||
protected: // attributes
|
||||
|
||||
ImageOptions m_defaultImageOptions; //!< The default image options used if nullptr is passed
|
||||
TextOptions m_defaultTextOptions; //!< The default text options used if nullptr is passed
|
||||
|
||||
bool m_deferCalls; //!< True if the actual render of the primitives should be deferred until end of frame
|
||||
|
||||
std::vector<DeferredPrimitive*> m_deferredPrimitives;
|
||||
|
||||
//! These two data members allows nested calls to BeginDraw2d/EndDraw2d. We will begin 2D mode only on the
|
||||
//! outermost call to BeginDraw2d with deferCalls set to false and will end 2D mode on the corresposnding
|
||||
//! call to EndDraw2d. The stack is used to detect that corresponding call and we need the level it occurred
|
||||
//! to know when to end 2D mode.
|
||||
int m_nestLevelAtWhichStarted2dMode;
|
||||
std::stack<bool> m_deferCallsFlagStack;
|
||||
|
||||
private:
|
||||
TransformationMatrices m_backupSceneMatrices;
|
||||
};
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
#include "LyShine.h"
|
||||
|
||||
#include "Draw2d.h"
|
||||
|
||||
#include "UiCanvasComponent.h"
|
||||
#include "UiCanvasManager.h"
|
||||
#include "LyShineDebug.h"
|
||||
@@ -55,6 +53,7 @@
|
||||
#include <LyShine/Bus/UiCursorBus.h>
|
||||
#include <LyShine/Bus/UiDraggableBus.h>
|
||||
#include <LyShine/Bus/UiDropTargetBus.h>
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#if defined(LYSHINE_INTERNAL_UNIT_TEST)
|
||||
#include "TextMarkup.h"
|
||||
@@ -455,7 +454,6 @@ void CLyShine::Render()
|
||||
// Render all the canvases loaded in game
|
||||
m_uiCanvasManager->RenderLoadedCanvases();
|
||||
|
||||
#ifdef LYSHINE_ATOM_TODO // convert cursor support to use Atom
|
||||
m_draw2d->RenderDeferredPrimitives();
|
||||
|
||||
// Don't render the UI cursor when in edit mode. For example during UI Preview mode a script could turn on the
|
||||
@@ -466,7 +464,6 @@ void CLyShine::Render()
|
||||
{
|
||||
RenderUiCursor();
|
||||
}
|
||||
#endif
|
||||
|
||||
GetUiRenderer()->EndUiFrameRender();
|
||||
|
||||
@@ -687,9 +684,11 @@ void CLyShine::RenderUiCursor()
|
||||
const AZ::Vector2 position = GetUiCursorPosition();
|
||||
const AZ::Vector2 dimensions(static_cast<float>(m_uiCursorTexture->GetWidth()), static_cast<float>(m_uiCursorTexture->GetHeight()));
|
||||
|
||||
#ifdef LYSHINE_ATOM_TODO // Convert cursor to Atom image
|
||||
m_draw2d->BeginDraw2d();
|
||||
m_draw2d->DrawImage(m_uiCursorTexture->GetTextureID(), position, dimensions);
|
||||
m_draw2d->EndDraw2d();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _RELEASE
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
#include "LyShine_precompiled.h"
|
||||
#include "LyShineDebug.h"
|
||||
#include "IConsole.h"
|
||||
#include <LyShine/IDraw2d.h>
|
||||
#include "IRenderer.h"
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
@@ -105,15 +106,24 @@ static bool g_deferDrawsToEndOfFrame = false;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
static int Create2DTexture(int width, int height, byte* data, ETEX_Format format)
|
||||
{
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
return renderer->DownLoadToVideoMemory(data, width, height, format, format, 1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static AZ::Vector2 GetTextureSize(AZ::Data::Instance<AZ::RPI::Image> image)
|
||||
{
|
||||
AZ::RHI::Size size = image->GetDescriptor().m_size;
|
||||
return AZ::Vector2(size.m_width, size.m_height);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int textureHeight,
|
||||
int minX, int minY, [[maybe_unused]] int rectWidth, int rectHeight,
|
||||
int tileWidth, int tileHeight, uint32* colors, bool varyAlpha)
|
||||
@@ -139,11 +149,13 @@ static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* CreateMonoTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> CreateMonoTestTexture()
|
||||
{
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
const int width = 32;
|
||||
const int height = 32;
|
||||
uint32 data[width * height];
|
||||
@@ -172,13 +184,18 @@ static ITexture* CreateMonoTestTexture()
|
||||
int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8);
|
||||
|
||||
return gEnv->pRenderer->EF_GetTextureByID(textureId);
|
||||
#else
|
||||
auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
return whiteTexture;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* CreateColorTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> CreateColorTestTexture()
|
||||
{
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
const int width = 32;
|
||||
const int height = 32;
|
||||
uint32 data[width * height];
|
||||
@@ -207,13 +224,18 @@ static ITexture* CreateColorTestTexture()
|
||||
int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8);
|
||||
|
||||
return gEnv->pRenderer->EF_GetTextureByID(textureId);
|
||||
#else
|
||||
auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
return whiteTexture;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* CreateMonoAlphaTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> CreateMonoAlphaTestTexture()
|
||||
{
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
const int width = 32;
|
||||
const int height = 32;
|
||||
uint32 data[width * height];
|
||||
@@ -242,13 +264,18 @@ static ITexture* CreateMonoAlphaTestTexture()
|
||||
int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8);
|
||||
|
||||
return gEnv->pRenderer->EF_GetTextureByID(textureId);
|
||||
#else
|
||||
auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
return whiteTexture;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* CreateColorAlphaTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> CreateColorAlphaTestTexture()
|
||||
{
|
||||
#ifdef LYSHINE_ATOM_TODO
|
||||
const int width = 32;
|
||||
const int height = 32;
|
||||
uint32 data[width * height];
|
||||
@@ -277,14 +304,18 @@ static ITexture* CreateColorAlphaTestTexture()
|
||||
int textureId = Create2DTexture(width, height, (uint8*)data, eTF_R8G8B8A8);
|
||||
|
||||
return gEnv->pRenderer->EF_GetTextureByID(textureId);
|
||||
#else
|
||||
auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
return whiteTexture;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* GetMonoTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> GetMonoTestTexture()
|
||||
{
|
||||
static ITexture* testImageMono = nullptr;
|
||||
static AZ::Data::Instance<AZ::RPI::Image> testImageMono = nullptr;
|
||||
|
||||
if (!testImageMono)
|
||||
{
|
||||
@@ -297,9 +328,9 @@ static ITexture* GetMonoTestTexture()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* GetColorTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> GetColorTestTexture()
|
||||
{
|
||||
static ITexture* testImageColor = nullptr;
|
||||
static AZ::Data::Instance<AZ::RPI::Image> testImageColor = nullptr;
|
||||
|
||||
if (!testImageColor)
|
||||
{
|
||||
@@ -312,9 +343,9 @@ static ITexture* GetColorTestTexture()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* GetMonoAlphaTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> GetMonoAlphaTestTexture()
|
||||
{
|
||||
static ITexture* testImageMonoAlpha = nullptr;
|
||||
static AZ::Data::Instance<AZ::RPI::Image> testImageMonoAlpha = nullptr;
|
||||
|
||||
if (!testImageMonoAlpha)
|
||||
{
|
||||
@@ -327,9 +358,9 @@ static ITexture* GetMonoAlphaTestTexture()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(_RELEASE)
|
||||
static ITexture* GetColorAlphaTestTexture()
|
||||
static AZ::Data::Instance<AZ::RPI::Image> GetColorAlphaTestTexture()
|
||||
{
|
||||
static ITexture* testImageColorAlpha = nullptr;
|
||||
static AZ::Data::Instance<AZ::RPI::Image> testImageColorAlpha = nullptr;
|
||||
|
||||
if (!testImageColorAlpha)
|
||||
{
|
||||
@@ -347,14 +378,12 @@ static void DebugDrawColoredBox(AZ::Vector2 pos, AZ::Vector2 size, AZ::Color col
|
||||
IDraw2d::HAlign horizontalAlignment = IDraw2d::HAlign::Left,
|
||||
IDraw2d::VAlign verticalAlignment = IDraw2d::VAlign::Top)
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions();
|
||||
int whiteTextureId = renderer->GetWhiteTextureId();
|
||||
|
||||
imageOptions.color = color.GetAsVector3();
|
||||
draw2d->DrawImageAligned(whiteTextureId, pos, size, horizontalAlignment, verticalAlignment,
|
||||
auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
draw2d->DrawImageAligned(whiteTexture, pos, size, horizontalAlignment, verticalAlignment,
|
||||
color.GetA(), 0.0f, nullptr, &imageOptions);
|
||||
}
|
||||
#endif
|
||||
@@ -364,7 +393,7 @@ static void DebugDrawColoredBox(AZ::Vector2 pos, AZ::Vector2 size, AZ::Color col
|
||||
static void DebugDrawStringWithSizeBox(IFFont* font, unsigned int effectIndex, const char* sizeString,
|
||||
const char* testString, AZ::Vector2 pos, float spacing, float size)
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions();
|
||||
if (font)
|
||||
@@ -398,9 +427,7 @@ static void DebugDrawStringWithSizeBox(IFFont* font, unsigned int effectIndex, c
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dFontSizes(IFFont* font, unsigned int effectIndex, const char* fontName)
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
float xOffset = 20.0f;
|
||||
float yOffset = 20.0f;
|
||||
@@ -463,8 +490,6 @@ static void DebugDraw2dFontSizes(IFFont* font, unsigned int effectIndex, const c
|
||||
|
||||
yOffset += 55.0f;
|
||||
DebugDrawStringWithSizeBox(font, effectIndex, "Size 49", testString, AZ::Vector2(xOffset, yOffset), xSpacing, 49);
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -524,7 +549,7 @@ static void DebugDrawAlignedTextWithOriginBox(AZ::Vector2 pos,
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dFontAlignment()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
float w = draw2d->GetViewportWidth();
|
||||
float yPos = 20;
|
||||
|
||||
@@ -591,7 +616,7 @@ static void DebugDraw2dFontAlignment()
|
||||
#if !defined(_RELEASE)
|
||||
static AZ::Vector2 DebugDrawFontColorTestBox(AZ::Vector2 pos, const char* string, AZ::Vector3 color, float opacity)
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
float pointSize = 32.0f;
|
||||
const float spacing = 6.0f;
|
||||
@@ -626,9 +651,7 @@ static AZ::Vector2 DebugDrawFontColorTestBox(AZ::Vector2 pos, const char* string
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dFontColorAndOpacity()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
AZ::Vector2 size;
|
||||
AZ::Vector2 pos(20.0f, 20.0f);
|
||||
@@ -659,8 +682,6 @@ static void DebugDraw2dFontColorAndOpacity()
|
||||
draw2d->DrawText("Opacity=0.25f", pos, 24.0f);
|
||||
pos.SetX(pos.GetX() + 200.0f);
|
||||
draw2d->DrawText("Opacity=0.00f", pos, 24.0f);
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -668,16 +689,11 @@ static void DebugDraw2dFontColorAndOpacity()
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dImageRotations()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
ITexture* texture = GetMonoTestTexture();
|
||||
int texId = texture->GetTextureID();
|
||||
AZ::Data::Instance<AZ::RPI::Image> texture = GetMonoTestTexture();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
|
||||
float width = (float)texture->GetWidth();
|
||||
float height = (float)texture->GetHeight();
|
||||
AZ::Vector2 size(width, height);
|
||||
AZ::Vector2 size = GetTextureSize(texture);
|
||||
|
||||
float row = 20.0f;
|
||||
float xSpacing = size.GetX() * 2.0f;
|
||||
@@ -690,7 +706,7 @@ static void DebugDraw2dImageRotations()
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
AZ::Vector2 pos(xStart + xSpacing * i, row);
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 45.0f * i);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 45.0f * i);
|
||||
DebugDrawColoredBox(AZ::Vector2(pos.GetX() - 2, pos.GetY() - 2), AZ::Vector2(5, 5), posBoxColor);
|
||||
}
|
||||
|
||||
@@ -703,7 +719,7 @@ static void DebugDraw2dImageRotations()
|
||||
{
|
||||
AZ::Vector2 pos(xStart + xSpacing * i, row);
|
||||
AZ::Vector2 pivot = pos + pivotOffset;
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 45.0f * i, &pivot);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 45.0f * i, &pivot);
|
||||
DebugDrawColoredBox(AZ::Vector2(pos.GetX() - 2, pos.GetY() - 2), AZ::Vector2(5, 5), posBoxColor);
|
||||
DebugDrawColoredBox(AZ::Vector2(pivot.GetX() - 2, pivot.GetY() - 2), AZ::Vector2(5, 5), pivotBoxColor);
|
||||
}
|
||||
@@ -715,11 +731,9 @@ static void DebugDraw2dImageRotations()
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
AZ::Vector2 pos(xStart + xSpacing * i + size.GetX() * 0.5f, row + size.GetY() * 0.5f);
|
||||
draw2d->DrawImageAligned(texId, pos, size, IDraw2d::HAlign::Center, IDraw2d::VAlign::Center, 1.0f, 45.0f * i);
|
||||
draw2d->DrawImageAligned(texture, pos, size, IDraw2d::HAlign::Center, IDraw2d::VAlign::Center, 1.0f, 45.0f * i);
|
||||
DebugDrawColoredBox(AZ::Vector2(pos.GetX() - 2, pos.GetY() - 2), AZ::Vector2(5, 5), posBoxColor);
|
||||
}
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -727,22 +741,17 @@ static void DebugDraw2dImageRotations()
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dImageColor()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
ITexture* texture = GetMonoAlphaTestTexture();
|
||||
int texId = texture->GetTextureID();
|
||||
AZ::Data::Instance<AZ::RPI::Image> texture = GetMonoAlphaTestTexture();
|
||||
|
||||
IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
|
||||
draw2d->DrawText(
|
||||
"Testing image colors, image is black and white, top row is opacity=1, bottom row is opacity = 0.5",
|
||||
AZ::Vector2(20, 20), 16);
|
||||
|
||||
float width = texture->GetWidth() * 2.0f;
|
||||
float height = texture->GetHeight() * 2.0f;
|
||||
AZ::Vector2 size(width, height);
|
||||
AZ::Vector2 size = GetTextureSize(texture) * 2.0f;
|
||||
|
||||
float xStart = 20.0f;
|
||||
float yStart = 50.0f;
|
||||
@@ -755,14 +764,12 @@ static void DebugDraw2dImageColor()
|
||||
|
||||
// Draw the image with this color
|
||||
imageOptions.color = g_colorVec3[color];
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions);
|
||||
|
||||
// draw below with half opacity to test combination of color and opacity
|
||||
pos.SetY(pos.GetY() + ySpacing);
|
||||
draw2d->DrawImage(texId, pos, size, 0.5f, 0.0f, 0, 0, &imageOptions);
|
||||
draw2d->DrawImage(texture, pos, size, 0.5f, 0.0f, 0, 0, &imageOptions);
|
||||
}
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -770,24 +777,20 @@ static void DebugDraw2dImageColor()
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dImageBlendMode()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
IRenderer* renderer = gEnv->pRenderer;
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
int whiteTextureId = renderer->GetWhiteTextureId();
|
||||
auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White);
|
||||
|
||||
ITexture* texture = GetColorAlphaTestTexture();
|
||||
int texId = texture->GetTextureID();
|
||||
AZ::Data::Instance<AZ::RPI::Image> texture = GetColorAlphaTestTexture();
|
||||
|
||||
IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
|
||||
draw2d->DrawText("Testing blend modes, src blend changes across x-axis, dst blend changes across y axis",
|
||||
AZ::Vector2(20, 20), 16);
|
||||
|
||||
float width = (float)texture->GetWidth();
|
||||
float height = (float)texture->GetHeight();
|
||||
AZ::Vector2 size(width, height);
|
||||
AZ::Vector2 size = GetTextureSize(texture);
|
||||
float width = size.GetX();
|
||||
float height = size.GetY();
|
||||
|
||||
float xStart = 20.0f;
|
||||
float yStart = 60.0f;
|
||||
@@ -824,16 +827,14 @@ static void DebugDraw2dImageBlendMode()
|
||||
AZ::Vector2(0.0f, 1.0f)
|
||||
},
|
||||
};
|
||||
draw2d->DrawQuad(whiteTextureId, verts);
|
||||
draw2d->DrawQuad(whiteTexture, verts);
|
||||
|
||||
// Draw the image with this color
|
||||
|
||||
imageOptions.blendMode = g_srcBlendModes[srcIndex] | g_dstBlendModes[dstIndex];
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions);
|
||||
}
|
||||
}
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -841,20 +842,17 @@ static void DebugDraw2dImageBlendMode()
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dImageUVs()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
ITexture* texture = GetColorTestTexture();
|
||||
int texId = texture->GetTextureID();
|
||||
AZ::Data::Instance<AZ::RPI::Image> texture = GetColorTestTexture();
|
||||
|
||||
IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
|
||||
draw2d->DrawText(
|
||||
"Testing DrawImage with minMaxTexCoords. Full image, top left quadrant, middle section, full flipped",
|
||||
AZ::Vector2(20, 20), 16);
|
||||
|
||||
AZ::Vector2 size((float)texture->GetWidth() * 2.0f, (float)texture->GetHeight() * 2.0f);
|
||||
AZ::Vector2 size = GetTextureSize(texture) * 2.0f;
|
||||
|
||||
float xStart = 20.0f;
|
||||
float yStart = 50.0f;
|
||||
@@ -867,27 +865,25 @@ static void DebugDraw2dImageUVs()
|
||||
// full image
|
||||
minMaxTexCoords[0] = AZ::Vector2(0, 0);
|
||||
minMaxTexCoords[1] = AZ::Vector2(1, 1);
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
|
||||
// top left quadrant of image
|
||||
pos.SetX(pos.GetX() + xSpacing);
|
||||
minMaxTexCoords[0] = AZ::Vector2(0, 0);
|
||||
minMaxTexCoords[1] = AZ::Vector2(0.5, 0.5);
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
|
||||
// middle of image
|
||||
pos.SetX(pos.GetX() + xSpacing);
|
||||
minMaxTexCoords[0] = AZ::Vector2(0.25, 0.25);
|
||||
minMaxTexCoords[1] = AZ::Vector2(0.75, 0.75);
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
|
||||
// flip of image
|
||||
pos.SetX(pos.GetX() + xSpacing);
|
||||
minMaxTexCoords[0] = AZ::Vector2(0.0, 1.0);
|
||||
minMaxTexCoords[1] = AZ::Vector2(1.0, 0.0);
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, minMaxTexCoords);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -895,18 +891,15 @@ static void DebugDraw2dImageUVs()
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dImagePixelRounding()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
ITexture* texture = GetColorTestTexture();
|
||||
int texId = texture->GetTextureID();
|
||||
AZ::Data::Instance<AZ::RPI::Image> texture = GetColorTestTexture();
|
||||
|
||||
IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
|
||||
draw2d->DrawText("Testing DrawImage pixel rounding options", AZ::Vector2(20, 20), 16);
|
||||
|
||||
AZ::Vector2 size((float)texture->GetWidth(), (float)texture->GetHeight());
|
||||
AZ::Vector2 size = GetTextureSize(texture);
|
||||
|
||||
float xStart = 20.0f;
|
||||
float yStart = 50.0f;
|
||||
@@ -929,11 +922,9 @@ static void DebugDraw2dImagePixelRounding()
|
||||
|
||||
imageOptions.pixelRounding = roundings[j];
|
||||
|
||||
draw2d->DrawImage(texId, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions);
|
||||
draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions);
|
||||
}
|
||||
}
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -941,12 +932,10 @@ static void DebugDraw2dImagePixelRounding()
|
||||
#if !defined(_RELEASE)
|
||||
static void DebugDraw2dLineBasic()
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions();
|
||||
|
||||
draw2d->BeginDraw2d(g_deferDrawsToEndOfFrame);
|
||||
|
||||
draw2d->DrawText("Testing DrawLine", AZ::Vector2(20, 20), 16);
|
||||
|
||||
AZ::Vector2 center = AZ::Vector2(draw2d->GetViewportWidth() * 0.5f, draw2d->GetViewportHeight() * 0.5f);
|
||||
@@ -963,8 +952,6 @@ static void DebugDraw2dLineBasic()
|
||||
draw2d->DrawLine(center, center + AZ::Vector2(-offset, -offset), AZ::Color(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
draw2d->DrawLine(center, center + AZ::Vector2(0, -offset), AZ::Color(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
draw2d->DrawLine(center, center + AZ::Vector2(offset, -offset), AZ::Color(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1436,13 +1423,17 @@ void LyShineDebug::RenderDebug()
|
||||
#if !defined(_RELEASE)
|
||||
|
||||
#ifndef EXCLUDE_DOCUMENTATION_PURPOSE
|
||||
if (!Draw2dHelper::GetDraw2d())
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
if (!draw2d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_deferDrawsToEndOfFrame = (CV_r_DebugUIDraw2dDefer) ? true : false;
|
||||
|
||||
// Set whether to defer draws or render immediately during scope of this helper
|
||||
Draw2dHelper draw2dHelper(g_deferDrawsToEndOfFrame);
|
||||
|
||||
if (CV_r_DebugUIDraw2dFont)
|
||||
{
|
||||
switch (CV_r_DebugUIDraw2dFont)
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <LyShine/Bus/UiEntityContextBus.h>
|
||||
#include <LyShine/Bus/UiCanvasUpdateNotificationBus.h>
|
||||
#include <LyShine/UiSerializeHelpers.h>
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
@@ -2224,13 +2225,13 @@ void UiCanvasComponent::DebugReportDrawCalls(AZ::IO::HandleType fileHandle, LySh
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void UiCanvasComponent::DebugDisplayElemBounds(IDraw2d* draw2d) const
|
||||
void UiCanvasComponent::DebugDisplayElemBounds(CDraw2d* draw2d) const
|
||||
{
|
||||
DebugDisplayChildElemBounds(draw2d, m_rootElement);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void UiCanvasComponent::DebugDisplayChildElemBounds(IDraw2d* draw2d, const AZ::EntityId entity) const
|
||||
void UiCanvasComponent::DebugDisplayChildElemBounds(CDraw2d* draw2d, const AZ::EntityId entity) const
|
||||
{
|
||||
AZ::u64 time = AZStd::GetTimeUTCMilliSecond();
|
||||
uint32 fractionsOfOneSecond = time % 1000;
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
struct SDepthTexture;
|
||||
class CDraw2d;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class UiCanvasComponent
|
||||
@@ -287,8 +288,8 @@ public: // member functions
|
||||
|
||||
void DebugReportDrawCalls(AZ::IO::HandleType fileHandle, LyShineDebug::DebugInfoDrawCallReport& reportInfo, void* context) const;
|
||||
|
||||
void DebugDisplayElemBounds(IDraw2d* draw2d) const;
|
||||
void DebugDisplayChildElemBounds(IDraw2d* draw2d, const AZ::EntityId entity) const;
|
||||
void DebugDisplayElemBounds(CDraw2d* draw2d) const;
|
||||
void DebugDisplayChildElemBounds(CDraw2d* draw2d, const AZ::EntityId entity) const;
|
||||
#endif
|
||||
|
||||
public: // static member functions
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#include "LyShine_precompiled.h"
|
||||
#include "UiCanvasManager.h"
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include "UiCanvasFileObject.h"
|
||||
#include "UiCanvasComponent.h"
|
||||
@@ -33,6 +34,8 @@
|
||||
#include <LyShine/Bus/World/UiCanvasOnMeshBus.h>
|
||||
#include <LyShine/Bus/World/UiCanvasRefBus.h>
|
||||
|
||||
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
|
||||
|
||||
#ifndef _RELEASE
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#endif
|
||||
@@ -998,16 +1001,15 @@ void UiCanvasManager::DebugDisplayCanvasData(int setting) const
|
||||
{
|
||||
bool onlyShowEnabledCanvases = (setting == 2) ? true : false;
|
||||
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
|
||||
draw2d->BeginDraw2d(false);
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
float xOffset = 20.0f;
|
||||
float yOffset = 20.0f;
|
||||
|
||||
const int elementNameFieldLength = 20;
|
||||
|
||||
int blackTexture = gEnv->pRenderer->GetBlackTextureId();
|
||||
auto blackTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::Black);
|
||||
|
||||
float textOpacity = 1.0f;
|
||||
float backgroundRectOpacity = 0.75f;
|
||||
|
||||
@@ -1152,21 +1154,17 @@ void UiCanvasManager::DebugDisplayCanvasData(int setting) const
|
||||
totalEnabledIntrs, totalEnabledUpdates);
|
||||
|
||||
WriteLine(buffer, red);
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void UiCanvasManager::DebugDisplayDrawCallData() const
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
|
||||
draw2d->BeginDraw2d(false);
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
float xOffset = 20.0f;
|
||||
float yOffset = 20.0f;
|
||||
|
||||
int blackTexture = gEnv->pRenderer->GetBlackTextureId();
|
||||
auto blackTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::Black);
|
||||
float textOpacity = 1.0f;
|
||||
float backgroundRectOpacity = 0.75f;
|
||||
const float lineSpacing = 20.0f;
|
||||
@@ -1293,8 +1291,6 @@ void UiCanvasManager::DebugDisplayDrawCallData() const
|
||||
totalDueToMaxVerts, totalDueToTextures);
|
||||
|
||||
WriteLine(buffer, red);
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1492,9 +1488,7 @@ void UiCanvasManager::DebugReportDrawCalls(const AZStd::string& name) const
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void UiCanvasManager::DebugDisplayElemBounds(int canvasIndexFilter) const
|
||||
{
|
||||
IDraw2d* draw2d = Draw2dHelper::GetDraw2d();
|
||||
|
||||
draw2d->BeginDraw2d(false);
|
||||
CDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d();
|
||||
|
||||
int canvasIndex = 0;
|
||||
for (auto canvas : m_loadedCanvases)
|
||||
@@ -1515,8 +1509,6 @@ void UiCanvasManager::DebugDisplayElemBounds(int canvasIndexFilter) const
|
||||
|
||||
++canvasIndex; // only increments for enabled canvases so index matches "ui_DisplayCanvasData 2"
|
||||
}
|
||||
|
||||
draw2d->EndDraw2d();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#include "LyShine_precompiled.h"
|
||||
#include "UiFaderComponent.h"
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <IRenderer.h>
|
||||
|
||||
#include <LyShine/IDraw2d.h>
|
||||
#include <LyShine/Draw2d.h>
|
||||
#include <LyShine/UiSerializeHelpers.h>
|
||||
#include <LyShine/Bus/UiElementBus.h>
|
||||
#include <LyShine/Bus/UiCanvasBus.h>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "LyShine_precompiled.h"
|
||||
|
||||
#include "UiImageSequenceComponent.h"
|
||||
#include <LyShine/IDraw2d.h>
|
||||
#include <LyShine/Draw2d.h>
|
||||
#include <LyShine/ISprite.h>
|
||||
#include <LyShine/IRenderGraph.h>
|
||||
#include <LyShine/Bus/UiElementBus.h>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#include "LyShine_precompiled.h"
|
||||
#include "UiMaskComponent.h"
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
@@ -23,7 +24,6 @@
|
||||
#include <LyShine/Bus/UiRenderBus.h>
|
||||
#include <LyShine/Bus/UiVisualBus.h>
|
||||
#include <LyShine/Bus/UiCanvasBus.h>
|
||||
#include <LyShine/IDraw2d.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC MEMBER FUNCTIONS
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
#include <LyShine/Bus/UiCanvasBus.h>
|
||||
#include <LyShine/UiSerializeHelpers.h>
|
||||
#include <LyShine/IRenderGraph.h>
|
||||
#include <LyShine/Draw2d.h>
|
||||
|
||||
#include <ILocalizationManager.h>
|
||||
|
||||
#include "UiSerialize.h"
|
||||
#include "Draw2d.h"
|
||||
#include "TextMarkup.h"
|
||||
#include "UiTextComponentOffsetsSelector.h"
|
||||
#include "StringUtfUtils.h"
|
||||
|
||||
Reference in New Issue
Block a user