本文整理匯總了C++中DrawTarget::MaskSurface方法的典型用法代碼示例。如果您正苦於以下問題:C++ DrawTarget::MaskSurface方法的具體用法?C++ DrawTarget::MaskSurface怎麽用?C++ DrawTarget::MaskSurface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DrawTarget
的用法示例。
在下文中一共展示了DrawTarget::MaskSurface方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: Point
void
gfxAlphaBoxBlur::Paint(gfxContext* aDestinationCtx)
{
if (!mContext)
return;
mBlur->Blur(mData);
mozilla::gfx::Rect* dirtyRect = mBlur->GetDirtyRect();
DrawTarget *dest = aDestinationCtx->GetDrawTarget();
if (!dest) {
NS_ERROR("Blurring not supported for Thebes contexts!");
return;
}
mozilla::RefPtr<SourceSurface> mask
= dest->CreateSourceSurfaceFromData(mData,
mBlur->GetSize(),
mBlur->GetStride(),
FORMAT_A8);
if (!mask) {
NS_ERROR("Failed to create mask!");
return;
}
nsRefPtr<gfxPattern> thebesPat = aDestinationCtx->GetPattern();
Pattern* pat = thebesPat->GetPattern(dest, nullptr);
Matrix oldTransform = dest->GetTransform();
Matrix newTransform = oldTransform;
newTransform.Translate(mBlur->GetRect().x, mBlur->GetRect().y);
// Avoid a semi-expensive clip operation if we can, otherwise
// clip to the dirty rect
if (dirtyRect) {
dest->PushClipRect(*dirtyRect);
}
dest->SetTransform(newTransform);
dest->MaskSurface(*pat, mask, Point(0, 0));
dest->SetTransform(oldTransform);
if (dirtyRect) {
dest->PopClip();
}
}
示例2: DoBlur
void
gfxAlphaBoxBlur::Paint(gfxContext* aDestinationCtx)
{
if (!mAccelerated && !mData) {
return;
}
DrawTarget *dest = aDestinationCtx->GetDrawTarget();
if (!dest) {
NS_WARNING("Blurring not supported for Thebes contexts!");
return;
}
RefPtr<gfxPattern> thebesPat = aDestinationCtx->GetPattern();
Pattern* pat = thebesPat->GetPattern(dest, nullptr);
if (!pat) {
NS_WARNING("Failed to get pattern for blur!");
return;
}
IntPoint topLeft;
RefPtr<SourceSurface> mask = DoBlur(nullptr, &topLeft);
if (!mask) {
NS_ERROR("Failed to create mask!");
return;
}
// Avoid a semi-expensive clip operation if we can, otherwise
// clip to the dirty rect
Rect* dirtyRect = mBlur.GetDirtyRect();
if (dirtyRect) {
dest->PushClipRect(*dirtyRect);
}
Matrix oldTransform = dest->GetTransform();
Matrix newTransform = oldTransform;
newTransform.PreTranslate(topLeft);
dest->SetTransform(newTransform);
dest->MaskSurface(*pat, mask, Point(0, 0));
dest->SetTransform(oldTransform);
if (dirtyRect) {
dest->PopClip();
}
}