зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 603488) for Windows reftest orange.
Backed out changeset f60f6c301670 (bug 603488) Backed out changeset 80520a16d7f1 (bug 603488) Backed out changeset eeed50e8e213 (bug 603488)
This commit is contained in:
Родитель
b39ca9caf1
Коммит
6f98a7a79c
|
@ -356,11 +356,6 @@ public:
|
|||
mCtx->CurrentState().op);
|
||||
}
|
||||
|
||||
operator DrawTarget*()
|
||||
{
|
||||
return mTarget;
|
||||
}
|
||||
|
||||
DrawTarget* operator->()
|
||||
{
|
||||
return mTarget;
|
||||
|
@ -3047,17 +3042,14 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
|
|||
}
|
||||
}
|
||||
|
||||
nsLayoutUtils::DirectDrawInfo drawInfo;
|
||||
|
||||
if (!srcSurf) {
|
||||
// The canvas spec says that drawImage should draw the first frame
|
||||
// of animated images. We also don't want to rasterize vector images.
|
||||
uint32_t sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME |
|
||||
nsLayoutUtils::SFE_NO_RASTERIZING_VECTORS;
|
||||
// of animated images
|
||||
uint32_t sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME;
|
||||
nsLayoutUtils::SurfaceFromElementResult res =
|
||||
nsLayoutUtils::SurfaceFromElement(element, sfeFlags);
|
||||
|
||||
if (!res.mSurface && !res.mDrawInfo.mImgContainer) {
|
||||
if (!res.mSurface) {
|
||||
// Spec says to silently do nothing if the element is still loading.
|
||||
if (!res.mIsStillLoading) {
|
||||
error.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
|
@ -3066,7 +3058,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
|
|||
}
|
||||
|
||||
// Ignore cairo surfaces that are bad! See bug 666312.
|
||||
if (res.mSurface && res.mSurface->CairoStatus()) {
|
||||
if (res.mSurface->CairoStatus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3078,16 +3070,12 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
|
|||
res.mCORSUsed);
|
||||
}
|
||||
|
||||
if (res.mSurface) {
|
||||
if (res.mImageRequest) {
|
||||
CanvasImageCache::NotifyDrawImage(element, mCanvasElement,
|
||||
res.mImageRequest, res.mSurface, imgSize);
|
||||
}
|
||||
|
||||
srcSurf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mTarget, res.mSurface);
|
||||
} else {
|
||||
drawInfo = res.mDrawInfo;
|
||||
if (res.mImageRequest) {
|
||||
CanvasImageCache::NotifyDrawImage(element, mCanvasElement,
|
||||
res.mImageRequest, res.mSurface, imgSize);
|
||||
}
|
||||
|
||||
srcSurf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mTarget, res.mSurface);
|
||||
}
|
||||
|
||||
if (optional_argc == 0) {
|
||||
|
@ -3134,62 +3122,16 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
|
|||
bounds = mTarget->GetTransform().TransformBounds(bounds);
|
||||
}
|
||||
|
||||
if (srcSurf) {
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
DrawSurface(srcSurf,
|
||||
mgfx::Rect(dx, dy, dw, dh),
|
||||
mgfx::Rect(sx, sy, sw, sh),
|
||||
DrawSurfaceOptions(filter),
|
||||
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
|
||||
} else {
|
||||
DrawDirectlyToCanvas(drawInfo, &bounds, dx, dy, dw, dh,
|
||||
sx, sy, sw, sh, imgSize);
|
||||
}
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
DrawSurface(srcSurf,
|
||||
mgfx::Rect(dx, dy, dw, dh),
|
||||
mgfx::Rect(sx, sy, sw, sh),
|
||||
DrawSurfaceOptions(filter),
|
||||
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
|
||||
|
||||
RedrawUser(gfxRect(dx, dy, dw, dh));
|
||||
}
|
||||
|
||||
void
|
||||
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)
|
||||
{
|
||||
gfxMatrix contextMatrix;
|
||||
|
||||
AdjustedTarget tempTarget(this, bounds->IsEmpty() ? nullptr: bounds);
|
||||
|
||||
// get any already existing transforms on the context. Include transformations used for context shadow
|
||||
if (tempTarget) {
|
||||
Matrix matrix = tempTarget->GetTransform();
|
||||
contextMatrix = gfxMatrix(matrix._11, matrix._12, matrix._21,
|
||||
matrix._22, matrix._31, matrix._32);
|
||||
}
|
||||
|
||||
gfxMatrix transformMatrix;
|
||||
transformMatrix.Translate(gfxPoint(sx, sy));
|
||||
if (dw > 0 && dh > 0) {
|
||||
transformMatrix.Scale(sw/dw, sh/dh);
|
||||
}
|
||||
transformMatrix.Translate(gfxPoint(-dx, -dy));
|
||||
|
||||
nsRefPtr<gfxContext> context = new gfxContext(tempTarget);
|
||||
context->SetMatrix(contextMatrix);
|
||||
|
||||
// FLAG_CAMP is added for increased performance
|
||||
uint32_t modifiedFlags = image.mDrawingFlags | imgIContainer::FLAG_CLAMP;
|
||||
|
||||
nsresult rv = image.mImgContainer->
|
||||
Draw(context, gfxPattern::FILTER_GOOD, transformMatrix,
|
||||
gfxRect(gfxPoint(dx, dy), gfxIntSize(dw, dh)),
|
||||
nsIntRect(nsIntPoint(0, 0), gfxIntSize(imgSize.width, imgSize.height)),
|
||||
gfxIntSize(imgSize.width, imgSize.height), nullptr, image.mWhichFrame,
|
||||
modifiedFlags);
|
||||
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& op,
|
||||
ErrorResult& error)
|
||||
|
|
|
@ -548,11 +548,6 @@ protected:
|
|||
double dx, double dy, double dw, double dh,
|
||||
uint8_t optional_argc, mozilla::ErrorResult& error);
|
||||
|
||||
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);
|
||||
|
||||
nsString& GetFont()
|
||||
{
|
||||
/* will initilize the value if not set, else does nothing */
|
||||
|
|
|
@ -1455,17 +1455,11 @@ gfxContext::Mask(gfxASurface *surface, const gfxPoint& offset)
|
|||
|
||||
gfxPoint pt = surface->GetDeviceOffset();
|
||||
|
||||
//Since we're already passing the offset as a transform, we have to temporarily set the device offset to 0,0 to avoid using it twice if sourceSurf still has access to it.
|
||||
surface->SetDeviceOffset(gfxPoint(0.0,0.0));
|
||||
|
||||
// We clip here to bind to the mask surface bounds, see above.
|
||||
mDT->MaskSurface(GeneralPattern(this),
|
||||
sourceSurf,
|
||||
Point(offset.x - pt.x, offset.y - pt.y),
|
||||
DrawOptions(1.0f, CurrentState().op, CurrentState().aaMode));
|
||||
|
||||
//We set the device offset to zero temporarily. Let's restore it now.
|
||||
surface->SetDeviceOffset(pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4484,6 +4484,15 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
|
|||
SurfaceFromElementResult result;
|
||||
nsresult rv;
|
||||
|
||||
bool forceCopy = (aSurfaceFlags & SFE_WANT_NEW_SURFACE) != 0;
|
||||
bool wantImageSurface = (aSurfaceFlags & SFE_WANT_IMAGE_SURFACE) != 0;
|
||||
bool premultAlpha = (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA) == 0;
|
||||
|
||||
if (!premultAlpha) {
|
||||
forceCopy = true;
|
||||
wantImageSurface = true;
|
||||
}
|
||||
|
||||
// Push a null JSContext on the stack so that code that runs within
|
||||
// the below code doesn't think it's being called by JS. See bug
|
||||
// 604262.
|
||||
|
@ -4516,8 +4525,6 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
|
|||
if (NS_FAILED(rv))
|
||||
return result;
|
||||
|
||||
uint32_t noRasterize = aSurfaceFlags & SFE_NO_RASTERIZING_VECTORS;
|
||||
|
||||
uint32_t whichFrame = (aSurfaceFlags & SFE_WANT_FIRST_FRAME)
|
||||
? (uint32_t) imgIContainer::FRAME_FIRST
|
||||
: (uint32_t) imgIContainer::FRAME_CURRENT;
|
||||
|
@ -4526,6 +4533,12 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
|
|||
frameFlags |= imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION;
|
||||
if (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA)
|
||||
frameFlags |= imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
|
||||
nsRefPtr<gfxASurface> framesurf;
|
||||
rv = imgContainer->GetFrame(whichFrame,
|
||||
frameFlags,
|
||||
getter_AddRefs(framesurf));
|
||||
if (NS_FAILED(rv))
|
||||
return result;
|
||||
|
||||
int32_t imgWidth, imgHeight;
|
||||
rv = imgContainer->GetWidth(&imgWidth);
|
||||
|
@ -4533,48 +4546,24 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
|
|||
if (NS_FAILED(rv) || NS_FAILED(rv2))
|
||||
return result;
|
||||
|
||||
if (!noRasterize || imgContainer->GetType() == imgIContainer::TYPE_RASTER) {
|
||||
bool forceCopy = (aSurfaceFlags & SFE_WANT_NEW_SURFACE) != 0;
|
||||
bool wantImageSurface = (aSurfaceFlags & SFE_WANT_IMAGE_SURFACE) != 0;
|
||||
bool premultAlpha = (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA) == 0;
|
||||
|
||||
if (!premultAlpha) {
|
||||
forceCopy = true;
|
||||
wantImageSurface = true;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> framesurf;
|
||||
rv = imgContainer->GetFrame(whichFrame,
|
||||
frameFlags,
|
||||
getter_AddRefs(framesurf));
|
||||
if (NS_FAILED(rv))
|
||||
return result;
|
||||
|
||||
if (wantImageSurface && framesurf->GetType() != gfxASurface::SurfaceTypeImage) {
|
||||
forceCopy = true;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> gfxsurf = framesurf;
|
||||
if (forceCopy) {
|
||||
if (wantImageSurface) {
|
||||
gfxsurf = new gfxImageSurface (gfxIntSize(imgWidth, imgHeight), gfxASurface::ImageFormatARGB32);
|
||||
} else {
|
||||
gfxsurf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(imgWidth, imgHeight),
|
||||
gfxASurface::CONTENT_COLOR_ALPHA);
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(gfxsurf);
|
||||
|
||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx->SetSource(framesurf);
|
||||
ctx->Paint();
|
||||
}
|
||||
result.mSurface = gfxsurf;
|
||||
if (wantImageSurface && framesurf->GetType() != gfxASurface::SurfaceTypeImage) {
|
||||
forceCopy = true;
|
||||
}
|
||||
else {
|
||||
result.mDrawInfo.mImgContainer = imgContainer;
|
||||
result.mDrawInfo.mWhichFrame = whichFrame;
|
||||
result.mDrawInfo.mDrawingFlags = frameFlags;
|
||||
|
||||
nsRefPtr<gfxASurface> gfxsurf = framesurf;
|
||||
if (forceCopy) {
|
||||
if (wantImageSurface) {
|
||||
gfxsurf = new gfxImageSurface (gfxIntSize(imgWidth, imgHeight), gfxASurface::ImageFormatARGB32);
|
||||
} else {
|
||||
gfxsurf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(imgWidth, imgHeight),
|
||||
gfxASurface::CONTENT_COLOR_ALPHA);
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(gfxsurf);
|
||||
|
||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx->SetSource(framesurf);
|
||||
ctx->Paint();
|
||||
}
|
||||
|
||||
int32_t corsmode;
|
||||
|
@ -4582,6 +4571,7 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
|
|||
result.mCORSUsed = (corsmode != imgIRequest::CORS_NONE);
|
||||
}
|
||||
|
||||
result.mSurface = gfxsurf;
|
||||
result.mSize = gfxIntSize(imgWidth, imgHeight);
|
||||
result.mPrincipal = principal.forget();
|
||||
// no images, including SVG images, can load content from another domain.
|
||||
|
|
|
@ -1474,19 +1474,7 @@ public:
|
|||
/* Whether we should skip premultiplication -- the resulting
|
||||
image will always be an image surface, and must not be given to
|
||||
Thebes for compositing! */
|
||||
SFE_NO_PREMULTIPLY_ALPHA = 1 << 4,
|
||||
/* Whether we should skip getting a surface for vector images and
|
||||
return a DirectDrawInfo containing an imgIContainer instead. */
|
||||
SFE_NO_RASTERIZING_VECTORS = 1 << 5
|
||||
};
|
||||
|
||||
struct DirectDrawInfo {
|
||||
/* imgIContainer to directly draw to a context */
|
||||
nsCOMPtr<imgIContainer> mImgContainer;
|
||||
/* which frame to draw */
|
||||
uint32_t mWhichFrame;
|
||||
/* imgIContainer flags to use when drawing */
|
||||
uint32_t mDrawingFlags;
|
||||
SFE_NO_PREMULTIPLY_ALPHA = 1 << 4
|
||||
};
|
||||
|
||||
struct SurfaceFromElementResult {
|
||||
|
@ -1496,8 +1484,6 @@ public:
|
|||
|
||||
/* mSurface will contain the resulting surface, or will be NULL on error */
|
||||
nsRefPtr<gfxASurface> mSurface;
|
||||
/* Contains info for drawing when there is no mSurface. */
|
||||
DirectDrawInfo mDrawInfo;
|
||||
/* The size of the surface */
|
||||
gfxIntSize mSize;
|
||||
/* The principal associated with the element whose surface was returned.
|
||||
|
|
Загрузка…
Ссылка в новой задаче