2008-09-25 19:53:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-09-25 19:53:09 +00:00
|
|
|
|
|
|
|
#include "gfxBlur.h"
|
2014-11-01 10:45:10 +00:00
|
|
|
|
|
|
|
#include "gfx2DGlue.h"
|
2013-10-07 23:15:59 +00:00
|
|
|
#include "gfxContext.h"
|
2013-10-02 04:20:47 +00:00
|
|
|
#include "gfxPlatform.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-11-01 10:45:10 +00:00
|
|
|
#include "mozilla/gfx/Blur.h"
|
|
|
|
#include "mozilla/gfx/PathHelpers.h"
|
2014-07-21 15:06:11 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-02-18 19:10:00 +00:00
|
|
|
#include "mozilla/UniquePtrExtensions.h"
|
2014-06-10 21:51:24 +00:00
|
|
|
#include "nsExpirationTracker.h"
|
|
|
|
#include "nsClassHashtable.h"
|
2015-05-13 19:19:27 +00:00
|
|
|
#include "gfxUtils.h"
|
2008-09-25 19:53:09 +00:00
|
|
|
|
2014-06-10 21:51:24 +00:00
|
|
|
using namespace mozilla;
|
2011-11-18 09:19:24 +00:00
|
|
|
using namespace mozilla::gfx;
|
2008-09-25 19:53:09 +00:00
|
|
|
|
|
|
|
gfxAlphaBoxBlur::gfxAlphaBoxBlur()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxAlphaBoxBlur::~gfxAlphaBoxBlur()
|
|
|
|
{
|
2012-09-26 09:27:40 +00:00
|
|
|
mContext = nullptr;
|
2008-09-25 19:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxContext*
|
|
|
|
gfxAlphaBoxBlur::Init(const gfxRect& aRect,
|
2015-06-01 08:26:19 +00:00
|
|
|
const IntSize& aSpreadRadius,
|
|
|
|
const IntSize& aBlurRadius,
|
2010-04-18 03:13:10 +00:00
|
|
|
const gfxRect* aDirtyRect,
|
|
|
|
const gfxRect* aSkipRect)
|
2008-09-25 19:53:09 +00:00
|
|
|
{
|
2012-09-28 17:21:40 +00:00
|
|
|
mozilla::gfx::Rect rect(Float(aRect.x), Float(aRect.y),
|
|
|
|
Float(aRect.width), Float(aRect.height));
|
2011-11-18 09:19:24 +00:00
|
|
|
IntSize spreadRadius(aSpreadRadius.width, aSpreadRadius.height);
|
|
|
|
IntSize blurRadius(aBlurRadius.width, aBlurRadius.height);
|
2014-07-21 15:06:11 +00:00
|
|
|
UniquePtr<Rect> dirtyRect;
|
2008-12-06 18:54:36 +00:00
|
|
|
if (aDirtyRect) {
|
2014-07-21 15:06:11 +00:00
|
|
|
dirtyRect = MakeUnique<Rect>(Float(aDirtyRect->x),
|
|
|
|
Float(aDirtyRect->y),
|
|
|
|
Float(aDirtyRect->width),
|
|
|
|
Float(aDirtyRect->height));
|
2010-04-18 03:13:10 +00:00
|
|
|
}
|
2014-07-21 15:06:11 +00:00
|
|
|
UniquePtr<Rect> skipRect;
|
2011-11-17 18:01:11 +00:00
|
|
|
if (aSkipRect) {
|
2014-07-21 15:06:11 +00:00
|
|
|
skipRect = MakeUnique<Rect>(Float(aSkipRect->x),
|
|
|
|
Float(aSkipRect->y),
|
|
|
|
Float(aSkipRect->width),
|
|
|
|
Float(aSkipRect->height));
|
2011-11-17 18:01:11 +00:00
|
|
|
}
|
2011-11-14 04:29:28 +00:00
|
|
|
|
2014-07-21 15:06:11 +00:00
|
|
|
mBlur = MakeUnique<AlphaBoxBlur>(rect, spreadRadius, blurRadius, dirtyRect.get(), skipRect.get());
|
2014-09-17 07:46:42 +00:00
|
|
|
size_t blurDataSize = mBlur->GetSurfaceAllocationSize();
|
|
|
|
if (blurDataSize == 0)
|
2013-04-19 10:13:18 +00:00
|
|
|
return nullptr;
|
2011-11-18 09:19:24 +00:00
|
|
|
|
|
|
|
IntSize size = mBlur->GetSize();
|
2013-04-19 10:13:18 +00:00
|
|
|
|
2008-09-25 19:53:09 +00:00
|
|
|
// Make an alpha-only surface to draw on. We will play with the data after
|
|
|
|
// everything is drawn to create a blur effect.
|
2016-02-18 19:10:00 +00:00
|
|
|
mData = MakeUniqueFallible<unsigned char[]>(blurDataSize);
|
2014-09-17 07:46:42 +00:00
|
|
|
if (!mData) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-02-18 19:10:00 +00:00
|
|
|
memset(mData.get(), 0, blurDataSize);
|
2013-10-02 04:20:47 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DrawTarget> dt =
|
2016-02-18 19:10:00 +00:00
|
|
|
gfxPlatform::GetPlatform()->CreateDrawTargetForData(mData.get(), size,
|
2013-10-02 04:20:47 +00:00
|
|
|
mBlur->GetStride(),
|
2014-01-10 19:06:16 +00:00
|
|
|
SurfaceFormat::A8);
|
2016-04-12 19:18:11 +00:00
|
|
|
if (!dt || !dt->IsValid()) {
|
2014-06-26 07:40:12 +00:00
|
|
|
return nullptr;
|
2013-10-02 04:20:47 +00:00
|
|
|
}
|
2008-09-25 19:53:09 +00:00
|
|
|
|
2011-11-18 09:19:24 +00:00
|
|
|
IntRect irect = mBlur->GetRect();
|
|
|
|
gfxPoint topleft(irect.TopLeft().x, irect.TopLeft().y);
|
|
|
|
|
2016-04-12 19:18:11 +00:00
|
|
|
mContext = gfxContext::ForDrawTarget(dt);
|
|
|
|
MOZ_ASSERT(mContext); // already checked for target above
|
2014-09-11 06:57:38 +00:00
|
|
|
mContext->SetMatrix(gfxMatrix::Translation(-topleft));
|
2008-09-25 19:53:09 +00:00
|
|
|
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-10 21:51:24 +00:00
|
|
|
DrawBlur(gfxContext* aDestinationCtx,
|
|
|
|
SourceSurface* aBlur,
|
|
|
|
const IntPoint& aTopLeft,
|
|
|
|
const Rect* aDirtyRect)
|
2008-09-25 19:53:09 +00:00
|
|
|
{
|
2013-10-02 04:20:47 +00:00
|
|
|
DrawTarget *dest = aDestinationCtx->GetDrawTarget();
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxPattern> thebesPat = aDestinationCtx->GetPattern();
|
2013-10-02 04:20:47 +00:00
|
|
|
Pattern* pat = thebesPat->GetPattern(dest, nullptr);
|
2008-09-25 19:53:09 +00:00
|
|
|
|
2013-10-02 04:20:47 +00:00
|
|
|
Matrix oldTransform = dest->GetTransform();
|
|
|
|
Matrix newTransform = oldTransform;
|
2014-09-10 17:29:35 +00:00
|
|
|
newTransform.PreTranslate(aTopLeft.x, aTopLeft.y);
|
2008-09-25 19:53:09 +00:00
|
|
|
|
2008-12-06 18:54:36 +00:00
|
|
|
// Avoid a semi-expensive clip operation if we can, otherwise
|
|
|
|
// clip to the dirty rect
|
2014-06-10 21:51:24 +00:00
|
|
|
if (aDirtyRect) {
|
|
|
|
dest->PushClipRect(*aDirtyRect);
|
2013-10-02 04:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dest->SetTransform(newTransform);
|
2014-06-10 21:51:24 +00:00
|
|
|
dest->MaskSurface(*pat, aBlur, Point(0, 0));
|
2013-10-02 04:20:47 +00:00
|
|
|
dest->SetTransform(oldTransform);
|
|
|
|
|
2014-06-10 21:51:24 +00:00
|
|
|
if (aDirtyRect) {
|
2013-10-02 04:20:47 +00:00
|
|
|
dest->PopClip();
|
2008-12-06 18:54:36 +00:00
|
|
|
}
|
2008-09-25 19:53:09 +00:00
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
already_AddRefed<SourceSurface>
|
2014-06-10 21:51:24 +00:00
|
|
|
gfxAlphaBoxBlur::DoBlur(DrawTarget* aDT, IntPoint* aTopLeft)
|
|
|
|
{
|
2016-02-18 19:10:00 +00:00
|
|
|
mBlur->Blur(mData.get());
|
2014-06-10 21:51:24 +00:00
|
|
|
|
|
|
|
*aTopLeft = mBlur->GetRect().TopLeft();
|
|
|
|
|
2016-02-18 19:10:00 +00:00
|
|
|
return aDT->CreateSourceSurfaceFromData(mData.get(),
|
2014-06-10 21:51:24 +00:00
|
|
|
mBlur->GetSize(),
|
|
|
|
mBlur->GetStride(),
|
|
|
|
SurfaceFormat::A8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxAlphaBoxBlur::Paint(gfxContext* aDestinationCtx)
|
|
|
|
{
|
|
|
|
if (!mContext)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DrawTarget *dest = aDestinationCtx->GetDrawTarget();
|
|
|
|
if (!dest) {
|
|
|
|
NS_WARNING("Blurring not supported for Thebes contexts!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect* dirtyRect = mBlur->GetDirtyRect();
|
|
|
|
|
|
|
|
IntPoint topLeft;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> mask = DoBlur(dest, &topLeft);
|
2014-06-10 21:51:24 +00:00
|
|
|
if (!mask) {
|
|
|
|
NS_ERROR("Failed to create mask!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawBlur(aDestinationCtx, mask, topLeft, dirtyRect);
|
|
|
|
}
|
|
|
|
|
2015-06-01 08:26:19 +00:00
|
|
|
IntSize gfxAlphaBoxBlur::CalculateBlurRadius(const gfxPoint& aStd)
|
2008-09-25 19:53:09 +00:00
|
|
|
{
|
2012-09-28 17:21:40 +00:00
|
|
|
mozilla::gfx::Point std(Float(aStd.x), Float(aStd.y));
|
2011-11-18 09:19:24 +00:00
|
|
|
IntSize size = AlphaBoxBlur::CalculateBlurRadius(std);
|
2015-06-01 08:26:19 +00:00
|
|
|
return IntSize(size.width, size.height);
|
2008-09-25 19:53:09 +00:00
|
|
|
}
|
2013-11-25 23:08:29 +00:00
|
|
|
|
2014-06-10 21:51:24 +00:00
|
|
|
struct BlurCacheKey : public PLDHashEntryHdr {
|
|
|
|
typedef const BlurCacheKey& KeyType;
|
|
|
|
typedef const BlurCacheKey* KeyTypePointer;
|
|
|
|
enum { ALLOW_MEMMOVE = true };
|
|
|
|
|
2015-06-25 19:04:21 +00:00
|
|
|
IntSize mMinSize;
|
2015-06-01 08:26:19 +00:00
|
|
|
IntSize mBlurRadius;
|
2015-09-24 07:43:32 +00:00
|
|
|
Color mShadowColor;
|
2014-06-10 21:51:24 +00:00
|
|
|
BackendType mBackend;
|
2015-06-25 19:04:21 +00:00
|
|
|
RectCornerRadii mCornerRadii;
|
2015-09-24 16:50:29 +00:00
|
|
|
bool mIsInset;
|
2014-06-10 21:51:24 +00:00
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
// Only used for inset blurs
|
|
|
|
bool mHasBorderRadius;
|
|
|
|
IntSize mInnerMinSize;
|
|
|
|
|
2015-09-23 18:49:05 +00:00
|
|
|
BlurCacheKey(IntSize aMinSize, IntSize aBlurRadius,
|
2015-09-24 07:43:32 +00:00
|
|
|
RectCornerRadii* aCornerRadii, const Color& aShadowColor,
|
2015-09-24 16:50:29 +00:00
|
|
|
BackendType aBackendType)
|
|
|
|
: BlurCacheKey(aMinSize, IntSize(0, 0),
|
2016-03-29 15:24:21 +00:00
|
|
|
aBlurRadius, aCornerRadii,
|
|
|
|
aShadowColor, false,
|
|
|
|
false, aBackendType)
|
2015-09-24 16:50:29 +00:00
|
|
|
{}
|
2014-06-10 21:51:24 +00:00
|
|
|
|
2014-08-08 01:17:30 +00:00
|
|
|
explicit BlurCacheKey(const BlurCacheKey* aOther)
|
2015-06-25 19:04:21 +00:00
|
|
|
: mMinSize(aOther->mMinSize)
|
2014-06-10 21:51:24 +00:00
|
|
|
, mBlurRadius(aOther->mBlurRadius)
|
2015-06-25 19:04:21 +00:00
|
|
|
, mShadowColor(aOther->mShadowColor)
|
2014-06-10 21:51:24 +00:00
|
|
|
, mBackend(aOther->mBackend)
|
2015-06-25 19:04:21 +00:00
|
|
|
, mCornerRadii(aOther->mCornerRadii)
|
2015-09-24 16:50:29 +00:00
|
|
|
, mIsInset(aOther->mIsInset)
|
|
|
|
, mHasBorderRadius(aOther->mHasBorderRadius)
|
|
|
|
, mInnerMinSize(aOther->mInnerMinSize)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
explicit BlurCacheKey(IntSize aOuterMinSize, IntSize aInnerMinSize,
|
2016-03-29 15:24:21 +00:00
|
|
|
IntSize aBlurRadius,
|
2015-09-24 07:43:32 +00:00
|
|
|
const RectCornerRadii* aCornerRadii,
|
|
|
|
const Color& aShadowColor, bool aIsInset,
|
2015-09-24 16:50:29 +00:00
|
|
|
bool aHasBorderRadius, BackendType aBackendType)
|
|
|
|
: mMinSize(aOuterMinSize)
|
|
|
|
, mBlurRadius(aBlurRadius)
|
|
|
|
, mShadowColor(aShadowColor)
|
|
|
|
, mBackend(aBackendType)
|
|
|
|
, mCornerRadii(aCornerRadii ? *aCornerRadii : RectCornerRadii())
|
|
|
|
, mIsInset(aIsInset)
|
|
|
|
, mHasBorderRadius(aHasBorderRadius)
|
|
|
|
, mInnerMinSize(aInnerMinSize)
|
2014-06-10 21:51:24 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
static PLDHashNumber
|
|
|
|
HashKey(const KeyTypePointer aKey)
|
|
|
|
{
|
2015-06-25 19:04:21 +00:00
|
|
|
PLDHashNumber hash = 0;
|
|
|
|
hash = AddToHash(hash, aKey->mMinSize.width, aKey->mMinSize.height);
|
2014-06-10 21:51:24 +00:00
|
|
|
hash = AddToHash(hash, aKey->mBlurRadius.width, aKey->mBlurRadius.height);
|
2015-06-25 19:04:21 +00:00
|
|
|
|
2015-09-24 07:43:32 +00:00
|
|
|
hash = AddToHash(hash, HashBytes(&aKey->mShadowColor.r,
|
|
|
|
sizeof(aKey->mShadowColor.r)));
|
|
|
|
hash = AddToHash(hash, HashBytes(&aKey->mShadowColor.g,
|
|
|
|
sizeof(aKey->mShadowColor.g)));
|
|
|
|
hash = AddToHash(hash, HashBytes(&aKey->mShadowColor.b,
|
|
|
|
sizeof(aKey->mShadowColor.b)));
|
|
|
|
hash = AddToHash(hash, HashBytes(&aKey->mShadowColor.a,
|
|
|
|
sizeof(aKey->mShadowColor.a)));
|
2015-06-25 19:04:21 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2015-09-24 16:50:29 +00:00
|
|
|
hash = AddToHash(hash, aKey->mCornerRadii[i].width, aKey->mCornerRadii[i].height);
|
2015-06-25 19:04:21 +00:00
|
|
|
}
|
|
|
|
|
2014-06-10 21:51:24 +00:00
|
|
|
hash = AddToHash(hash, (uint32_t)aKey->mBackend);
|
2015-09-24 16:50:29 +00:00
|
|
|
|
|
|
|
if (aKey->mIsInset) {
|
|
|
|
hash = AddToHash(hash, aKey->mInnerMinSize.width, aKey->mInnerMinSize.height);
|
|
|
|
hash = AddToHash(hash, HashBytes(&aKey->mHasBorderRadius, sizeof(bool)));
|
|
|
|
}
|
2014-06-10 21:51:24 +00:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
bool
|
|
|
|
KeyEquals(KeyTypePointer aKey) const
|
2014-06-10 21:51:24 +00:00
|
|
|
{
|
2015-06-25 19:04:21 +00:00
|
|
|
if (aKey->mMinSize == mMinSize &&
|
2014-06-10 21:51:24 +00:00
|
|
|
aKey->mBlurRadius == mBlurRadius &&
|
2015-06-25 19:04:21 +00:00
|
|
|
aKey->mCornerRadii == mCornerRadii &&
|
|
|
|
aKey->mShadowColor == mShadowColor &&
|
2014-06-10 21:51:24 +00:00
|
|
|
aKey->mBackend == mBackend) {
|
2015-09-24 16:50:29 +00:00
|
|
|
|
|
|
|
if (mIsInset) {
|
|
|
|
return (mHasBorderRadius == aKey->mHasBorderRadius) &&
|
2016-03-29 15:24:21 +00:00
|
|
|
(mInnerMinSize == aKey->mInnerMinSize);
|
2015-09-24 16:50:29 +00:00
|
|
|
}
|
|
|
|
|
2014-06-10 21:51:24 +00:00
|
|
|
return true;
|
2015-06-25 19:04:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-06-10 21:51:24 +00:00
|
|
|
}
|
2015-09-24 16:50:29 +00:00
|
|
|
|
|
|
|
static KeyTypePointer
|
|
|
|
KeyToPointer(KeyType aKey)
|
2014-06-10 21:51:24 +00:00
|
|
|
{
|
|
|
|
return &aKey;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is what is cached. It need to be allocated in an object separated
|
|
|
|
* to the cache entry to be able to be tracked by the nsExpirationTracker.
|
|
|
|
* */
|
|
|
|
struct BlurCacheData {
|
2015-06-25 19:04:21 +00:00
|
|
|
BlurCacheData(SourceSurface* aBlur, IntMargin aExtendDestBy, const BlurCacheKey& aKey)
|
2014-06-10 21:51:24 +00:00
|
|
|
: mBlur(aBlur)
|
2015-06-25 19:04:21 +00:00
|
|
|
, mExtendDest(aExtendDestBy)
|
2014-06-10 21:51:24 +00:00
|
|
|
, mKey(aKey)
|
|
|
|
{}
|
|
|
|
|
|
|
|
BlurCacheData(const BlurCacheData& aOther)
|
|
|
|
: mBlur(aOther.mBlur)
|
2015-06-25 19:04:21 +00:00
|
|
|
, mExtendDest(aOther.mExtendDest)
|
2014-06-10 21:51:24 +00:00
|
|
|
, mKey(aOther.mKey)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
nsExpirationState *GetExpirationState() {
|
|
|
|
return &mExpirationState;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsExpirationState mExpirationState;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> mBlur;
|
2015-06-25 19:04:21 +00:00
|
|
|
IntMargin mExtendDest;
|
2014-06-10 21:51:24 +00:00
|
|
|
BlurCacheKey mKey;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class implements a cache with no maximum size, that retains the
|
|
|
|
* SourceSurfaces used to draw the blurs.
|
|
|
|
*
|
|
|
|
* An entry stays in the cache as long as it is used often.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class BlurCache final : public nsExpirationTracker<BlurCacheData,4>
|
2014-06-10 21:51:24 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
BlurCache()
|
2015-09-10 04:07:07 +00:00
|
|
|
: nsExpirationTracker<BlurCacheData, 4>(GENERATION_MS, "BlurCache")
|
2014-06-10 21:51:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void NotifyExpired(BlurCacheData* aObject)
|
|
|
|
{
|
|
|
|
RemoveObject(aObject);
|
|
|
|
mHashEntries.Remove(aObject->mKey);
|
|
|
|
}
|
|
|
|
|
2015-06-25 19:04:21 +00:00
|
|
|
BlurCacheData* Lookup(const IntSize aMinSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize& aBlurRadius,
|
2015-06-25 19:04:21 +00:00
|
|
|
RectCornerRadii* aCornerRadii,
|
2015-09-24 07:43:32 +00:00
|
|
|
const Color& aShadowColor,
|
2015-06-25 19:04:21 +00:00
|
|
|
BackendType aBackendType)
|
2014-06-10 21:51:24 +00:00
|
|
|
{
|
|
|
|
BlurCacheData* blur =
|
2015-06-25 19:04:21 +00:00
|
|
|
mHashEntries.Get(BlurCacheKey(aMinSize, aBlurRadius,
|
|
|
|
aCornerRadii, aShadowColor,
|
|
|
|
aBackendType));
|
2014-06-10 21:51:24 +00:00
|
|
|
if (blur) {
|
|
|
|
MarkUsed(blur);
|
|
|
|
}
|
|
|
|
|
|
|
|
return blur;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
BlurCacheData* LookupInsetBoxShadow(const IntSize aOuterMinSize,
|
|
|
|
const IntSize aInnerMinSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize& aBlurRadius,
|
2015-09-24 16:50:29 +00:00
|
|
|
const RectCornerRadii* aCornerRadii,
|
2015-09-24 07:43:32 +00:00
|
|
|
const Color& aShadowColor,
|
2015-09-24 16:50:29 +00:00
|
|
|
const bool& aHasBorderRadius,
|
|
|
|
BackendType aBackendType)
|
|
|
|
{
|
2016-03-29 15:24:21 +00:00
|
|
|
bool insetBoxShadow = true;
|
2015-09-24 16:50:29 +00:00
|
|
|
BlurCacheKey key(aOuterMinSize, aInnerMinSize,
|
2016-03-29 15:24:21 +00:00
|
|
|
aBlurRadius, aCornerRadii,
|
|
|
|
aShadowColor, insetBoxShadow,
|
|
|
|
aHasBorderRadius, aBackendType);
|
2015-09-24 16:50:29 +00:00
|
|
|
BlurCacheData* blur = mHashEntries.Get(key);
|
|
|
|
if (blur) {
|
|
|
|
MarkUsed(blur);
|
|
|
|
}
|
|
|
|
|
|
|
|
return blur;
|
|
|
|
}
|
|
|
|
|
2014-06-10 21:51:24 +00:00
|
|
|
// Returns true if we successfully register the blur in the cache, false
|
|
|
|
// otherwise.
|
|
|
|
bool RegisterEntry(BlurCacheData* aValue)
|
|
|
|
{
|
|
|
|
nsresult rv = AddObject(aValue);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// We are OOM, and we cannot track this object. We don't want stall
|
|
|
|
// entries in the hash table (since the expiration tracker is responsible
|
|
|
|
// for removing the cache entries), so we avoid putting that entry in the
|
|
|
|
// table, which is a good things considering we are short on memory
|
|
|
|
// anyway, we probably don't want to retain things.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mHashEntries.Put(aValue->mKey, aValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static const uint32_t GENERATION_MS = 1000;
|
|
|
|
/**
|
|
|
|
* FIXME use nsTHashtable to avoid duplicating the BlurCacheKey.
|
|
|
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=761393#c47
|
|
|
|
*/
|
|
|
|
nsClassHashtable<BlurCacheKey, BlurCacheData> mHashEntries;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BlurCache* gBlurCache = nullptr;
|
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
static IntSize
|
2015-06-25 19:04:21 +00:00
|
|
|
ComputeMinSizeForShadowShape(RectCornerRadii* aCornerRadii,
|
2015-09-23 18:49:05 +00:00
|
|
|
IntSize aBlurRadius,
|
2015-06-25 19:04:21 +00:00
|
|
|
IntMargin& aSlice,
|
|
|
|
const IntSize& aRectSize)
|
2015-05-13 19:19:27 +00:00
|
|
|
{
|
|
|
|
float cornerWidth = 0;
|
|
|
|
float cornerHeight = 0;
|
|
|
|
if (aCornerRadii) {
|
|
|
|
RectCornerRadii corners = *aCornerRadii;
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
cornerWidth = std::max(cornerWidth, corners[i].width);
|
|
|
|
cornerHeight = std::max(cornerHeight, corners[i].height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aSlice = IntMargin(ceil(cornerHeight) + aBlurRadius.height,
|
|
|
|
ceil(cornerWidth) + aBlurRadius.width,
|
|
|
|
ceil(cornerHeight) + aBlurRadius.height,
|
|
|
|
ceil(cornerWidth) + aBlurRadius.width);
|
|
|
|
|
2015-06-25 19:04:21 +00:00
|
|
|
IntSize minSize(aSlice.LeftRight() + 1,
|
|
|
|
aSlice.TopBottom() + 1);
|
|
|
|
|
|
|
|
// If aRectSize is smaller than minSize, the border-image approach won't
|
|
|
|
// work; there's no way to squeeze parts of the min box-shadow source
|
|
|
|
// image such that the result looks correct. So we need to adjust minSize
|
|
|
|
// in such a way that we can later draw it without stretching in the affected
|
|
|
|
// dimension. We also need to adjust "slice" to ensure that we're not trying
|
|
|
|
// to slice away more than we have.
|
|
|
|
if (aRectSize.width < minSize.width) {
|
|
|
|
minSize.width = aRectSize.width;
|
|
|
|
aSlice.left = 0;
|
|
|
|
aSlice.right = 0;
|
|
|
|
}
|
|
|
|
if (aRectSize.height < minSize.height) {
|
|
|
|
minSize.height = aRectSize.height;
|
|
|
|
aSlice.top = 0;
|
|
|
|
aSlice.bottom = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(aSlice.LeftRight() <= minSize.width);
|
|
|
|
MOZ_ASSERT(aSlice.TopBottom() <= minSize.height);
|
|
|
|
return minSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CacheBlur(DrawTarget& aDT,
|
|
|
|
const IntSize& aMinSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize& aBlurRadius,
|
2015-06-25 19:04:21 +00:00
|
|
|
RectCornerRadii* aCornerRadii,
|
2015-09-24 07:43:32 +00:00
|
|
|
const Color& aShadowColor,
|
2015-06-25 19:04:21 +00:00
|
|
|
IntMargin aExtendDest,
|
|
|
|
SourceSurface* aBoxShadow)
|
|
|
|
{
|
|
|
|
BlurCacheKey key(aMinSize, aBlurRadius, aCornerRadii, aShadowColor, aDT.GetBackendType());
|
|
|
|
BlurCacheData* data = new BlurCacheData(aBoxShadow, aExtendDest, key);
|
|
|
|
if (!gBlurCache->RegisterEntry(data)) {
|
|
|
|
delete data;
|
|
|
|
}
|
2015-05-13 19:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Blurs a small surface and creates the mask.
|
2015-06-17 14:00:52 +00:00
|
|
|
static already_AddRefed<SourceSurface>
|
2015-11-05 15:29:52 +00:00
|
|
|
CreateBlurMask(const IntSize& aMinSize,
|
2015-05-13 19:19:27 +00:00
|
|
|
RectCornerRadii* aCornerRadii,
|
2015-09-23 18:49:05 +00:00
|
|
|
IntSize aBlurRadius,
|
2015-05-13 19:19:27 +00:00
|
|
|
IntMargin& aExtendDestBy,
|
|
|
|
IntMargin& aSliceBorder,
|
|
|
|
DrawTarget& aDestDrawTarget)
|
|
|
|
{
|
|
|
|
gfxAlphaBoxBlur blur;
|
2015-11-05 15:29:52 +00:00
|
|
|
IntRect minRect(IntPoint(), aMinSize);
|
2015-06-25 19:04:21 +00:00
|
|
|
|
2015-09-23 18:49:05 +00:00
|
|
|
gfxContext* blurCtx = blur.Init(ThebesRect(Rect(minRect)), IntSize(),
|
2015-05-13 19:19:27 +00:00
|
|
|
aBlurRadius, nullptr, nullptr);
|
2015-06-25 19:04:21 +00:00
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
if (!blurCtx) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawTarget* blurDT = blurCtx->GetDrawTarget();
|
|
|
|
ColorPattern black(Color(0.f, 0.f, 0.f, 1.f));
|
|
|
|
|
|
|
|
if (aCornerRadii) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<Path> roundedRect =
|
2015-06-25 19:04:21 +00:00
|
|
|
MakePathForRoundedRect(*blurDT, Rect(minRect), *aCornerRadii);
|
2015-05-13 19:19:27 +00:00
|
|
|
blurDT->Fill(roundedRect, black);
|
|
|
|
} else {
|
2015-06-25 19:04:21 +00:00
|
|
|
blurDT->FillRect(Rect(minRect), black);
|
2015-05-13 19:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IntPoint topLeft;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> result = blur.DoBlur(&aDestDrawTarget, &topLeft);
|
2015-08-19 03:43:24 +00:00
|
|
|
if (!result) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-05-13 19:19:27 +00:00
|
|
|
|
2015-06-25 19:04:21 +00:00
|
|
|
IntRect expandedMinRect(topLeft, result->GetSize());
|
|
|
|
aExtendDestBy = expandedMinRect - minRect;
|
2015-11-05 15:29:52 +00:00
|
|
|
aSliceBorder += aExtendDestBy;
|
2015-05-13 19:19:27 +00:00
|
|
|
|
2015-06-25 19:04:21 +00:00
|
|
|
MOZ_ASSERT(aSliceBorder.LeftRight() <= expandedMinRect.width);
|
|
|
|
MOZ_ASSERT(aSliceBorder.TopBottom() <= expandedMinRect.height);
|
2015-05-13 19:19:27 +00:00
|
|
|
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
static already_AddRefed<SourceSurface>
|
2015-09-24 07:43:32 +00:00
|
|
|
CreateBoxShadow(SourceSurface* aBlurMask, const Color& aShadowColor)
|
2015-05-13 19:19:27 +00:00
|
|
|
{
|
|
|
|
IntSize blurredSize = aBlurMask->GetSize();
|
|
|
|
gfxPlatform* platform = gfxPlatform::GetPlatform();
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DrawTarget> boxShadowDT =
|
2015-05-13 19:19:27 +00:00
|
|
|
platform->CreateOffscreenContentDrawTarget(blurredSize, SurfaceFormat::B8G8R8A8);
|
2015-07-06 15:58:22 +00:00
|
|
|
|
|
|
|
if (!boxShadowDT) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
ColorPattern shadowColor(ToDeviceColor(aShadowColor));
|
|
|
|
boxShadowDT->MaskSurface(shadowColor, aBlurMask, Point(0, 0));
|
|
|
|
return boxShadowDT->Snapshot();
|
|
|
|
}
|
|
|
|
|
2015-11-05 15:29:52 +00:00
|
|
|
static already_AddRefed<SourceSurface>
|
2016-01-10 22:05:26 +00:00
|
|
|
GetBlur(gfxContext* aDestinationCtx,
|
2015-06-25 19:04:21 +00:00
|
|
|
const IntSize& aRectSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize& aBlurRadius,
|
2015-06-25 19:04:21 +00:00
|
|
|
RectCornerRadii* aCornerRadii,
|
2015-09-24 07:43:32 +00:00
|
|
|
const Color& aShadowColor,
|
2015-06-25 19:04:21 +00:00
|
|
|
IntMargin& aExtendDestBy,
|
2016-01-10 22:05:26 +00:00
|
|
|
IntMargin& aSlice)
|
2015-06-25 19:04:21 +00:00
|
|
|
{
|
|
|
|
if (!gBlurCache) {
|
|
|
|
gBlurCache = new BlurCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSize minSize =
|
|
|
|
ComputeMinSizeForShadowShape(aCornerRadii, aBlurRadius, aSlice, aRectSize);
|
|
|
|
|
2015-11-05 15:29:52 +00:00
|
|
|
// We can get seams using the min size rect when drawing to the destination rect
|
|
|
|
// if we have a non-pixel aligned destination transformation. In those cases,
|
|
|
|
// fallback to just rendering the destination rect.
|
|
|
|
Matrix destMatrix = ToMatrix(aDestinationCtx->CurrentMatrix());
|
|
|
|
bool useDestRect = !destMatrix.IsRectilinear() || destMatrix.HasNonIntegerTranslation();
|
|
|
|
if (useDestRect) {
|
|
|
|
minSize = aRectSize;
|
|
|
|
}
|
|
|
|
|
2016-01-10 22:05:26 +00:00
|
|
|
DrawTarget& destDT = *aDestinationCtx->GetDrawTarget();
|
|
|
|
|
2015-06-25 19:04:21 +00:00
|
|
|
BlurCacheData* cached = gBlurCache->Lookup(minSize, aBlurRadius,
|
|
|
|
aCornerRadii, aShadowColor,
|
2016-01-10 22:05:26 +00:00
|
|
|
destDT.GetBackendType());
|
2015-11-05 15:29:52 +00:00
|
|
|
if (cached && !useDestRect) {
|
2015-06-25 19:04:21 +00:00
|
|
|
// See CreateBlurMask() for these values
|
|
|
|
aExtendDestBy = cached->mExtendDest;
|
|
|
|
aSlice = aSlice + aExtendDestBy;
|
2015-11-05 15:29:52 +00:00
|
|
|
RefPtr<SourceSurface> blur = cached->mBlur;
|
|
|
|
return blur.forget();
|
2015-06-25 19:04:21 +00:00
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> blurMask =
|
2016-01-10 22:05:26 +00:00
|
|
|
CreateBlurMask(minSize, aCornerRadii, aBlurRadius, aExtendDestBy, aSlice,
|
|
|
|
destDT);
|
2015-06-25 19:04:21 +00:00
|
|
|
|
|
|
|
if (!blurMask) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> boxShadow = CreateBoxShadow(blurMask, aShadowColor);
|
2015-07-06 15:58:22 +00:00
|
|
|
if (!boxShadow) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-11-05 15:29:52 +00:00
|
|
|
if (useDestRect) {
|
|
|
|
// Since we're just going to paint the actual rect to the destination
|
|
|
|
aSlice.SizeTo(0, 0, 0, 0);
|
|
|
|
} else {
|
2016-01-10 22:05:26 +00:00
|
|
|
CacheBlur(destDT, minSize, aBlurRadius, aCornerRadii, aShadowColor,
|
|
|
|
aExtendDestBy, boxShadow);
|
2015-11-05 15:29:52 +00:00
|
|
|
}
|
|
|
|
return boxShadow.forget();
|
2015-06-25 19:04:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxAlphaBoxBlur::ShutdownBlurCache()
|
|
|
|
{
|
|
|
|
delete gBlurCache;
|
|
|
|
gBlurCache = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
static Rect
|
|
|
|
RectWithEdgesTRBL(Float aTop, Float aRight, Float aBottom, Float aLeft)
|
|
|
|
{
|
|
|
|
return Rect(aLeft, aTop, aRight - aLeft, aBottom - aTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RepeatOrStretchSurface(DrawTarget& aDT, SourceSurface* aSurface,
|
|
|
|
const Rect& aDest, const Rect& aSrc, Rect& aSkipRect)
|
|
|
|
{
|
|
|
|
if (aSkipRect.Contains(aDest)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!aDT.GetTransform().IsRectilinear() &&
|
2015-06-26 23:33:24 +00:00
|
|
|
aDT.GetBackendType() != BackendType::CAIRO) ||
|
2016-02-13 13:33:27 +00:00
|
|
|
(aDT.GetBackendType() == BackendType::DIRECT2D1_1)) {
|
2015-05-13 19:19:27 +00:00
|
|
|
// Use stretching if possible, since it leads to less seams when the
|
|
|
|
// destination is transformed. However, don't do this if we're using cairo,
|
|
|
|
// because if cairo is using pixman it won't render anything for large
|
|
|
|
// stretch factors because pixman's internal fixed point precision is not
|
|
|
|
// high enough to handle those scale factors.
|
|
|
|
// Calling FillRect on a D2D backend with a repeating pattern is much slower
|
|
|
|
// than DrawSurface, so special case the D2D backend here.
|
|
|
|
aDT.DrawSurface(aSurface, aDest, aSrc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfacePattern pattern(aSurface, ExtendMode::REPEAT,
|
|
|
|
Matrix::Translation(aDest.TopLeft() - aSrc.TopLeft()),
|
2016-05-25 16:01:18 +00:00
|
|
|
SamplingFilter::GOOD, RoundedToInt(aSrc));
|
2015-05-13 19:19:27 +00:00
|
|
|
aDT.FillRect(aDest, pattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DrawCorner(DrawTarget& aDT, SourceSurface* aSurface,
|
|
|
|
const Rect& aDest, const Rect& aSrc, Rect& aSkipRect)
|
|
|
|
{
|
|
|
|
if (aSkipRect.Contains(aDest)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aDT.DrawSurface(aSurface, aDest, aSrc);
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
static void
|
|
|
|
DrawBoxShadows(DrawTarget& aDestDrawTarget, SourceSurface* aSourceBlur,
|
|
|
|
Rect aDstOuter, Rect aDstInner, Rect aSrcOuter, Rect aSrcInner,
|
|
|
|
Rect aSkipRect)
|
|
|
|
{
|
|
|
|
// Corners: top left, top right, bottom left, bottom right
|
|
|
|
DrawCorner(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstOuter.Y(), aDstInner.X(),
|
|
|
|
aDstInner.Y(), aDstOuter.X()),
|
|
|
|
RectWithEdgesTRBL(aSrcOuter.Y(), aSrcInner.X(),
|
|
|
|
aSrcInner.Y(), aSrcOuter.X()),
|
2016-03-29 15:24:21 +00:00
|
|
|
aSkipRect);
|
2015-09-24 16:50:29 +00:00
|
|
|
|
|
|
|
DrawCorner(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstOuter.Y(), aDstOuter.XMost(),
|
|
|
|
aDstInner.Y(), aDstInner.XMost()),
|
|
|
|
RectWithEdgesTRBL(aSrcOuter.Y(), aSrcOuter.XMost(),
|
|
|
|
aSrcInner.Y(), aSrcInner.XMost()),
|
|
|
|
aSkipRect);
|
|
|
|
|
|
|
|
DrawCorner(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstInner.YMost(), aDstInner.X(),
|
|
|
|
aDstOuter.YMost(), aDstOuter.X()),
|
|
|
|
RectWithEdgesTRBL(aSrcInner.YMost(), aSrcInner.X(),
|
|
|
|
aSrcOuter.YMost(), aSrcOuter.X()),
|
|
|
|
aSkipRect);
|
|
|
|
|
|
|
|
DrawCorner(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstInner.YMost(), aDstOuter.XMost(),
|
|
|
|
aDstOuter.YMost(), aDstInner.XMost()),
|
|
|
|
RectWithEdgesTRBL(aSrcInner.YMost(), aSrcOuter.XMost(),
|
|
|
|
aSrcOuter.YMost(), aSrcInner.XMost()),
|
|
|
|
aSkipRect);
|
|
|
|
|
|
|
|
// Edges: top, left, right, bottom
|
|
|
|
RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstOuter.Y(), aDstInner.XMost(),
|
|
|
|
aDstInner.Y(), aDstInner.X()),
|
|
|
|
RectWithEdgesTRBL(aSrcOuter.Y(), aSrcInner.XMost(),
|
|
|
|
aSrcInner.Y(), aSrcInner.X()),
|
|
|
|
aSkipRect);
|
|
|
|
RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstInner.Y(), aDstInner.X(),
|
|
|
|
aDstInner.YMost(), aDstOuter.X()),
|
|
|
|
RectWithEdgesTRBL(aSrcInner.Y(), aSrcInner.X(),
|
|
|
|
aSrcInner.YMost(), aSrcOuter.X()),
|
|
|
|
aSkipRect);
|
2016-03-29 15:24:21 +00:00
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstInner.Y(), aDstOuter.XMost(),
|
|
|
|
aDstInner.YMost(), aDstInner.XMost()),
|
|
|
|
RectWithEdgesTRBL(aSrcInner.Y(), aSrcOuter.XMost(),
|
|
|
|
aSrcInner.YMost(), aSrcInner.XMost()),
|
|
|
|
aSkipRect);
|
|
|
|
RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
|
|
|
|
RectWithEdgesTRBL(aDstInner.YMost(), aDstInner.XMost(),
|
|
|
|
aDstOuter.YMost(), aDstInner.X()),
|
|
|
|
RectWithEdgesTRBL(aSrcInner.YMost(), aSrcInner.XMost(),
|
|
|
|
aSrcOuter.YMost(), aSrcInner.X()),
|
|
|
|
aSkipRect);
|
|
|
|
}
|
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
/***
|
|
|
|
* We draw a blurred a rectangle by only blurring a smaller rectangle and
|
|
|
|
* splitting the rectangle into 9 parts.
|
|
|
|
* First, a small minimum source rect is calculated and used to create a blur
|
|
|
|
* mask since the actual blurring itself is expensive. Next, we use the mask
|
|
|
|
* with the given shadow color to create a minimally-sized box shadow of the
|
|
|
|
* right color. Finally, we cut out the 9 parts from the box-shadow source and
|
|
|
|
* paint each part in the right place, stretching the non-corner parts to fill
|
|
|
|
* the space between the corners.
|
|
|
|
*/
|
|
|
|
|
2013-11-25 23:08:29 +00:00
|
|
|
/* static */ void
|
2015-06-25 19:04:21 +00:00
|
|
|
gfxAlphaBoxBlur::BlurRectangle(gfxContext* aDestinationCtx,
|
2013-11-25 23:08:29 +00:00
|
|
|
const gfxRect& aRect,
|
2014-11-01 10:45:10 +00:00
|
|
|
RectCornerRadii* aCornerRadii,
|
2013-11-25 23:09:04 +00:00
|
|
|
const gfxPoint& aBlurStdDev,
|
2015-09-24 07:43:32 +00:00
|
|
|
const Color& aShadowColor,
|
2013-11-25 23:08:29 +00:00
|
|
|
const gfxRect& aDirtyRect,
|
|
|
|
const gfxRect& aSkipRect)
|
|
|
|
{
|
2015-06-01 08:26:19 +00:00
|
|
|
IntSize blurRadius = CalculateBlurRadius(aBlurStdDev);
|
2013-11-25 23:08:29 +00:00
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
IntRect rect = RoundedToInt(ToRect(aRect));
|
|
|
|
IntMargin extendDestBy;
|
|
|
|
IntMargin slice;
|
2015-06-25 19:04:21 +00:00
|
|
|
|
2016-01-10 22:05:26 +00:00
|
|
|
RefPtr<SourceSurface> boxShadow = GetBlur(aDestinationCtx,
|
2015-06-25 19:04:21 +00:00
|
|
|
rect.Size(), blurRadius,
|
|
|
|
aCornerRadii, aShadowColor,
|
2016-01-10 22:05:26 +00:00
|
|
|
extendDestBy, slice);
|
2015-06-25 19:04:21 +00:00
|
|
|
if (!boxShadow) {
|
2015-05-13 19:19:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-05-18 15:30:41 +00:00
|
|
|
|
2016-01-10 22:05:26 +00:00
|
|
|
DrawTarget& destDrawTarget = *aDestinationCtx->GetDrawTarget();
|
2015-05-13 19:19:27 +00:00
|
|
|
destDrawTarget.PushClipRect(ToRect(aDirtyRect));
|
|
|
|
|
|
|
|
// Copy the right parts from boxShadow into destDrawTarget. The middle parts
|
|
|
|
// will be stretched, border-image style.
|
|
|
|
|
|
|
|
Rect srcOuter(Point(), Size(boxShadow->GetSize()));
|
|
|
|
Rect srcInner = srcOuter;
|
|
|
|
srcInner.Deflate(Margin(slice));
|
|
|
|
|
|
|
|
rect.Inflate(extendDestBy);
|
|
|
|
Rect dstOuter(rect);
|
|
|
|
Rect dstInner(rect);
|
|
|
|
dstInner.Deflate(Margin(slice));
|
|
|
|
|
|
|
|
Rect skipRect = ToRect(aSkipRect);
|
|
|
|
|
|
|
|
if (srcInner.IsEqualInterior(srcOuter)) {
|
|
|
|
MOZ_ASSERT(dstInner.IsEqualInterior(dstOuter));
|
|
|
|
// The target rect is smaller than the minimal size so just draw the surface
|
|
|
|
destDrawTarget.DrawSurface(boxShadow, dstInner, srcInner);
|
|
|
|
} else {
|
2015-09-24 16:50:29 +00:00
|
|
|
DrawBoxShadows(destDrawTarget, boxShadow, dstOuter, dstInner,
|
|
|
|
srcOuter, srcInner, skipRect);
|
2015-05-13 19:19:27 +00:00
|
|
|
|
|
|
|
// Middle part
|
|
|
|
RepeatOrStretchSurface(destDrawTarget, boxShadow,
|
|
|
|
RectWithEdgesTRBL(dstInner.Y(), dstInner.XMost(),
|
|
|
|
dstInner.YMost(), dstInner.X()),
|
|
|
|
RectWithEdgesTRBL(srcInner.Y(), srcInner.XMost(),
|
|
|
|
srcInner.YMost(), srcInner.X()),
|
|
|
|
skipRect);
|
2013-11-25 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-13 19:19:27 +00:00
|
|
|
// A note about anti-aliasing and seems between adjacent parts:
|
|
|
|
// We don't explicitly disable anti-aliasing in the DrawSurface calls above,
|
|
|
|
// so if there's a transform on destDrawTarget that is not pixel-aligned,
|
|
|
|
// there will be seams between adjacent parts of the box-shadow. It's hard to
|
|
|
|
// avoid those without the use of an intermediate surface.
|
|
|
|
// You might think that we could avoid those by just turning of AA, but there
|
|
|
|
// is a problem with that: Box-shadow rendering needs to clip out the
|
|
|
|
// element's border box, and we'd like that clip to have anti-aliasing -
|
|
|
|
// especially if the element has rounded corners! So we can't do that unless
|
|
|
|
// we have a way to say "Please anti-alias the clip, but don't antialias the
|
|
|
|
// destination rect of the DrawSurface call".
|
|
|
|
// On OS X there is an additional problem with turning off AA: CoreGraphics
|
|
|
|
// will not just fill the pixels that have their pixel center inside the
|
|
|
|
// filled shape. Instead, it will fill all the pixels which are partially
|
|
|
|
// covered by the shape. So for pixels on the edge between two adjacent parts,
|
|
|
|
// all those pixels will be painted to by both parts, which looks very bad.
|
|
|
|
|
|
|
|
destDrawTarget.PopClip();
|
2013-11-25 23:08:29 +00:00
|
|
|
}
|
2014-06-10 21:51:24 +00:00
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
static already_AddRefed<Path>
|
|
|
|
GetBoxShadowInsetPath(DrawTarget* aDrawTarget,
|
|
|
|
const Rect aOuterRect, const Rect aInnerRect,
|
|
|
|
const bool aHasBorderRadius, const RectCornerRadii& aInnerClipRadii)
|
|
|
|
{
|
|
|
|
/***
|
|
|
|
* We create an inset path by having two rects.
|
|
|
|
*
|
|
|
|
* -----------------------
|
|
|
|
* | ________________ |
|
|
|
|
* | | | |
|
|
|
|
* | | | |
|
|
|
|
* | ------------------ |
|
|
|
|
* |_____________________|
|
|
|
|
*
|
|
|
|
* The outer rect and the inside rect. The path
|
|
|
|
* creates a frame around the content where we draw the inset shadow.
|
|
|
|
*/
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<PathBuilder> builder =
|
2015-09-24 16:50:29 +00:00
|
|
|
aDrawTarget->CreatePathBuilder(FillRule::FILL_EVEN_ODD);
|
|
|
|
AppendRectToPath(builder, aOuterRect, true);
|
|
|
|
|
|
|
|
if (aHasBorderRadius) {
|
|
|
|
AppendRoundedRectToPath(builder, aInnerRect, aInnerClipRadii, false);
|
|
|
|
} else {
|
|
|
|
AppendRectToPath(builder, aInnerRect, false);
|
|
|
|
}
|
|
|
|
return builder->Finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
FillDestinationPath(gfxContext* aDestinationCtx,
|
|
|
|
const Rect aDestinationRect,
|
|
|
|
const Rect aShadowClipRect,
|
|
|
|
const Color& aShadowColor,
|
|
|
|
const bool aHasBorderRadius,
|
|
|
|
const RectCornerRadii& aInnerClipRadii)
|
|
|
|
{
|
|
|
|
// When there is no blur radius, fill the path onto the destination
|
|
|
|
// surface.
|
2015-09-24 07:43:32 +00:00
|
|
|
aDestinationCtx->SetColor(aShadowColor);
|
2015-09-24 16:50:29 +00:00
|
|
|
DrawTarget* destDrawTarget = aDestinationCtx->GetDrawTarget();
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<Path> shadowPath = GetBoxShadowInsetPath(destDrawTarget, aDestinationRect,
|
2015-09-24 16:50:29 +00:00
|
|
|
aShadowClipRect, aHasBorderRadius,
|
|
|
|
aInnerClipRadii);
|
|
|
|
|
|
|
|
aDestinationCtx->SetPath(shadowPath);
|
|
|
|
aDestinationCtx->Fill();
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
static void
|
2015-09-24 16:50:29 +00:00
|
|
|
CacheInsetBlur(const IntSize aMinOuterSize,
|
|
|
|
const IntSize aMinInnerSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize& aBlurRadius,
|
2015-09-24 16:50:29 +00:00
|
|
|
const RectCornerRadii* aCornerRadii,
|
2015-09-24 07:43:32 +00:00
|
|
|
const Color& aShadowColor,
|
2015-09-24 16:50:29 +00:00
|
|
|
const bool& aHasBorderRadius,
|
|
|
|
BackendType aBackendType,
|
|
|
|
SourceSurface* aBoxShadow)
|
|
|
|
{
|
2016-03-29 15:24:21 +00:00
|
|
|
bool isInsetBlur = true;
|
2015-09-24 16:50:29 +00:00
|
|
|
BlurCacheKey key(aMinOuterSize, aMinInnerSize,
|
2016-03-29 15:24:21 +00:00
|
|
|
aBlurRadius, aCornerRadii,
|
|
|
|
aShadowColor, isInsetBlur,
|
|
|
|
aHasBorderRadius, aBackendType);
|
|
|
|
IntMargin extendDestBy(0, 0, 0, 0);
|
|
|
|
BlurCacheData* data = new BlurCacheData(aBoxShadow, extendDestBy, key);
|
2015-09-24 16:50:29 +00:00
|
|
|
if (!gBlurCache->RegisterEntry(data)) {
|
|
|
|
delete data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<mozilla::gfx::SourceSurface>
|
2016-03-29 15:24:21 +00:00
|
|
|
gfxAlphaBoxBlur::GetInsetBlur(const mozilla::gfx::Rect aOuterRect,
|
|
|
|
const mozilla::gfx::Rect aWhitespaceRect,
|
|
|
|
const bool aIsDestRect,
|
|
|
|
const mozilla::gfx::Color& aShadowColor,
|
|
|
|
const mozilla::gfx::IntSize& aBlurRadius,
|
|
|
|
const bool aHasBorderRadius,
|
2015-09-24 16:50:29 +00:00
|
|
|
const RectCornerRadii& aInnerClipRadii,
|
2016-01-10 22:05:26 +00:00
|
|
|
DrawTarget* aDestDrawTarget)
|
2015-09-24 16:50:29 +00:00
|
|
|
{
|
|
|
|
if (!gBlurCache) {
|
|
|
|
gBlurCache = new BlurCache();
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
IntSize outerSize((int)aOuterRect.width, (int)aOuterRect.height);
|
|
|
|
IntSize whitespaceSize((int)aWhitespaceRect.width, (int)aWhitespaceRect.height);
|
2015-09-24 16:50:29 +00:00
|
|
|
BlurCacheData* cached =
|
2016-03-29 15:24:21 +00:00
|
|
|
gBlurCache->LookupInsetBoxShadow(outerSize, whitespaceSize,
|
|
|
|
aBlurRadius, &aInnerClipRadii,
|
|
|
|
aShadowColor, aHasBorderRadius,
|
2016-01-10 22:05:26 +00:00
|
|
|
aDestDrawTarget->GetBackendType());
|
2015-10-16 15:27:51 +00:00
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
if (cached && !aIsDestRect) {
|
2015-09-24 16:50:29 +00:00
|
|
|
// So we don't forget the actual cached blur
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> cachedBlur = cached->mBlur;
|
2015-09-24 16:50:29 +00:00
|
|
|
return cachedBlur.forget();
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
// If we can do a min rect, the whitespace rect will be expanded in Init to
|
|
|
|
// aOuterRect.
|
|
|
|
Rect blurRect = aIsDestRect ? aOuterRect : aWhitespaceRect;
|
2015-09-23 18:49:05 +00:00
|
|
|
IntSize zeroSpread(0, 0);
|
2016-03-29 15:24:21 +00:00
|
|
|
gfxContext* minGfxContext = Init(ThebesRect(blurRect),
|
|
|
|
zeroSpread, aBlurRadius,
|
|
|
|
nullptr, nullptr);
|
2015-09-24 16:50:29 +00:00
|
|
|
if (!minGfxContext) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
// This is really annoying. When we create the AlphaBoxBlur, the gfxContext
|
|
|
|
// has a translation applied to it that is the topLeft point. This is actually
|
|
|
|
// the rect we gave it plus the blur radius. The rects we give this for the outer
|
|
|
|
// and whitespace rects are based at (0, 0). We could either translate those rects
|
|
|
|
// when we don't have a destination rect or ignore the translation when using
|
|
|
|
// the dest rect. The dest rects layout gives us expect this translation.
|
|
|
|
if (!aIsDestRect) {
|
|
|
|
minGfxContext->SetMatrix(gfxMatrix());
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
DrawTarget* minDrawTarget = minGfxContext->GetDrawTarget();
|
2016-03-29 15:24:21 +00:00
|
|
|
|
|
|
|
// Fill in the path between the inside white space / outer rects
|
|
|
|
// NOT the inner frame
|
2015-11-11 22:23:14 +00:00
|
|
|
RefPtr<Path> maskPath =
|
2016-03-29 15:24:21 +00:00
|
|
|
GetBoxShadowInsetPath(minDrawTarget, aOuterRect,
|
|
|
|
aWhitespaceRect, aHasBorderRadius,
|
2015-11-11 22:23:14 +00:00
|
|
|
aInnerClipRadii);
|
2015-09-24 16:50:29 +00:00
|
|
|
|
2015-11-02 21:30:03 +00:00
|
|
|
Color black(0.f, 0.f, 0.f, 1.f);
|
|
|
|
minGfxContext->SetColor(black);
|
2015-09-24 16:50:29 +00:00
|
|
|
minGfxContext->SetPath(maskPath);
|
|
|
|
minGfxContext->Fill();
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
// Create the A8 mask
|
2015-10-16 15:27:51 +00:00
|
|
|
IntPoint topLeft;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> minMask = DoBlur(minDrawTarget, &topLeft);
|
2015-09-24 16:50:29 +00:00
|
|
|
if (!minMask) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
// Fill in with the color we actually wanted
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> minInsetBlur = CreateBoxShadow(minMask, aShadowColor);
|
2015-09-24 16:50:29 +00:00
|
|
|
if (!minInsetBlur) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
if (!aIsDestRect) {
|
|
|
|
CacheInsetBlur(outerSize, whitespaceSize,
|
|
|
|
aBlurRadius, &aInnerClipRadii,
|
|
|
|
aShadowColor, aHasBorderRadius,
|
|
|
|
aDestDrawTarget->GetBackendType(),
|
|
|
|
minInsetBlur);
|
2015-12-04 19:05:47 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
return minInsetBlur.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
2016-03-29 15:24:21 +00:00
|
|
|
* We create our minimal rect with 2 rects.
|
|
|
|
* The first is the inside whitespace rect, that is "cut out"
|
|
|
|
* from the box. This is (1). This must be the size
|
|
|
|
* of the blur radius + corner radius so we can have a big enough
|
|
|
|
* inside cut.
|
|
|
|
*
|
|
|
|
* The second (2) is one blur radius surrounding the inner
|
|
|
|
* frame of (1). This is the amount of blur space required
|
|
|
|
* to get a proper blend.
|
2015-09-24 16:50:29 +00:00
|
|
|
*
|
2016-03-29 15:24:21 +00:00
|
|
|
* B = one blur size
|
|
|
|
* W = one blur + corner radii - known as inner margin
|
|
|
|
* ___________________________________
|
|
|
|
* | |
|
|
|
|
* | | | |
|
|
|
|
* | (2) | (1) | (2) |
|
|
|
|
* | B | W | B |
|
|
|
|
* | | | |
|
|
|
|
* | | | |
|
|
|
|
* | | |
|
|
|
|
* |________________________________|
|
2015-09-24 16:50:29 +00:00
|
|
|
*/
|
2016-03-29 15:24:21 +00:00
|
|
|
static void GetBlurMargins(const bool aHasBorderRadius,
|
|
|
|
const RectCornerRadii& aInnerClipRadii,
|
|
|
|
const IntSize aBlurRadius,
|
|
|
|
Margin& aOutBlurMargin,
|
|
|
|
Margin& aOutInnerMargin)
|
|
|
|
{
|
|
|
|
float cornerWidth = 0;
|
|
|
|
float cornerHeight = 0;
|
|
|
|
if (aHasBorderRadius) {
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
cornerWidth = std::max(cornerWidth, aInnerClipRadii[i].width);
|
|
|
|
cornerHeight = std::max(cornerHeight, aInnerClipRadii[i].height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only the inside whitespace size cares about the border radius size.
|
|
|
|
// Outer sizes only care about blur.
|
|
|
|
int width = cornerWidth + aBlurRadius.width;
|
|
|
|
int height = cornerHeight + aBlurRadius.height;
|
|
|
|
|
|
|
|
aOutInnerMargin.SizeTo(height, width, height, width);
|
|
|
|
aOutBlurMargin.SizeTo(aBlurRadius.height, aBlurRadius.width,
|
|
|
|
aBlurRadius.height, aBlurRadius.width);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
GetInsetBoxShadowRects(const Margin aBlurMargin,
|
|
|
|
const Margin aInnerMargin,
|
|
|
|
const Rect aShadowClipRect,
|
|
|
|
const Rect aDestinationRect,
|
|
|
|
Rect& aOutWhitespaceRect,
|
|
|
|
Rect& aOutOuterRect)
|
|
|
|
{
|
|
|
|
// We always copy (2 * blur radius) + corner radius worth of data to the destination rect
|
|
|
|
// This covers the blend of the path + the actual blur
|
|
|
|
// Need +1 so that we copy the edges correctly as we'll copy
|
|
|
|
// over the min box shadow corners then the +1 for the edges between
|
|
|
|
// Note, the (x,y) coordinates are from the blur margin
|
|
|
|
// since the frame outside the whitespace rect is 1 blur radius extra space.
|
|
|
|
Rect insideWhiteSpace(aBlurMargin.left,
|
|
|
|
aBlurMargin.top,
|
|
|
|
aInnerMargin.LeftRight() + 1,
|
|
|
|
aInnerMargin.TopBottom() + 1);
|
|
|
|
|
|
|
|
// If the inner white space rect is larger than the shadow clip rect
|
|
|
|
// our approach does not work as we'll just copy one corner
|
|
|
|
// and cover the destination. In those cases, fallback to the destination rect
|
|
|
|
bool useDestRect = (aShadowClipRect.width <= aInnerMargin.LeftRight()) ||
|
|
|
|
(aShadowClipRect.height <= aInnerMargin.TopBottom());
|
|
|
|
|
|
|
|
if (useDestRect) {
|
|
|
|
aOutWhitespaceRect = aShadowClipRect;
|
|
|
|
aOutOuterRect = aDestinationRect;
|
|
|
|
} else {
|
|
|
|
aOutWhitespaceRect = insideWhiteSpace;
|
|
|
|
aOutOuterRect = aOutWhitespaceRect;
|
|
|
|
aOutOuterRect.Inflate(aBlurMargin);
|
|
|
|
}
|
|
|
|
|
|
|
|
return useDestRect;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:50:29 +00:00
|
|
|
void
|
|
|
|
gfxAlphaBoxBlur::BlurInsetBox(gfxContext* aDestinationCtx,
|
|
|
|
const Rect aDestinationRect,
|
|
|
|
const Rect aShadowClipRect,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize aBlurRadius,
|
|
|
|
const IntSize aSpreadRadius,
|
2015-09-24 16:50:29 +00:00
|
|
|
const Color& aShadowColor,
|
|
|
|
bool aHasBorderRadius,
|
|
|
|
const RectCornerRadii& aInnerClipRadii,
|
2015-10-19 17:53:04 +00:00
|
|
|
const Rect aSkipRect,
|
|
|
|
const Point aShadowOffset)
|
2015-09-24 16:50:29 +00:00
|
|
|
{
|
2016-03-29 15:24:21 +00:00
|
|
|
if ((aBlurRadius.width == 0 && aBlurRadius.height == 0)
|
|
|
|
|| aShadowClipRect.IsEmpty()) {
|
2015-09-24 16:50:29 +00:00
|
|
|
FillDestinationPath(aDestinationCtx, aDestinationRect, aShadowClipRect,
|
|
|
|
aShadowColor, aHasBorderRadius, aInnerClipRadii);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
DrawTarget* destDrawTarget = aDestinationCtx->GetDrawTarget();
|
2015-09-24 16:50:29 +00:00
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
Margin innerMargin;
|
|
|
|
Margin blurMargin;
|
|
|
|
GetBlurMargins(aHasBorderRadius, aInnerClipRadii, aBlurRadius,
|
|
|
|
blurMargin, innerMargin);
|
2015-09-24 16:50:29 +00:00
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
Rect whitespaceRect;
|
|
|
|
Rect outerRect;
|
|
|
|
bool useDestRect = GetInsetBoxShadowRects(blurMargin, innerMargin, aShadowClipRect,
|
|
|
|
aDestinationRect, whitespaceRect, outerRect);
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> minBlur = GetInsetBlur(outerRect, whitespaceRect, useDestRect, aShadowColor,
|
|
|
|
aBlurRadius, aHasBorderRadius, aInnerClipRadii,
|
|
|
|
destDrawTarget);
|
|
|
|
if (!minBlur) {
|
|
|
|
return;
|
2015-12-04 19:05:47 +00:00
|
|
|
}
|
2015-09-24 16:50:29 +00:00
|
|
|
|
2016-03-29 15:24:21 +00:00
|
|
|
if (useDestRect) {
|
|
|
|
IntSize blurSize = minBlur->GetSize();
|
|
|
|
Rect srcBlur(0, 0, blurSize.width, blurSize.height);
|
|
|
|
Rect destBlur = aDestinationRect;
|
|
|
|
|
|
|
|
// The blur itself expands the rect by the blur margin, so we
|
|
|
|
// have to mimic that here.
|
|
|
|
destBlur.Inflate(blurMargin);
|
|
|
|
MOZ_ASSERT(srcBlur.Size() == destBlur.Size());
|
|
|
|
destDrawTarget->DrawSurface(minBlur, destBlur, srcBlur);
|
2015-09-24 16:50:29 +00:00
|
|
|
} else {
|
2016-03-29 15:24:21 +00:00
|
|
|
Rect srcOuter(outerRect);
|
|
|
|
Rect srcInner(srcOuter);
|
|
|
|
srcInner.Deflate(blurMargin); // The outer color fill
|
|
|
|
srcInner.Deflate(innerMargin); // The inner whitespace
|
|
|
|
|
|
|
|
// The shadow clip rect already takes into account the spread radius
|
|
|
|
Rect outerFillRect(aShadowClipRect);
|
|
|
|
outerFillRect.Inflate(blurMargin);
|
|
|
|
FillDestinationPath(aDestinationCtx, aDestinationRect, outerFillRect, aShadowColor, false, RectCornerRadii());
|
|
|
|
|
|
|
|
// Inflate once for the frame around the whitespace
|
|
|
|
Rect destRect(aShadowClipRect);
|
|
|
|
destRect.Inflate(blurMargin);
|
|
|
|
|
|
|
|
// Deflate for the blurred in white space
|
|
|
|
Rect destInnerRect(aShadowClipRect);
|
|
|
|
destInnerRect.Deflate(innerMargin);
|
|
|
|
|
|
|
|
DrawBoxShadows(*destDrawTarget, minBlur,
|
|
|
|
destRect, destInnerRect,
|
2015-10-16 15:27:51 +00:00
|
|
|
srcOuter, srcInner,
|
2015-09-24 16:50:29 +00:00
|
|
|
aSkipRect);
|
2015-10-16 15:27:51 +00:00
|
|
|
}
|
2015-09-24 16:50:29 +00:00
|
|
|
}
|