Skip to content

Commit 7872454

Browse files
committed
fix: 修复彩色掩码光标的越界访问
1 parent 83b3af7 commit 7872454

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Magpie.Core/CursorDrawer2.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,8 @@ HRESULT CursorDrawer2::_InitializeCursorTexture(_CursorInfo& cursorInfo) noexcep
706706
CD3DX12_HEAP_PROPERTIES heapProperties(D3D12_HEAP_TYPE_UPLOAD);
707707

708708
CD3DX12_RESOURCE_DESC texDesc = CD3DX12_RESOURCE_DESC::Tex2D(
709-
cursorInfo.type == _CursorType::Monochrome ? DXGI_FORMAT_R8_UNORM : DXGI_FORMAT_R16G16B16A16_FLOAT,
709+
cursorInfo.type == _CursorType::Color ? DXGI_FORMAT_R16G16B16A16_FLOAT :
710+
(cursorInfo.type == _CursorType::Monochrome ? DXGI_FORMAT_R8_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM),
710711
cursorInfo.originSize.width, cursorInfo.originSize.height, 1, 1);
711712

712713
D3D12_PLACED_SUBRESOURCE_FOOTPRINT textureLayout;
@@ -716,7 +717,7 @@ HRESULT CursorDrawer2::_InitializeCursorTexture(_CursorInfo& cursorInfo) noexcep
716717
&textureLayout, nullptr, &textureRowSizeInBytes, &textureSize);
717718

718719
assert(textureRowSizeInBytes == cursorInfo.originSize.width *
719-
(cursorInfo.type == _CursorType::Monochrome ? 1 : 8));
720+
(cursorInfo.type == _CursorType::Color ? 8 : (cursorInfo.type == _CursorType::Monochrome ? 1 : 4)));
720721

721722
CD3DX12_RESOURCE_DESC bufferDesc = CD3DX12_RESOURCE_DESC::Buffer(textureSize);
722723

0 commit comments

Comments
 (0)