mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 19:07:31 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
f08dd1422d
29 changed files with 1084 additions and 672 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -10,14 +10,13 @@
|
|||
#include "nsSize.h"
|
||||
#include "gfxPoint.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/gfx/Blur.h"
|
||||
|
||||
class gfxContext;
|
||||
struct gfxRect;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class AlphaBoxBlur;
|
||||
struct Color;
|
||||
struct RectCornerRadii;
|
||||
class SourceSurface;
|
||||
|
|
@ -57,6 +56,9 @@ public:
|
|||
|
||||
/**
|
||||
* Constructs a box blur and initializes the temporary surface.
|
||||
*
|
||||
* @param aDestinationCtx The destination to blur to.
|
||||
*
|
||||
* @param aRect The coordinates of the surface to create in device units.
|
||||
*
|
||||
* @param aBlurRadius The blur radius in pixels. This is the radius of
|
||||
|
|
@ -73,24 +75,28 @@ public:
|
|||
* represents an area where blurring is unnecessary and shouldn't be done
|
||||
* for speed reasons. It is safe to pass nullptr here.
|
||||
*/
|
||||
gfxContext* Init(const gfxRect& aRect,
|
||||
const mozilla::gfx::IntSize& aSpreadRadius,
|
||||
const mozilla::gfx::IntSize& aBlurRadius,
|
||||
const gfxRect* aDirtyRect,
|
||||
const gfxRect* aSkipRect);
|
||||
already_AddRefed<gfxContext>
|
||||
Init(gfxContext* aDestinationCtx,
|
||||
const gfxRect& aRect,
|
||||
const mozilla::gfx::IntSize& aSpreadRadius,
|
||||
const mozilla::gfx::IntSize& aBlurRadius,
|
||||
const gfxRect* aDirtyRect,
|
||||
const gfxRect* aSkipRect);
|
||||
|
||||
already_AddRefed<DrawTarget>
|
||||
InitDrawTarget(const mozilla::gfx::DrawTarget* aReferenceDT,
|
||||
const mozilla::gfx::Rect& aRect,
|
||||
const mozilla::gfx::IntSize& aSpreadRadius,
|
||||
const mozilla::gfx::IntSize& aBlurRadius,
|
||||
const mozilla::gfx::Rect* aDirtyRect = nullptr,
|
||||
const mozilla::gfx::Rect* aSkipRect = nullptr);
|
||||
|
||||
/**
|
||||
* Returns the context that should be drawn to supply the alpha mask to be
|
||||
* blurred. If the returned surface is null, then there was an error in
|
||||
* its creation.
|
||||
* Performs the blur and optionally colors the result if aShadowColor is not null.
|
||||
*/
|
||||
gfxContext* GetContext()
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::gfx::SourceSurface>
|
||||
DoBlur(DrawTarget* aDT, mozilla::gfx::IntPoint* aTopLeft);
|
||||
DoBlur(const mozilla::gfx::Color* aShadowColor = nullptr,
|
||||
mozilla::gfx::IntPoint* aOutTopLeft = nullptr);
|
||||
|
||||
/**
|
||||
* Does the actual blurring/spreading and mask applying. Users of this
|
||||
|
|
@ -129,7 +135,7 @@ public:
|
|||
*/
|
||||
static void BlurRectangle(gfxContext *aDestinationCtx,
|
||||
const gfxRect& aRect,
|
||||
RectCornerRadii* aCornerRadii,
|
||||
const RectCornerRadii* aCornerRadii,
|
||||
const gfxPoint& aBlurStdDev,
|
||||
const Color& aShadowColor,
|
||||
const gfxRect& aDirtyRect,
|
||||
|
|
@ -154,41 +160,45 @@ public:
|
|||
* @param aSKipRect An area in device pixels we don't have to paint in.
|
||||
*/
|
||||
void BlurInsetBox(gfxContext* aDestinationCtx,
|
||||
const mozilla::gfx::Rect aDestinationRect,
|
||||
const mozilla::gfx::Rect aShadowClipRect,
|
||||
const mozilla::gfx::IntSize aBlurRadius,
|
||||
const mozilla::gfx::IntSize aSpreadRadius,
|
||||
const mozilla::gfx::Rect& aDestinationRect,
|
||||
const mozilla::gfx::Rect& aShadowClipRect,
|
||||
const mozilla::gfx::IntSize& aBlurRadius,
|
||||
const mozilla::gfx::Color& aShadowColor,
|
||||
const bool aHasBorderRadius,
|
||||
const RectCornerRadii& aInnerClipRadii,
|
||||
const mozilla::gfx::Rect aSkipRect,
|
||||
const mozilla::gfx::Point aShadowOffset);
|
||||
const RectCornerRadii* aInnerClipRadii,
|
||||
const mozilla::gfx::Rect& aSkipRect,
|
||||
const mozilla::gfx::Point& aShadowOffset);
|
||||
|
||||
protected:
|
||||
already_AddRefed<mozilla::gfx::SourceSurface>
|
||||
GetInsetBlur(const mozilla::gfx::Rect aOuterRect,
|
||||
const mozilla::gfx::Rect aWhitespaceRect,
|
||||
const bool aIsDestRect,
|
||||
GetInsetBlur(const mozilla::gfx::Rect& aOuterRect,
|
||||
const mozilla::gfx::Rect& aWhitespaceRect,
|
||||
bool aIsDestRect,
|
||||
const mozilla::gfx::Color& aShadowColor,
|
||||
const mozilla::gfx::IntSize& aBlurRadius,
|
||||
const bool aHasBorderRadius,
|
||||
const RectCornerRadii& aInnerClipRadii,
|
||||
DrawTarget* aDestDrawTarget);
|
||||
const RectCornerRadii* aInnerClipRadii,
|
||||
DrawTarget* aDestDrawTarget,
|
||||
bool aMirrorCorners);
|
||||
|
||||
|
||||
/**
|
||||
* The context of the temporary alpha surface.
|
||||
* The DrawTarget of the temporary alpha surface.
|
||||
*/
|
||||
RefPtr<gfxContext> mContext;
|
||||
RefPtr<DrawTarget> mDrawTarget;
|
||||
|
||||
/**
|
||||
* The temporary alpha surface.
|
||||
*/
|
||||
mozilla::UniquePtr<unsigned char[]> mData;
|
||||
uint8_t* mData;
|
||||
|
||||
/**
|
||||
* The object that actually does the blurring for us.
|
||||
*/
|
||||
mozilla::UniquePtr<mozilla::gfx::AlphaBoxBlur> mBlur;
|
||||
mozilla::gfx::AlphaBoxBlur mBlur;
|
||||
|
||||
/**
|
||||
* Indicates using DrawTarget-accelerated blurs.
|
||||
*/
|
||||
bool mAccelerated;
|
||||
};
|
||||
|
||||
#endif /* GFX_BLUR_H */
|
||||
|
|
|
|||
|
|
@ -1309,7 +1309,12 @@ gfxPlatform::CreateSimilarSoftwareDrawTarget(DrawTarget* aDT,
|
|||
if (Factory::DoesBackendSupportDataDrawtarget(aDT->GetBackendType())) {
|
||||
dt = aDT->CreateSimilarDrawTarget(aSize, aFormat);
|
||||
} else {
|
||||
dt = Factory::CreateDrawTarget(BackendType::SKIA, aSize, aFormat);
|
||||
#ifdef USE_SKIA
|
||||
BackendType backendType = BackendType::SKIA;
|
||||
#else
|
||||
BackendType backendType = BackendType::CAIRO;
|
||||
#endif
|
||||
dt = Factory::CreateDrawTarget(backendType, aSize, aFormat);
|
||||
}
|
||||
|
||||
return dt.forget();
|
||||
|
|
@ -1322,7 +1327,11 @@ gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize,
|
|||
NS_ASSERTION(backendType != BackendType::NONE, "No backend.");
|
||||
|
||||
if (!Factory::DoesBackendSupportDataDrawtarget(backendType)) {
|
||||
#ifdef USE_SKIA
|
||||
backendType = BackendType::SKIA;
|
||||
#else
|
||||
backendType = BackendType::CAIRO;
|
||||
#endif
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(backendType,
|
||||
|
|
|
|||
|
|
@ -692,7 +692,7 @@ gfxUtils::ClipToRegion(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
|||
}
|
||||
|
||||
/*static*/ gfxFloat
|
||||
gfxUtils::ClampToScaleFactor(gfxFloat aVal)
|
||||
gfxUtils::ClampToScaleFactor(gfxFloat aVal, bool aRoundDown)
|
||||
{
|
||||
// Arbitary scale factor limitation. We can increase this
|
||||
// for better scaling performance at the cost of worse
|
||||
|
|
@ -713,14 +713,17 @@ gfxUtils::ClampToScaleFactor(gfxFloat aVal)
|
|||
|
||||
gfxFloat power = log(aVal)/log(kScaleResolution);
|
||||
|
||||
// If power is within 1e-5 of an integer, round to nearest to
|
||||
// prevent floating point errors, otherwise round up to the
|
||||
// next integer value.
|
||||
if (fabs(power - NS_round(power)) < 1e-5) {
|
||||
// If power is within 1e-5 of an integer, round to nearest to
|
||||
// prevent floating point errors.
|
||||
power = NS_round(power);
|
||||
} else if (inverse) {
|
||||
} else if (inverse != aRoundDown) {
|
||||
// Use floor when we are either inverted or rounding down, but
|
||||
// not both.
|
||||
power = floor(power);
|
||||
} else {
|
||||
// Otherwise, ceil when we are not inverted and not rounding
|
||||
// down, or we are inverted and rounding down.
|
||||
power = ceil(power);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,9 +128,10 @@ public:
|
|||
|
||||
/**
|
||||
* Return the smallest power of kScaleResolution (2) greater than or equal to
|
||||
* aVal.
|
||||
* aVal. If aRoundDown is specified, the power of 2 will be less than
|
||||
* or equal to aVal.
|
||||
*/
|
||||
static gfxFloat ClampToScaleFactor(gfxFloat aVal);
|
||||
static gfxFloat ClampToScaleFactor(gfxFloat aVal, bool aRoundDown = false);
|
||||
|
||||
/**
|
||||
* Clears surface to aColor (which defaults to transparent black).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue