Skip to content

Commit

Permalink
Backed out changesets 950a3afc2b15 and dfb5303af6f9 (bug 1028288) for…
Browse files Browse the repository at this point in the history
… being incorrect
  • Loading branch information
KWierso committed Aug 6, 2014
1 parent 82972d1 commit 914924e
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 124 deletions.
13 changes: 4 additions & 9 deletions dom/canvas/CanvasRenderingContext2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

#include "nsIServiceManager.h"
#include "nsMathUtils.h"
#include "SVGPreserveAspectRatio.h"
#include "SVGImageContext.h"

#include "nsContentUtils.h"

Expand Down Expand Up @@ -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));
Expand All @@ -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;

Expand All @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions dom/canvas/CanvasRenderingContext2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,7 @@ typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
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()
{
Expand Down
21 changes: 9 additions & 12 deletions gfx/thebes/gfxDrawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -177,15 +174,15 @@ 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();
gfxMatrix oldMatrix = mPattern->GetMatrix();
mPattern->SetMatrix(aTransform * oldMatrix);
aContext->SetPattern(mPattern);
aContext->Rectangle(aFillRect);
aContext->FillWithOpacity(aOpacity);
aContext->Fill();
mPattern->SetMatrix(oldMatrix);
return true;
}
12 changes: 4 additions & 8 deletions gfx/thebes/gfxDrawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class gfxDrawable {
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:
Expand All @@ -63,8 +62,7 @@ class gfxSurfaceDrawable : public gfxDrawable {
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;
Expand Down Expand Up @@ -109,8 +107,7 @@ class gfxCallbackDrawable : public gfxDrawable {
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);
Expand All @@ -133,8 +130,7 @@ class gfxPatternDrawable : public gfxDrawable {
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();
Expand Down
5 changes: 2 additions & 3 deletions gfx/thebes/gfxUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions gfx/thebes/gfxUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class gfxUtils {
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.
Expand Down
18 changes: 8 additions & 10 deletions image/src/VectorImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 =
Expand All @@ -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);

Expand All @@ -951,20 +949,20 @@ 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,
aParams.userSpaceToImageSpace,
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();
Expand Down
4 changes: 2 additions & 2 deletions image/src/VectorImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class VectorImage : public ImageResource,
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();
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions layout/reftests/svg/as-image/canvas-drawImage-alpha-1.html

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions layout/reftests/svg/as-image/canvas-drawImage-alpha-2.html

This file was deleted.

4 changes: 0 additions & 4 deletions layout/reftests/svg/as-image/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions layout/reftests/svg/as-image/squaredCircle-transparent.svg

This file was deleted.

10 changes: 2 additions & 8 deletions layout/svg/SVGImageContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -45,7 +40,6 @@ class SVGImageContext

private:
SVGPreserveAspectRatio mPreserveAspectRatio;
gfxFloat mGlobalOpacity;
};

} // namespace mozilla
Expand Down

0 comments on commit 914924e

Please sign in to comment.