Adopt a patch that fixes a bug causing animated gifs to flicker

when using cairo 1.10.x and make mozilla-firefox and mozilla-thunderbird
build against systemwide cairo as it was with cairo 1.8.x.
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>

https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch

OK landry@
This commit is contained in:
dcoppa 2011-03-10 14:34:17 +00:00
parent 784e269dd3
commit 9f2ad3cb2a
11 changed files with 350 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.118 2011/03/02 14:44:19 landry Exp $
# $OpenBSD: Makefile,v 1.119 2011/03/10 14:34:17 dcoppa Exp $
COMMENT-main = Mozilla e-mail, rss and usenet client
COMMENT-lightning = Mozilla Thunderbird calendar extension
@ -12,6 +12,7 @@ MOZILLA_CODENAME = mail
MULTI_PACKAGES = -main -lightning
PKGNAME-main = ${PKGNAME}
REVISION-main = 0
PKGNAME-lightning = lightning-1.0beta2
EPOCH-lightning = 0
REVISION-lightning = 14

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-mozilla_modules_libpr0n_decoders_gif_nsGIFDecoder2_cpp,v 1.1 2011/03/10 14:34:17 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp.orig Mon Feb 21 12:47:04 2011
+++ mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp Tue Mar 8 14:30:15 2011
@@ -202,7 +202,7 @@ static NS_METHOD ReadDataOut(nsIInputStream* in,
nsresult
nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows)
{
- nsIntRect r(0, fromRow, mGIFStruct.width, rows);
+ nsIntRect r(mGIFStruct.x_offset, mGIFStruct.y_offset + fromRow, mGIFStruct.width, rows);
// Update image
nsresult rv = mImageContainer->FrameUpdated(mGIFStruct.images_decoded, r);
@@ -215,7 +215,6 @@ nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint
if (!mGIFStruct.images_decoded && mObserver) {
PRUint32 imgCurFrame;
mImageContainer->GetCurrentFrameIndex(&imgCurFrame);
- r.y += mGIFStruct.y_offset;
mObserver->OnDataAvailable(nsnull, imgCurFrame == PRUint32(mGIFStruct.images_decoded), &r);
}
return NS_OK;

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-mozilla_modules_libpr0n_src_imgContainer_cpp,v 1.1 2011/03/10 14:34:17 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- mozilla/modules/libpr0n/src/imgContainer.cpp.orig Mon Feb 21 12:47:04 2011
+++ mozilla/modules/libpr0n/src/imgContainer.cpp Tue Mar 8 14:30:15 2011
@@ -420,6 +420,8 @@ nsresult imgContainer::InternalAddFrameHelper(PRUint32
frame->GetImageData(imageData, imageLength);
+ frame->LockImageData();
+
mFrames.InsertElementAt(framenum, frame.forget());
mNumFrames++;
@@ -444,6 +446,11 @@ nsresult imgContainer::InternalAddFrame(PRUint32 frame
nsresult rv = frame->Init(aX, aY, aWidth, aHeight, aFormat, aPaletteDepth);
NS_ENSURE_SUCCESS(rv, rv);
+
+ if (mFrames.Length() > 0) {
+ imgFrame *prevframe = mFrames.ElementAt(mFrames.Length() - 1);
+ prevframe->UnlockImageData();
+ }
if (mFrames.Length() == 0) {
return InternalAddFrameHelper(framenum, frame.forget(), imageData, imageLength,

View File

@ -0,0 +1,91 @@
$OpenBSD: patch-mozilla_modules_libpr0n_src_imgFrame_cpp,v 1.1 2011/03/10 14:34:17 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- mozilla/modules/libpr0n/src/imgFrame.cpp.orig Mon Feb 21 12:47:04 2011
+++ mozilla/modules/libpr0n/src/imgFrame.cpp Tue Mar 8 14:30:15 2011
@@ -157,6 +157,7 @@ imgFrame::imgFrame() :
#ifdef USE_WIN_SURFACE
, mIsDDBSurface(PR_FALSE)
#endif
+ , mLocked(PR_FALSE)
{
static PRBool hasCheckedOptimize = PR_FALSE;
if (!hasCheckedOptimize) {
@@ -418,8 +419,7 @@ void imgFrame::Draw(gfxContext *aContext, gfxPattern::
PRBool doTile = !imageRect.Contains(sourceRect);
if (doPadding || doPartialDecode) {
- gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height) +
- gfxPoint(aPadding.left, aPadding.top);
+ gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height);
if (!doTile && !mSinglePixel) {
// Not tiling, and we have a surface, so we can account for
@@ -713,7 +713,7 @@ nsresult imgFrame::ImageUpdated(const nsIntRect &aUpda
// clamp to bounds, in case someone sends a bogus updateRect (I'm looking at
// you, gif decoder)
- nsIntRect boundsRect(0, 0, mSize.width, mSize.height);
+ nsIntRect boundsRect(mOffset, mSize);
mDecoded.IntersectRect(mDecoded, boundsRect);
#ifdef XP_MACOSX
@@ -811,8 +811,14 @@ void imgFrame::GetPaletteData(PRUint32 **aPalette, PRU
nsresult imgFrame::LockImageData()
{
if (mPalettedImageData)
- return NS_OK;
+ return NS_ERROR_NOT_AVAILABLE;
+ NS_ABORT_IF_FALSE(!mLocked, "Trying to lock already locked image data.");
+ if (mLocked) {
+ return NS_ERROR_FAILURE;
+ }
+ mLocked = PR_TRUE;
+
if ((mOptSurface || mSinglePixel) && !mImageSurface) {
// Recover the pixels
mImageSurface = new gfxImageSurface(gfxIntSize(mSize.width, mSize.height),
@@ -837,14 +843,26 @@ nsresult imgFrame::LockImageData()
#endif
}
+ if (mImageSurface)
+ mImageSurface->Flush();
+
return NS_OK;
}
nsresult imgFrame::UnlockImageData()
{
if (mPalettedImageData)
- return NS_OK;
+ return NS_ERROR_NOT_AVAILABLE;
+ NS_ABORT_IF_FALSE(mLocked, "Unlocking an unlocked image!");
+ if (!mLocked) {
+ return NS_ERROR_FAILURE;
+ }
+ mLocked = PR_FALSE;
+
+ if (mImageSurface)
+ mImageSurface->MarkDirty();
+
#ifdef XP_MACOSX
if (mQuartzSurface)
mQuartzSurface->Flush();
@@ -900,7 +918,7 @@ void imgFrame::SetBlendMethod(PRInt32 aBlendMethod)
PRBool imgFrame::ImageComplete() const
{
- return mDecoded == nsIntRect(0, 0, mSize.width, mSize.height);
+ return mDecoded == nsIntRect(mOffset, mSize);
}
// A hint from the image decoders that this image has no alpha, even

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-mozilla_modules_libpr0n_src_imgFrame_h,v 1.1 2011/03/10 14:34:17 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- mozilla/modules/libpr0n/src/imgFrame.h.orig Mon Feb 21 12:47:04 2011
+++ mozilla/modules/libpr0n/src/imgFrame.h Tue Mar 8 14:30:15 2011
@@ -172,6 +172,7 @@ class imgFrame (private)
PRPackedBool mNeverUseDeviceSurface;
PRPackedBool mFormatChanged;
PRPackedBool mCompositingFailed;
+ PRPackedBool mLocked;
#ifdef XP_WIN
PRPackedBool mIsDDBSurface;

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.167 2011/03/02 14:39:48 landry Exp $
# $OpenBSD: Makefile,v 1.168 2011/03/10 14:34:18 dcoppa Exp $
COMMENT = Mozilla web browser
@ -7,6 +7,7 @@ MOZILLA_VERSION = 3.6.14
MOZILLA_BRANCH = 1.9.2
MOZILLA_PROJECT = mozilla-firefox
MOZILLA_CODENAME = browser
REVISION = 0
SO_VERSION = 22.2
# NOTE: Must bump minor version if any shlib's are removed from the

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-modules_libpr0n_decoders_gif_nsGIFDecoder2_cpp,v 1.1 2011/03/10 14:34:18 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp.orig Thu Mar 3 11:43:21 2011
+++ modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp Tue Mar 8 12:43:28 2011
@@ -202,7 +202,7 @@ static NS_METHOD ReadDataOut(nsIInputStream* in,
nsresult
nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows)
{
- nsIntRect r(0, fromRow, mGIFStruct.width, rows);
+ nsIntRect r(mGIFStruct.x_offset, mGIFStruct.y_offset + fromRow, mGIFStruct.width, rows);
// Update image
nsresult rv = mImageContainer->FrameUpdated(mGIFStruct.images_decoded, r);
@@ -215,7 +215,6 @@ nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint
if (!mGIFStruct.images_decoded && mObserver) {
PRUint32 imgCurFrame;
mImageContainer->GetCurrentFrameIndex(&imgCurFrame);
- r.y += mGIFStruct.y_offset;
mObserver->OnDataAvailable(nsnull, imgCurFrame == PRUint32(mGIFStruct.images_decoded), &r);
}
return NS_OK;

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-modules_libpr0n_src_imgContainer_cpp,v 1.1 2011/03/10 14:34:18 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- modules/libpr0n/src/imgContainer.cpp.orig Thu Mar 3 11:43:21 2011
+++ modules/libpr0n/src/imgContainer.cpp Tue Mar 8 12:43:28 2011
@@ -420,6 +420,8 @@ nsresult imgContainer::InternalAddFrameHelper(PRUint32
frame->GetImageData(imageData, imageLength);
+ frame->LockImageData();
+
mFrames.InsertElementAt(framenum, frame.forget());
mNumFrames++;
@@ -444,6 +446,11 @@ nsresult imgContainer::InternalAddFrame(PRUint32 frame
nsresult rv = frame->Init(aX, aY, aWidth, aHeight, aFormat, aPaletteDepth);
NS_ENSURE_SUCCESS(rv, rv);
+
+ if (mFrames.Length() > 0) {
+ imgFrame *prevframe = mFrames.ElementAt(mFrames.Length() - 1);
+ prevframe->UnlockImageData();
+ }
if (mFrames.Length() == 0) {
return InternalAddFrameHelper(framenum, frame.forget(), imageData, imageLength,

View File

@ -0,0 +1,91 @@
$OpenBSD: patch-modules_libpr0n_src_imgFrame_cpp,v 1.1 2011/03/10 14:34:18 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- modules/libpr0n/src/imgFrame.cpp.orig Thu Mar 3 11:43:21 2011
+++ modules/libpr0n/src/imgFrame.cpp Tue Mar 8 12:43:28 2011
@@ -157,6 +157,7 @@ imgFrame::imgFrame() :
#ifdef USE_WIN_SURFACE
, mIsDDBSurface(PR_FALSE)
#endif
+ , mLocked(PR_FALSE)
{
static PRBool hasCheckedOptimize = PR_FALSE;
if (!hasCheckedOptimize) {
@@ -418,8 +419,7 @@ void imgFrame::Draw(gfxContext *aContext, gfxPattern::
PRBool doTile = !imageRect.Contains(sourceRect);
if (doPadding || doPartialDecode) {
- gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height) +
- gfxPoint(aPadding.left, aPadding.top);
+ gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height);
if (!doTile && !mSinglePixel) {
// Not tiling, and we have a surface, so we can account for
@@ -713,7 +713,7 @@ nsresult imgFrame::ImageUpdated(const nsIntRect &aUpda
// clamp to bounds, in case someone sends a bogus updateRect (I'm looking at
// you, gif decoder)
- nsIntRect boundsRect(0, 0, mSize.width, mSize.height);
+ nsIntRect boundsRect(mOffset, mSize);
mDecoded.IntersectRect(mDecoded, boundsRect);
#ifdef XP_MACOSX
@@ -811,8 +811,14 @@ void imgFrame::GetPaletteData(PRUint32 **aPalette, PRU
nsresult imgFrame::LockImageData()
{
if (mPalettedImageData)
- return NS_OK;
+ return NS_ERROR_NOT_AVAILABLE;
+ NS_ABORT_IF_FALSE(!mLocked, "Trying to lock already locked image data.");
+ if (mLocked) {
+ return NS_ERROR_FAILURE;
+ }
+ mLocked = PR_TRUE;
+
if ((mOptSurface || mSinglePixel) && !mImageSurface) {
// Recover the pixels
mImageSurface = new gfxImageSurface(gfxIntSize(mSize.width, mSize.height),
@@ -837,14 +843,26 @@ nsresult imgFrame::LockImageData()
#endif
}
+ if (mImageSurface)
+ mImageSurface->Flush();
+
return NS_OK;
}
nsresult imgFrame::UnlockImageData()
{
if (mPalettedImageData)
- return NS_OK;
+ return NS_ERROR_NOT_AVAILABLE;
+ NS_ABORT_IF_FALSE(mLocked, "Unlocking an unlocked image!");
+ if (!mLocked) {
+ return NS_ERROR_FAILURE;
+ }
+ mLocked = PR_FALSE;
+
+ if (mImageSurface)
+ mImageSurface->MarkDirty();
+
#ifdef XP_MACOSX
if (mQuartzSurface)
mQuartzSurface->Flush();
@@ -900,7 +918,7 @@ void imgFrame::SetBlendMethod(PRInt32 aBlendMethod)
PRBool imgFrame::ImageComplete() const
{
- return mDecoded == nsIntRect(0, 0, mSize.width, mSize.height);
+ return mDecoded == nsIntRect(mOffset, mSize);
}
// A hint from the image decoders that this image has no alpha, even

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-modules_libpr0n_src_imgFrame_h,v 1.1 2011/03/10 14:34:18 dcoppa Exp $
Fix animated gif flickering bug with cairo 1.10.x
Patch backported from FF4 branch by Rafal Muzylo <galtgendo@o2.pl>
https://bugzilla.mozilla.org/show_bug.cgi?id=597174
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/xulrunner/files/fix-animated-gifs.patch
--- modules/libpr0n/src/imgFrame.h.orig Thu Mar 3 11:43:21 2011
+++ modules/libpr0n/src/imgFrame.h Tue Mar 8 12:43:28 2011
@@ -172,6 +172,7 @@ class imgFrame (private)
PRPackedBool mNeverUseDeviceSurface;
PRPackedBool mFormatChanged;
PRPackedBool mCompositingFailed;
+ PRPackedBool mLocked;
#ifdef XP_WIN
PRPackedBool mIsDDBSurface;

View File

@ -1,4 +1,4 @@
# $OpenBSD: mozilla.port.mk,v 1.20 2011/01/18 12:31:24 landry Exp $
# $OpenBSD: mozilla.port.mk,v 1.21 2011/03/10 14:34:17 dcoppa Exp $
SHARED_ONLY = Yes
ONLY_FOR_ARCHS= alpha amd64 arm i386 powerpc sparc64
@ -72,6 +72,11 @@ CONFIGURE_ARGS +=--with-system-jpeg=${LOCALBASE} \
--enable-svg-renderer=cairo \
--enable-canvas
# for mozilla branch 1.9.2, build against systemwide cairo
.if ${MOZILLA_BRANCH} == 1.9.2
CONFIGURE_ARGS +=--enable-system-cairo
.endif
# those ones only apply to mozilla branch 1.9.2 but 1.9.1 apps don't complain
CONFIGURE_ARGS +=--disable-freetypetest \
--disable-mochitest \