Stop mapping all Unicode through CJK fonts and cut D2D working-set growth
Custom font fallback no longer covers the whole BMP/SIP, so Segoe UI Emoji can paint color glyphs again; CJK still prefers Noto Sans SC then YaHei. Drop GaussianBlur compatible targets during BeginDraw (they retained GPU memory as the candidate window grew), grow the composition swapchain in 64px steps without shrinking, and reuse Card chrome plus cached text formats instead of reallocating them every layout.
This commit is contained in:
1 parent
5421c1dd1b
commit
2ac86ea0e2
5 files changed
+152
-122
No files matched your search
+28
-10
@@ -7,6 +7,16 @@
|
||||
|
||||
namespace msimeui
|
||||
{
|
||||
namespace
|
||||
{
|
||||
UINT AlignSwapExtent(UINT value)
|
||||
{
|
||||
constexpr UINT kBucket = 64;
|
||||
value = (std::max)(value, 1U);
|
||||
return ((value + kBucket - 1U) / kBucket) * kBucket;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool DeviceResources::IsSameColor(const D2D1_COLOR_F &lhs, const D2D1_COLOR_F &rhs)
|
||||
{
|
||||
return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
|
||||
@@ -128,10 +138,10 @@ bool DeviceResources::EnsureForComposition(HWND hwnd)
|
||||
|
||||
RECT rc = {};
|
||||
GetClientRect(hwnd, &rc);
|
||||
const UINT width = static_cast<UINT>((std::max)(rc.right, 1L));
|
||||
const UINT height = static_cast<UINT>((std::max)(rc.bottom, 1L));
|
||||
const UINT width = AlignSwapExtent(static_cast<UINT>((std::max)(rc.right, 1L)));
|
||||
const UINT height = AlignSwapExtent(static_cast<UINT>((std::max)(rc.bottom, 1L)));
|
||||
|
||||
if (composition_ && deviceContext_ && swapChain_ && pixelWidth_ == width && pixelHeight_ == height)
|
||||
if (composition_ && deviceContext_ && swapChain_ && pixelWidth_ >= width && pixelHeight_ >= height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -210,11 +220,13 @@ bool DeviceResources::EnsureForComposition(HWND hwnd)
|
||||
return true;
|
||||
}
|
||||
|
||||
pixelWidth_ = width;
|
||||
pixelHeight_ = height;
|
||||
const UINT newWidth = (std::max)(pixelWidth_, width);
|
||||
const UINT newHeight = (std::max)(pixelHeight_, height);
|
||||
pixelWidth_ = newWidth;
|
||||
pixelHeight_ = newHeight;
|
||||
deviceContext_->SetTarget(nullptr);
|
||||
dxgiBitmap_.Reset();
|
||||
if (FAILED(swapChain_->ResizeBuffers(0, width, height, DXGI_FORMAT_B8G8R8A8_UNORM, 0)))
|
||||
if (FAILED(swapChain_->ResizeBuffers(0, newWidth, newHeight, DXGI_FORMAT_B8G8R8A8_UNORM, 0)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -232,13 +244,19 @@ void DeviceResources::Resize(UINT width, UINT height)
|
||||
pixelHeight_ = height;
|
||||
return;
|
||||
}
|
||||
if (composition_ && swapChain_ && deviceContext_ && (pixelWidth_ != width || pixelHeight_ != height))
|
||||
if (composition_ && swapChain_ && deviceContext_)
|
||||
{
|
||||
pixelWidth_ = width;
|
||||
pixelHeight_ = height;
|
||||
const UINT neededW = AlignSwapExtent(width);
|
||||
const UINT neededH = AlignSwapExtent(height);
|
||||
if (pixelWidth_ >= neededW && pixelHeight_ >= neededH)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pixelWidth_ = (std::max)(pixelWidth_, neededW);
|
||||
pixelHeight_ = (std::max)(pixelHeight_, neededH);
|
||||
deviceContext_->SetTarget(nullptr);
|
||||
dxgiBitmap_.Reset();
|
||||
if (SUCCEEDED(swapChain_->ResizeBuffers(0, width, height, DXGI_FORMAT_B8G8R8A8_UNORM, 0)))
|
||||
if (SUCCEEDED(swapChain_->ResizeBuffers(0, pixelWidth_, pixelHeight_, DXGI_FORMAT_B8G8R8A8_UNORM, 0)))
|
||||
{
|
||||
BindCompositionSurface();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user