checkpoint(new_editor): native d3d12 ui path
Key node 1: move main-window UI presentation onto the D3D12 render loop with native UI renderer, text system, and texture host. Key node 2: wire frame timing/FPS display, window runtime, swapchain presentation, and native screenshot capture around the new path. Key node 3: carry editor shell/workspace/viewport/panel interaction updates needed by the new renderer and detached window flow. Key node 4: pump async resource loads and scene bridge follow-up needed for scene content visibility in new_editor.
This commit is contained in:
85
new_editor/app/Rendering/D3D12/D3D12UiTextSystem.h
Normal file
85
new_editor/app/Rendering/D3D12/D3D12UiTextSystem.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
|
||||
#include <dwrite.h>
|
||||
#include <windows.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Host {
|
||||
|
||||
class D3D12UiTextSystem final : public ::XCEngine::UI::Editor::UIEditorTextMeasurer {
|
||||
public:
|
||||
struct ShapedGlyph {
|
||||
Microsoft::WRL::ComPtr<IDWriteFontFace> fontFace = {};
|
||||
std::uint16_t glyphIndex = 0u;
|
||||
float fontEmSize = 0.0f;
|
||||
float originX = 0.0f;
|
||||
float originY = 0.0f;
|
||||
DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE_NATURAL;
|
||||
bool isSideways = false;
|
||||
};
|
||||
|
||||
struct ShapedTextRun {
|
||||
std::vector<ShapedGlyph> glyphs = {};
|
||||
float width = 0.0f;
|
||||
float height = 0.0f;
|
||||
};
|
||||
|
||||
struct RasterizedGlyph {
|
||||
std::vector<std::uint8_t> rgbaPixels = {};
|
||||
UINT width = 0u;
|
||||
UINT height = 0u;
|
||||
LONG boundsLeft = 0;
|
||||
LONG boundsTop = 0;
|
||||
LONG boundsRight = 0;
|
||||
LONG boundsBottom = 0;
|
||||
};
|
||||
|
||||
bool Initialize();
|
||||
void Shutdown();
|
||||
|
||||
void SetDpiScale(float dpiScale);
|
||||
float GetDpiScale() const;
|
||||
const std::string& GetLastError() const;
|
||||
|
||||
float MeasureTextWidth(
|
||||
const ::XCEngine::UI::Editor::UIEditorTextMeasureRequest& request) const override;
|
||||
bool ShapeTextRun(
|
||||
std::string_view text,
|
||||
float fontSize,
|
||||
ShapedTextRun& outRun,
|
||||
std::string& outError) const;
|
||||
bool RasterizeGlyph(
|
||||
const ShapedGlyph& glyph,
|
||||
RasterizedGlyph& outGlyph,
|
||||
std::string& outError) const;
|
||||
bool RasterizeTextMask(
|
||||
std::string_view text,
|
||||
float fontSize,
|
||||
std::vector<std::uint8_t>& outRgbaPixels,
|
||||
UINT& outWidth,
|
||||
UINT& outHeight,
|
||||
std::string& outError);
|
||||
|
||||
private:
|
||||
IDWriteTextFormat* GetTextFormat(float fontSize) const;
|
||||
static std::wstring Utf8ToWide(std::string_view text);
|
||||
|
||||
Microsoft::WRL::ComPtr<IDWriteFactory> m_dwriteFactory = {};
|
||||
mutable std::unordered_map<int, Microsoft::WRL::ComPtr<IDWriteTextFormat>> m_textFormats = {};
|
||||
float m_dpiScale = 1.0f;
|
||||
std::string m_lastError = {};
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Host
|
||||
Reference in New Issue
Block a user