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(); } }