本文整理汇总了C++中CD3DTexture::LockRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CD3DTexture::LockRect方法的具体用法?C++ CD3DTexture::LockRect怎么用?C++ CD3DTexture::LockRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CD3DTexture
的用法示例。
在下文中一共展示了CD3DTexture::LockRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderImpl
void CRendererSoftware::RenderImpl(CD3DTexture& target, CRect& sourceRect, CPoint(&destPoints)[4], uint32_t flags)
{
// if creation failed
if (!m_outputShader)
return;
CRenderBuffer* buf = m_renderBuffers[m_iBufferIndex];
// 1. convert yuv to rgb
m_sw_scale_ctx = sws_getCachedContext(m_sw_scale_ctx,
buf->GetWidth(), buf->GetHeight(), buf->av_format,
buf->GetWidth(), buf->GetHeight(), AV_PIX_FMT_BGRA,
SWS_FAST_BILINEAR, nullptr, nullptr, nullptr);
if (!m_sw_scale_ctx)
return;
sws_setColorspaceDetails(m_sw_scale_ctx,
sws_getCoefficients(buf->color_space), buf->full_range,
sws_getCoefficients(AVCOL_SPC_BT709), buf->full_range,
0, 1 << 16, 1 << 16);
uint8_t* src[YuvImage::MAX_PLANES];
int srcStride[YuvImage::MAX_PLANES];
buf->GetDataPlanes(src, srcStride);
D3D11_MAPPED_SUBRESOURCE mapping;
if (target.LockRect(0, &mapping, D3D11_MAP_WRITE_DISCARD))
{
uint8_t *dst[] = { static_cast<uint8_t*>(mapping.pData), nullptr, nullptr };
int dstStride[] = { static_cast<int>(mapping.RowPitch), 0, 0 };
sws_scale(m_sw_scale_ctx, src, srcStride, 0, std::min(target.GetHeight(), buf->GetHeight()), dst, dstStride);
if (!target.UnlockRect(0))
CLog::LogF(LOGERROR, "failed to unlock swtarget texture.");
}
else
CLog::LogF(LOGERROR, "failed to lock swtarget texture into memory.");
// rotate initial rect
ReorderDrawPoints(CRect(destPoints[0], destPoints[2]), destPoints);
}