mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-06 06:09:50 +00:00
Compare commits
1 Commits
dev/migrie
...
user/lheck
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa81e700ff |
@@ -265,7 +265,12 @@ void BackendD3D::_handleSettingsUpdate(const RenderingPayload& p)
|
||||
{
|
||||
wil::com_ptr<ID3D11Texture2D> buffer;
|
||||
THROW_IF_FAILED(p.swapChain.swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(buffer.addressof())));
|
||||
THROW_IF_FAILED(p.device->CreateRenderTargetView(buffer.get(), nullptr, _renderTargetView.put()));
|
||||
|
||||
static constexpr D3D11_RENDER_TARGET_VIEW_DESC desc{
|
||||
.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB,
|
||||
.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D,
|
||||
};
|
||||
THROW_IF_FAILED(p.device->CreateRenderTargetView(buffer.get(), &desc, _renderTargetView.put()));
|
||||
}
|
||||
|
||||
const auto fontChanged = _fontGeneration != p.s->font.generation();
|
||||
@@ -547,7 +552,7 @@ void BackendD3D::_recreateBackgroundColorBitmap(const RenderingPayload& p)
|
||||
.Height = p.s->viewportCellCount.y,
|
||||
.MipLevels = 1,
|
||||
.ArraySize = 1,
|
||||
.Format = DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
|
||||
.SampleDesc = { 1, 0 },
|
||||
.Usage = D3D11_USAGE_DYNAMIC,
|
||||
.BindFlags = D3D11_BIND_SHADER_RESOURCE,
|
||||
|
||||
@@ -35,6 +35,7 @@ float3 DWrite_EnhanceContrast3(float3 alpha, float k)
|
||||
return alpha * (k + 1.0f) / (alpha * k + 1.0f);
|
||||
}
|
||||
|
||||
// dwrite vs. gamma 1.8: https://www.desmos.com/calculator/6wocsr6vcq
|
||||
float DWrite_ApplyAlphaCorrection(float a, float f, float4 g)
|
||||
{
|
||||
return a + a * (1 - a) * ((g.x * f + g.y) * a + (g.z * f + g.w));
|
||||
|
||||
@@ -27,7 +27,7 @@ struct PSData
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord : texcoord;
|
||||
nointerpolation uint shadingType : shadingType;
|
||||
nointerpolation uint2 renditionScale : renditionScale;
|
||||
nointerpolation float2 renditionScale : renditionScale;
|
||||
nointerpolation float4 color : color;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,27 +44,13 @@ Output main(PSData data) : SV_Target
|
||||
}
|
||||
case SHADING_TYPE_TEXT_GRAYSCALE:
|
||||
{
|
||||
// These are independent of the glyph texture and could be moved to the vertex shader or CPU side of things.
|
||||
const float4 foreground = premultiplyColor(data.color);
|
||||
const float blendEnhancedContrast = DWrite_ApplyLightOnDarkContrastAdjustment(enhancedContrast, data.color.rgb);
|
||||
const float intensity = DWrite_CalcColorIntensity(data.color.rgb);
|
||||
// These aren't.
|
||||
const float4 glyph = glyphAtlas[data.texcoord];
|
||||
const float contrasted = DWrite_EnhanceContrast(glyph.a, blendEnhancedContrast);
|
||||
const float alphaCorrected = DWrite_ApplyAlphaCorrection(contrasted, intensity, gammaRatios);
|
||||
color = alphaCorrected * foreground;
|
||||
color = glyphAtlas[data.texcoord].a * data.color;
|
||||
weights = color.aaaa;
|
||||
break;
|
||||
}
|
||||
case SHADING_TYPE_TEXT_CLEARTYPE:
|
||||
{
|
||||
// These are independent of the glyph texture and could be moved to the vertex shader or CPU side of things.
|
||||
const float blendEnhancedContrast = DWrite_ApplyLightOnDarkContrastAdjustment(enhancedContrast, data.color.rgb);
|
||||
// These aren't.
|
||||
const float4 glyph = glyphAtlas[data.texcoord];
|
||||
const float3 contrasted = DWrite_EnhanceContrast3(glyph.rgb, blendEnhancedContrast);
|
||||
const float3 alphaCorrected = DWrite_ApplyAlphaCorrection3(contrasted, data.color.rgb, gammaRatios);
|
||||
weights = float4(alphaCorrected * data.color.a, 1);
|
||||
weights = float4(glyphAtlas[data.texcoord].rgb * data.color.a, 1);
|
||||
color = weights * data.color;
|
||||
break;
|
||||
}
|
||||
@@ -77,14 +63,14 @@ Output main(PSData data) : SV_Target
|
||||
case SHADING_TYPE_DOTTED_LINE:
|
||||
{
|
||||
const bool on = frac(data.position.x / (2.0f * underlineWidth * data.renditionScale.x)) < 0.5f;
|
||||
color = on * premultiplyColor(data.color);
|
||||
color = on * data.color;
|
||||
weights = color.aaaa;
|
||||
break;
|
||||
}
|
||||
case SHADING_TYPE_DASHED_LINE:
|
||||
{
|
||||
const bool on = frac(data.position.x / (backgroundCellSize.x * data.renditionScale.x)) < 0.5f;
|
||||
color = on * premultiplyColor(data.color);
|
||||
color = on * data.color;
|
||||
weights = color.aaaa;
|
||||
break;
|
||||
}
|
||||
@@ -102,13 +88,13 @@ Output main(PSData data) : SV_Target
|
||||
const float s = sin(data.position.x * freq);
|
||||
const float d = abs(centerY - (s * amp) - data.position.y);
|
||||
const float a = 1 - saturate(d - strokeWidthHalf);
|
||||
color = a * premultiplyColor(data.color);
|
||||
color = a * data.color;
|
||||
weights = color.aaaa;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
color = premultiplyColor(data.color);
|
||||
color = data.color;
|
||||
weights = color.aaaa;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "shader_common.hlsl"
|
||||
|
||||
#pragma warning(disable: 3571) // pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
|
||||
|
||||
cbuffer ConstBuffer : register(b0)
|
||||
{
|
||||
float2 positionScale;
|
||||
@@ -13,7 +15,7 @@ PSData main(VSData data)
|
||||
// clang-format on
|
||||
{
|
||||
PSData output;
|
||||
output.color = data.color;
|
||||
output.color = float4(pow(data.color.rgb * data.color.a, 2.2), data.color.a);
|
||||
output.shadingType = data.shadingType;
|
||||
output.renditionScale = data.renditionScale;
|
||||
// positionScale is expected to be float2(2.0f / sizeInPixel.x, -2.0f / sizeInPixel.y). Together with the
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user