Bug 1346618 - Part 1. Remove SVGImageContext::mGlobalOpacity.
MozReview-Commit-ID: ByiPa4sreEh
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5097,22 +5097,22 @@ CanvasRenderingContext2D::DrawDirectlyTo
Scale(1.0 / contextScale.width,
1.0 / contextScale.height).
Translate(aDest.x - aSrc.x, aDest.y - aSrc.y));
// FLAG_CLAMP is added for increased performance, since we never tile here.
uint32_t modifiedFlags = aImage.mDrawingFlags | imgIContainer::FLAG_CLAMP;
CSSIntSize sz(scaledImageSize.width, scaledImageSize.height); // XXX hmm is scaledImageSize really in CSS pixels?
- SVGImageContext svgContext(Some(sz), Nothing(), CurrentState().globalAlpha);
+ SVGImageContext svgContext(Some(sz));
auto result = aImage.mImgContainer->
Draw(context, scaledImageSize,
ImageRegion::Create(gfxRect(aSrc.x, aSrc.y, aSrc.width, aSrc.height)),
- aImage.mWhichFrame, SamplingFilter::GOOD, Some(svgContext), modifiedFlags, 1.0);
+ aImage.mWhichFrame, SamplingFilter::GOOD, Some(svgContext), modifiedFlags, CurrentState().globalAlpha);
if (result != DrawResult::SUCCESS) {
NS_WARNING("imgIContainer::Draw failed");
}
}
void
CanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& aOp,
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -788,17 +788,17 @@ struct SVGDrawingParameters
: context(aContext)
, size(aSize.width, aSize.height)
, region(aRegion)
, samplingFilter(aSamplingFilter)
, svgContext(aSVGContext)
, viewportSize(aSize)
, animationTime(aAnimationTime)
, flags(aFlags)
- , opacity(aSVGContext ? aSVGContext->GetGlobalOpacity() : aOpacity)
+ , opacity(aOpacity)
{
if (aSVGContext) {
auto sz = aSVGContext->GetViewportSize();
if (sz) {
viewportSize = nsIntSize(sz->width, sz->height); // XXX losing unit
}
}
}
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -6797,17 +6797,18 @@ nsLayoutUtils::DrawBackgroundImage(gfxCo
const nsRect& aDirty,
uint32_t aImageFlags,
ExtendMode aExtendMode,
float aOpacity)
{
PROFILER_LABEL("layout", "nsLayoutUtils::DrawBackgroundImage",
js::ProfileEntry::Category::GRAPHICS);
- const Maybe<SVGImageContext> svgContext(Some(SVGImageContext(Some(aImageSize))));
+ const Maybe<SVGImageContext>
+ svgContext(Some(SVGImageContext(Some(aImageSize))));
/* Fast path when there is no need for image spacing */
if (aRepeatSize.width == aDest.width && aRepeatSize.height == aDest.height) {
return DrawImageInternal(aContext, aPresContext, aImage,
aSamplingFilter, aDest, aFill, aAnchor,
aDirty, svgContext, aImageFlags, aExtendMode,
aOpacity);
}
--- a/layout/svg/SVGImageContext.h
+++ b/layout/svg/SVGImageContext.h
@@ -19,18 +19,17 @@ namespace mozilla {
// Used to pass information such as
// - viewport information from CSS, and
// - overridden attributes from an SVG <image> element
// to the image's internal SVG document when it's drawn.
class SVGImageContext
{
public:
SVGImageContext()
- : mGlobalOpacity(1.0)
- , mIsPaintingSVGImageElement(false)
+ : mIsPaintingSVGImageElement(false)
{ }
/**
* Currently it seems that the aViewportSize parameter ends up being used
* for different things by different pieces of code, and probably in some
* cases being used incorrectly (specifically in the case of pixel snapping
* under the nsLayoutUtils::Draw*Image() methods). An unfortunate result of
* the messy code is that aViewportSize is currently a Maybe<T> since it
@@ -44,21 +43,19 @@ public:
* point we need to clean this code up, make our abstractions clear, create
* that utility and stop using Maybe for this parameter.
*
* Note: 'aIsPaintingSVGImageElement' should be used to indicate whether
* the SVG image in question is being painted for an SVG <image> element.
*/
explicit SVGImageContext(const Maybe<CSSIntSize>& aViewportSize,
const Maybe<SVGPreserveAspectRatio>& aPreserveAspectRatio = Nothing(),
- gfxFloat aOpacity = 1.0,
bool aIsPaintingSVGImageElement = false)
: mViewportSize(aViewportSize)
, mPreserveAspectRatio(aPreserveAspectRatio)
- , mGlobalOpacity(aOpacity)
, mIsPaintingSVGImageElement(aIsPaintingSVGImageElement)
{ }
static void MaybeInitAndStoreContextPaint(Maybe<SVGImageContext>& aContext,
nsIFrame* aFromFrame,
imgIContainer* aImgContainer);
const Maybe<CSSIntSize>& GetViewportSize() const {
@@ -72,20 +69,16 @@ public:
const Maybe<SVGPreserveAspectRatio>& GetPreserveAspectRatio() const {
return mPreserveAspectRatio;
}
void SetPreserveAspectRatio(const Maybe<SVGPreserveAspectRatio>& aPAR) {
mPreserveAspectRatio = aPAR;
}
- gfxFloat GetGlobalOpacity() const {
- return mGlobalOpacity;
- }
-
const SVGEmbeddingContextPaint* GetContextPaint() const {
return mContextPaint.get();
}
bool IsPaintingForSVGImageElement() const {
return mIsPaintingSVGImageElement;
}
@@ -95,47 +88,44 @@ public:
(mContextPaint == aOther.mContextPaint) ||
// or both have context paint that are different but equivalent objects:
(mContextPaint && aOther.mContextPaint &&
*mContextPaint == *aOther.mContextPaint);
return contextPaintIsEqual &&
mViewportSize == aOther.mViewportSize &&
mPreserveAspectRatio == aOther.mPreserveAspectRatio &&
- mGlobalOpacity == aOther.mGlobalOpacity &&
mIsPaintingSVGImageElement == aOther.mIsPaintingSVGImageElement;
}
bool operator!=(const SVGImageContext& aOther) const {
return !(*this == aOther);
}
uint32_t Hash() const {
uint32_t hash = 0;
if (mContextPaint) {
hash = HashGeneric(hash, mContextPaint->Hash());
}
return HashGeneric(hash,
mViewportSize.map(HashSize).valueOr(0),
mPreserveAspectRatio.map(HashPAR).valueOr(0),
- HashBytes(&mGlobalOpacity, sizeof(mGlobalOpacity)),
mIsPaintingSVGImageElement);
}
private:
static uint32_t HashSize(const CSSIntSize& aSize) {
return HashGeneric(aSize.width, aSize.height);
}
static uint32_t HashPAR(const SVGPreserveAspectRatio& aPAR) {
return aPAR.Hash();
}
// NOTE: When adding new member-vars, remember to update Hash() & operator==.
RefPtr<SVGEmbeddingContextPaint> mContextPaint;
Maybe<CSSIntSize> mViewportSize;
Maybe<SVGPreserveAspectRatio> mPreserveAspectRatio;
- gfxFloat mGlobalOpacity;
bool mIsPaintingSVGImageElement;
};
} // namespace mozilla
#endif // MOZILLA_SVGCONTEXT_H_
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -402,17 +402,17 @@ nsSVGImageFrame::PaintSVG(gfxContext& aC
// attributes of mImageContainer's internal SVG document. The 'width' &
// 'height' values we're passing in here are in CSS units (though they
// come from width/height *attributes* in SVG). They influence the region
// of the SVG image's internal document that is visible, in combination
// with preserveAspectRatio and viewBox.
const Maybe<SVGImageContext> context(
Some(SVGImageContext(Some(CSSIntSize::Truncate(width, height)),
Some(imgElem->mPreserveAspectRatio.GetAnimValue()),
- 1.0, /* aIsPaintingSVGImageElement */ true)));
+ /* aIsPaintingSVGImageElement */ true)));
// For the actual draw operation to draw crisply (and at the right size),
// our destination rect needs to be |width|x|height|, *in dev pixels*.
LayoutDeviceSize devPxSize(width, height);
nsRect destRect(nsPoint(),
LayoutDevicePixel::ToAppUnits(devPxSize,
appUnitsPerDevPx));