feat(windows): usbip-win runbook ([~]) + clean-room Kinect10.dll NUI shim (x86+x64 export-verified) (wave 9; todo 14 done, 12/13 blocked)
This commit is contained in:
1 parent
3eb8c07e4c
commit
9b5a0255e2
30 files changed
+3007
-12
No files matched your search
@@ -0,0 +1,94 @@
|
||||
#include "frame_texture.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace nui_shim {
|
||||
|
||||
NuiFrameTexture::NuiFrameTexture(uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t bytes_per_pixel)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
bytes_per_pixel_(bytes_per_pixel),
|
||||
bits_(static_cast<std::size_t>(width) * height * bytes_per_pixel, 0) {}
|
||||
|
||||
void NuiFrameTexture::set_bits(const uint8_t* data, std::size_t size) {
|
||||
const std::size_t n = size < bits_.size() ? size : bits_.size();
|
||||
if (data != nullptr && n != 0) {
|
||||
std::memcpy(bits_.data(), data, n);
|
||||
}
|
||||
if (n < bits_.size()) {
|
||||
std::memset(bits_.data() + n, 0, bits_.size() - n);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* NuiFrameTexture::data() { return bits_.data(); }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE NuiFrameTexture::QueryInterface(REFIID riid,
|
||||
void** ppv) {
|
||||
if (ppv == nullptr) {
|
||||
return E_POINTER;
|
||||
}
|
||||
if (IsEqualIID(riid, IID_IUnknown)) {
|
||||
*ppv = static_cast<IUnknown*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
*ppv = nullptr;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE NuiFrameTexture::AddRef() {
|
||||
return static_cast<ULONG>(InterlockedIncrement(&ref_count_));
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE NuiFrameTexture::Release() {
|
||||
const LONG count = InterlockedDecrement(&ref_count_);
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
return static_cast<ULONG>(count);
|
||||
}
|
||||
|
||||
int STDMETHODCALLTYPE NuiFrameTexture::BufferLen() {
|
||||
return static_cast<int>(bits_.size());
|
||||
}
|
||||
|
||||
int STDMETHODCALLTYPE NuiFrameTexture::Pitch() {
|
||||
return static_cast<int>(width_ * bytes_per_pixel_);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE NuiFrameTexture::LockRect(UINT Level,
|
||||
NUI_LOCKED_RECT* pLockedRect,
|
||||
RECT*,
|
||||
DWORD) {
|
||||
if (pLockedRect == nullptr) {
|
||||
return E_POINTER;
|
||||
}
|
||||
if (Level != 0) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
pLockedRect->Pitch = static_cast<INT>(width_ * bytes_per_pixel_);
|
||||
pLockedRect->size = static_cast<INT>(bits_.size());
|
||||
pLockedRect->pBits = bits_.data();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE NuiFrameTexture::GetLevelDesc(UINT Level,
|
||||
NUI_SURFACE_DESC* pDesc) {
|
||||
if (pDesc == nullptr) {
|
||||
return E_POINTER;
|
||||
}
|
||||
if (Level != 0) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
pDesc->Width = width_;
|
||||
pDesc->Height = height_;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE NuiFrameTexture::UnlockRect(UINT Level) {
|
||||
return Level == 0 ? S_OK : E_INVALIDARG;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user