mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 10:54:33 +00:00
Backed out changesets 950a3afc2b15 and dfb5303af6f9 (bug 1028288) for being incorrect
This commit is contained in:
parent
82972d112d
commit
914924e971
@ -9,8 +9,6 @@
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "SVGPreserveAspectRatio.h"
|
||||
#include "SVGImageContext.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
@ -3434,7 +3432,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
|
||||
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
|
||||
} else {
|
||||
DrawDirectlyToCanvas(drawInfo, &bounds, dx, dy, dw, dh,
|
||||
sx, sy, sw, sh, imgSize, CurrentState().globalAlpha);
|
||||
sx, sy, sw, sh, imgSize);
|
||||
}
|
||||
|
||||
RedrawUser(gfxRect(dx, dy, dw, dh));
|
||||
@ -3445,8 +3443,7 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
||||
const nsLayoutUtils::DirectDrawInfo& image,
|
||||
mgfx::Rect* bounds, double dx, double dy,
|
||||
double dw, double dh, double sx, double sy,
|
||||
double sw, double sh, gfxIntSize imgSize,
|
||||
gfxFloat opacity)
|
||||
double sw, double sh, gfxIntSize imgSize)
|
||||
{
|
||||
gfxMatrix contextMatrix;
|
||||
|
||||
@ -3472,14 +3469,12 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
||||
// FLAG_CLAMP is added for increased performance
|
||||
uint32_t modifiedFlags = image.mDrawingFlags | imgIContainer::FLAG_CLAMP;
|
||||
|
||||
SVGImageContext svgContext(SVGPreserveAspectRatio(), opacity);
|
||||
|
||||
nsresult rv = image.mImgContainer->
|
||||
Draw(context, GraphicsFilter::FILTER_GOOD, transformMatrix,
|
||||
gfxRect(gfxPoint(dx, dy), gfxIntSize(dw, dh)),
|
||||
nsIntRect(nsIntPoint(0, 0), gfxIntSize(imgSize.width, imgSize.height)),
|
||||
gfxIntSize(imgSize.width, imgSize.height),
|
||||
&svgContext, image.mWhichFrame, modifiedFlags);
|
||||
gfxIntSize(imgSize.width, imgSize.height), nullptr, image.mWhichFrame,
|
||||
modifiedFlags);
|
||||
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
}
|
||||
|
@ -667,8 +667,7 @@ protected:
|
||||
void DrawDirectlyToCanvas(const nsLayoutUtils::DirectDrawInfo& image,
|
||||
mozilla::gfx::Rect* bounds, double dx, double dy,
|
||||
double dw, double dh, double sx, double sy,
|
||||
double sw, double sh, gfxIntSize imgSize,
|
||||
gfxFloat opacity);
|
||||
double sw, double sh, gfxIntSize imgSize);
|
||||
|
||||
nsString& GetFont()
|
||||
{
|
||||
|
@ -31,8 +31,7 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform,
|
||||
gfxFloat aOpacity)
|
||||
const gfxMatrix& aTransform)
|
||||
{
|
||||
ExtendMode extend = ExtendMode::CLAMP;
|
||||
|
||||
@ -51,7 +50,7 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
|
||||
|
||||
if (aContext->CurrentOperator() == gfxContext::OPERATOR_CLEAR) {
|
||||
dt->ClearRect(fillRect);
|
||||
} else if (aContext->CurrentOperator() == gfxContext::OPERATOR_SOURCE && aOpacity == 1.0) {
|
||||
} else if (aContext->CurrentOperator() == gfxContext::OPERATOR_SOURCE) {
|
||||
// Emulate cairo operator source which is bound by mask!
|
||||
dt->ClearRect(fillRect);
|
||||
dt->FillRect(fillRect, pattern);
|
||||
@ -61,7 +60,7 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
|
||||
aContext->CurrentAntialiasMode() == gfxContext::MODE_ALIASED ?
|
||||
AntialiasMode::NONE :
|
||||
AntialiasMode::SUBPIXEL;
|
||||
dt->FillRect(fillRect, pattern, DrawOptions(aOpacity, op, aaMode));
|
||||
dt->FillRect(fillRect, pattern, DrawOptions(1.0f, op, aaMode));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -97,16 +96,15 @@ gfxCallbackDrawable::Draw(gfxContext* aContext,
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform,
|
||||
gfxFloat aOpacity)
|
||||
const gfxMatrix& aTransform)
|
||||
{
|
||||
if ((aRepeat || aOpacity != 1.0) && !mSurfaceDrawable) {
|
||||
if (aRepeat && !mSurfaceDrawable) {
|
||||
mSurfaceDrawable = MakeSurfaceDrawable(aFilter);
|
||||
}
|
||||
|
||||
if (mSurfaceDrawable)
|
||||
return mSurfaceDrawable->Draw(aContext, aFillRect, aRepeat, aFilter,
|
||||
aTransform, aOpacity);
|
||||
aTransform);
|
||||
|
||||
if (mCallback)
|
||||
return (*mCallback)(aContext, aFillRect, aFilter, aTransform);
|
||||
@ -161,8 +159,7 @@ gfxPatternDrawable::Draw(gfxContext* aContext,
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform,
|
||||
gfxFloat aOpacity)
|
||||
const gfxMatrix& aTransform)
|
||||
{
|
||||
if (!mPattern)
|
||||
return false;
|
||||
@ -177,7 +174,7 @@ gfxPatternDrawable::Draw(gfxContext* aContext,
|
||||
// will happen through this Draw() method with aRepeat = false.
|
||||
nsRefPtr<gfxCallbackDrawable> callbackDrawable = MakeCallbackDrawable();
|
||||
return callbackDrawable->Draw(aContext, aFillRect, true, aFilter,
|
||||
aTransform, aOpacity);
|
||||
aTransform);
|
||||
}
|
||||
|
||||
aContext->NewPath();
|
||||
@ -185,7 +182,7 @@ gfxPatternDrawable::Draw(gfxContext* aContext,
|
||||
mPattern->SetMatrix(aTransform * oldMatrix);
|
||||
aContext->SetPattern(mPattern);
|
||||
aContext->Rectangle(aFillRect);
|
||||
aContext->FillWithOpacity(aOpacity);
|
||||
aContext->Fill();
|
||||
mPattern->SetMatrix(oldMatrix);
|
||||
return true;
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ public:
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform = gfxMatrix(),
|
||||
gfxFloat aOpacity = 1.0) = 0;
|
||||
const gfxMatrix& aTransform = gfxMatrix()) = 0;
|
||||
virtual gfxIntSize Size() { return mSize; }
|
||||
|
||||
protected:
|
||||
@ -63,8 +62,7 @@ public:
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform = gfxMatrix(),
|
||||
gfxFloat aOpacity = 1.0);
|
||||
const gfxMatrix& aTransform = gfxMatrix());
|
||||
|
||||
protected:
|
||||
mozilla::RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
|
||||
@ -109,8 +107,7 @@ public:
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform = gfxMatrix(),
|
||||
gfxFloat aOpacity = 1.0);
|
||||
const gfxMatrix& aTransform = gfxMatrix());
|
||||
|
||||
protected:
|
||||
already_AddRefed<gfxSurfaceDrawable> MakeSurfaceDrawable(const GraphicsFilter aFilter = GraphicsFilter::FILTER_FAST);
|
||||
@ -133,8 +130,7 @@ public:
|
||||
const gfxRect& aFillRect,
|
||||
bool aRepeat,
|
||||
const GraphicsFilter& aFilter,
|
||||
const gfxMatrix& aTransform = gfxMatrix(),
|
||||
gfxFloat aOpacity = 1.0);
|
||||
const gfxMatrix& aTransform = gfxMatrix());
|
||||
|
||||
protected:
|
||||
already_AddRefed<gfxCallbackDrawable> MakeCallbackDrawable();
|
||||
|
@ -575,8 +575,7 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext,
|
||||
const gfxRect& aFill,
|
||||
const SurfaceFormat aFormat,
|
||||
GraphicsFilter aFilter,
|
||||
uint32_t aImageFlags,
|
||||
gfxFloat aOpacity)
|
||||
uint32_t aImageFlags)
|
||||
{
|
||||
PROFILER_LABEL("gfxUtils", "DrawPixelSnapped",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
@ -626,7 +625,7 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
drawable->Draw(aContext, aFill, doTile, aFilter, userSpaceToImageSpace, aOpacity);
|
||||
drawable->Draw(aContext, aFill, doTile, aFilter, userSpaceToImageSpace);
|
||||
}
|
||||
|
||||
/* static */ int
|
||||
|
@ -80,8 +80,7 @@ public:
|
||||
const gfxRect& aFill,
|
||||
const mozilla::gfx::SurfaceFormat aFormat,
|
||||
GraphicsFilter aFilter,
|
||||
uint32_t aImageFlags = imgIContainer::FLAG_NONE,
|
||||
gfxFloat aOpacity = 1.0);
|
||||
uint32_t aImageFlags = imgIContainer::FLAG_NONE);
|
||||
|
||||
/**
|
||||
* Clip aContext to the region aRegion.
|
||||
|
@ -880,20 +880,18 @@ VectorImage::Draw(gfxContext* aContext,
|
||||
aSVGContext, animTime, aFlags));
|
||||
}
|
||||
|
||||
gfxFloat opacity = aSVGContext ? aSVGContext->GetGlobalOpacity() : 1.0;
|
||||
|
||||
// Draw.
|
||||
if (drawable) {
|
||||
Show(drawable, params, opacity);
|
||||
Show(drawable, params);
|
||||
} else {
|
||||
CreateDrawableAndShow(params, opacity);
|
||||
CreateDrawableAndShow(params);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams, gfxFloat aOpacity)
|
||||
VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams)
|
||||
{
|
||||
mSVGDocumentWrapper->UpdateViewportBounds(aParams.viewportSize);
|
||||
mSVGDocumentWrapper->FlushImageTransformInvalidation();
|
||||
@ -914,7 +912,7 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams, gfxFloat
|
||||
// The image is too big to fit in the cache:
|
||||
!SurfaceCache::CanHold(aParams.imageRect.Size());
|
||||
if (bypassCache)
|
||||
return Show(svgDrawable, aParams, aOpacity);
|
||||
return Show(svgDrawable, aParams);
|
||||
|
||||
// Try to create an offscreen surface.
|
||||
RefPtr<gfx::DrawTarget> target =
|
||||
@ -924,7 +922,7 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams, gfxFloat
|
||||
// up way too big. Generally it also wouldn't fit in the cache, but the prefs
|
||||
// could be set such that the cache isn't the limiting factor.
|
||||
if (!target)
|
||||
return Show(svgDrawable, aParams, aOpacity);
|
||||
return Show(svgDrawable, aParams);
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(target);
|
||||
|
||||
@ -951,12 +949,12 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams, gfxFloat
|
||||
// to draw before returning from this function.
|
||||
nsRefPtr<gfxDrawable> drawable =
|
||||
new gfxSurfaceDrawable(surface, ThebesIntSize(aParams.imageRect.Size()));
|
||||
Show(drawable, aParams, aOpacity);
|
||||
Show(drawable, aParams);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams, gfxFloat aOpacity)
|
||||
VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams)
|
||||
{
|
||||
MOZ_ASSERT(aDrawable, "Should have a gfxDrawable by now");
|
||||
gfxUtils::DrawPixelSnapped(aParams.context, aDrawable,
|
||||
@ -964,7 +962,7 @@ VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams, g
|
||||
aParams.subimage, aParams.sourceRect,
|
||||
ThebesIntRect(aParams.imageRect), aParams.fill,
|
||||
SurfaceFormat::B8G8R8A8,
|
||||
aParams.filter, aParams.flags, aOpacity);
|
||||
aParams.filter, aParams.flags);
|
||||
|
||||
MOZ_ASSERT(mRenderingObserver, "Should have a rendering observer by now");
|
||||
mRenderingObserver->ResumeHonoringInvalidations();
|
||||
|
@ -86,8 +86,8 @@ protected:
|
||||
virtual nsresult StopAnimation();
|
||||
virtual bool ShouldAnimate();
|
||||
|
||||
void CreateDrawableAndShow(const SVGDrawingParameters& aParams, gfxFloat aOpacity);
|
||||
void Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams, gfxFloat aOpacity);
|
||||
void CreateDrawableAndShow(const SVGDrawingParameters& aParams);
|
||||
void Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams);
|
||||
|
||||
private:
|
||||
void CancelAllListeners();
|
||||
|
@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<div style="width: 100px; height: 100px; background: orange; position:absolute"></div>
|
||||
<div style="width: 100px; height: 100px; background: lime; opacity: .25; position:absolute"></div>
|
||||
</body>
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
function go() {
|
||||
var canvas = document.getElementById("canvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
var image = document.getElementById("image");
|
||||
|
||||
// Draw some orange
|
||||
ctx.fillStyle = "orange";
|
||||
ctx.fillRect(0, 0, 100, 100);
|
||||
|
||||
ctx.globalAlpha = 0.25;
|
||||
ctx.drawImage(image, 0, 0);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="go()">
|
||||
<canvas id="canvas" width="200" height="200"></canvas>
|
||||
<img id="image" src="lime100x100.svg" style="display: none">
|
||||
</body>
|
||||
</html>
|
@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<embed style="width: 200px; height: 200px;"
|
||||
src="squaredCircle-transparent.svg"/>
|
||||
</body>
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
function go() {
|
||||
var canvas = document.getElementById("canvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
var image = document.getElementById("image");
|
||||
|
||||
// Draw some orange
|
||||
ctx.fillStyle = "orange";
|
||||
ctx.fillRect(0, 0, 200, 200);
|
||||
|
||||
ctx.globalAlpha = 0.75;
|
||||
ctx.drawImage(image, 0, 0, 200, 200);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="go()">
|
||||
<canvas id="canvas" width="200" height="200"></canvas>
|
||||
<img id="image" src="squaredCircle-viewBox-100x100.svg" style="display: none">
|
||||
</body>
|
||||
</html>
|
@ -45,10 +45,6 @@ skip-if(B2G) == canvas-drawImage-scale-1c.html lime100x100-ref.html
|
||||
fuzzy(1,2) fails-if(Android&&AndroidVersion<15&&AndroidVersion!=10) == canvas-drawImage-scale-2a.html canvas-drawImage-scale-2-ref.html
|
||||
fails == canvas-drawImage-scale-2b.html canvas-drawImage-scale-2-ref.html
|
||||
|
||||
fuzzy-if(winWidget&&!d2d,1,10000) fuzzy-if(Android||B2G,1,10000) == canvas-drawImage-alpha-1.html canvas-drawImage-alpha-1-ref.html
|
||||
#Same as scale-2a but with globalAlpha:
|
||||
fuzzy(1,2) fuzzy-if(winWidget&&!d2d,1,40000) fuzzy-if(Android||B2G,1,40000) fails-if(Android&&AndroidVersion<15&&AndroidVersion!=10) == canvas-drawImage-alpha-2.html canvas-drawImage-alpha-2-ref.html
|
||||
|
||||
skip-if(B2G) == canvas-drawImage-slice-1a.html lime100x100-ref.html
|
||||
== canvas-drawImage-slice-1b.html lime100x100-ref.html
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" >
|
||||
<rect x="0" y="0" height="100" width="100" fill="orange"/>
|
||||
<g style="opacity:.75">
|
||||
<rect x="2" y="2" height="96" width="96"
|
||||
stroke-width="4" stroke="black" fill="yellow"/>
|
||||
<circle cx="50" cy="50" r="46" style="fill: blue"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 330 B |
@ -18,19 +18,14 @@ class SVGImageContext
|
||||
public:
|
||||
SVGImageContext() { }
|
||||
|
||||
SVGImageContext(SVGPreserveAspectRatio aPreserveAspectRatio,
|
||||
gfxFloat aOpacity = 1.0)
|
||||
: mPreserveAspectRatio(aPreserveAspectRatio), mGlobalOpacity(aOpacity)
|
||||
SVGImageContext(SVGPreserveAspectRatio aPreserveAspectRatio)
|
||||
: mPreserveAspectRatio(aPreserveAspectRatio)
|
||||
{ }
|
||||
|
||||
const SVGPreserveAspectRatio& GetPreserveAspectRatio() const {
|
||||
return mPreserveAspectRatio;
|
||||
}
|
||||
|
||||
gfxFloat GetGlobalOpacity() const {
|
||||
return mGlobalOpacity;
|
||||
}
|
||||
|
||||
bool operator==(const SVGImageContext& aOther) const {
|
||||
return mPreserveAspectRatio == aOther.mPreserveAspectRatio;
|
||||
}
|
||||
@ -45,7 +40,6 @@ public:
|
||||
|
||||
private:
|
||||
SVGPreserveAspectRatio mPreserveAspectRatio;
|
||||
gfxFloat mGlobalOpacity;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
x
Reference in New Issue
Block a user