本文整理汇总了C++中microsoft::wrl::ComPtr::EndDraw方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::EndDraw方法的具体用法?C++ ComPtr::EndDraw怎么用?C++ ComPtr::EndDraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::EndDraw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Ends drawing updates started by a previous BeginDraw call.
void Scenario1ImageSource::EndDraw()
{
// Remove the transform and clip applied in BeginDraw since
// the target area can change on every update.
m_d2dContext->SetTransform(D2D1::IdentityMatrix());
m_d2dContext->PopAxisAlignedClip();
// Remove the render target and end drawing.
DX::ThrowIfFailed(
m_d2dContext->EndDraw()
);
m_d2dContext->SetTarget(nullptr);
// Query for ISurfaceImageSourceNative interface.
Microsoft::WRL::ComPtr<ISurfaceImageSourceNative> sisNative;
DX::ThrowIfFailed(
reinterpret_cast<IUnknown*>(this)->QueryInterface(IID_PPV_ARGS(&sisNative))
);
DX::ThrowIfFailed(
sisNative->EndDraw()
);
}
示例2: ApplyInlineFormat
void TextInlineFormat_Shadow::ApplyInlineFormat(ID2D1RenderTarget* target, IDWriteTextLayout* layout,
ID2D1SolidColorBrush* solidBrush, const UINT32& strLen, const D2D1_POINT_2F& drawPosition)
{
if (!target || !layout) return;
// In order to make a shadow effect using the built-in D2D effect, we first need to make
// certain parts of the string transparent. We then draw only the parts of the string we
// we want a shadow for onto a memory bitmap. From this bitmap we can create the shadow
// effect and draw it.
D2D1_COLOR_F color = D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.0f);
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> transparent;
HRESULT hr = target->CreateSolidColorBrush(color, transparent.GetAddressOf());
if (FAILED(hr)) return;
// Only change characters outside of the range(s) transparent
for (UINT32 i = 0; i < strLen; ++i)
{
bool found = false;
for (const auto& range : GetRanges())
{
if (range.length <= 0) continue;
if (i >= range.startPosition && i < (range.startPosition + range.length))
{
found = true;
break;
}
}
if (!found)
{
DWRITE_TEXT_RANGE temp = { i, 1 };
layout->SetDrawingEffect(transparent.Get(), temp);
}
}
Microsoft::WRL::ComPtr<ID2D1Bitmap> bitmap;
Microsoft::WRL::ComPtr<ID2D1BitmapRenderTarget> bTarget;
hr = target->CreateCompatibleRenderTarget(bTarget.GetAddressOf());
if (FAILED(hr)) return;
// Draw onto memory bitmap target
bTarget->BeginDraw();
bTarget->DrawTextLayout(drawPosition, layout, solidBrush);
bTarget->EndDraw();
hr = bTarget->GetBitmap(bitmap.GetAddressOf());
if (FAILED(hr)) return;
// Shadow effects can only be drawn with a D2D device context
Microsoft::WRL::ComPtr<ID2D1DeviceContext> dc;
hr = target->QueryInterface(__uuidof(ID2D1DeviceContext), reinterpret_cast<void**>(dc.GetAddressOf()));
if (FAILED(hr)) return;
// Create shadow effect
Microsoft::WRL::ComPtr<ID2D1Effect> shadow;
hr = dc->CreateEffect(CLSID_D2D1Shadow, &shadow);
if (FAILED(hr)) return;
// Load shadow options to effect
shadow->SetInput(0, bitmap.Get());
shadow->SetValue(D2D1_SHADOW_PROP_BLUR_STANDARD_DEVIATION, m_Blur);
shadow->SetValue(D2D1_SHADOW_PROP_COLOR, ToVector4F(m_Color));
shadow->SetValue(D2D1_SHADOW_PROP_OPTIMIZATION, D2D1_SHADOW_OPTIMIZATION_SPEED);
// Draw effect
dc->DrawImage(shadow.Get(), m_Offset);
}