Bug 77497 imgContainer needs to have a GIF specific version

patch by paper@animecity.nu r=pavlov sr=tor
This commit is contained in:
timeless%mac.com 2002-10-07 21:49:33 +00:00
Родитель 7665afebba
Коммит 23d2e15fdc
8 изменённых файлов: 1463 добавлений и 1130 удалений

Просмотреть файл

@ -31,6 +31,7 @@
#include "imgRequestProxy.h"
// gif
#include "imgContainerGIF.h"
#include "nsGIFDecoder2.h"
@ -58,6 +59,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(imgLoader)
NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequestProxy)
// gif
NS_GENERIC_FACTORY_CONSTRUCTOR(imgContainerGIF)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGIFDecoder2)
// jpeg
@ -96,6 +98,10 @@ static const nsModuleComponentInfo components[] =
imgRequestProxyConstructor, },
// gif
{ "GIF image container",
NS_GIFCONTAINER_CID,
"@mozilla.org/image/container;1?type=image/gif",
imgContainerGIFConstructor, },
{ "GIF Decoder",
NS_GIFDECODER2_CID,
"@mozilla.org/image/decoder;2?type=image/gif",

Просмотреть файл

@ -37,7 +37,7 @@ REQUIRES = xpcom \
imglib2 \
$(NULL)
CPPSRCS = GIF2.cpp nsGIFDecoder2.cpp
CPPSRCS = GIF2.cpp nsGIFDecoder2.cpp imgContainerGIF.cpp
include $(topsrcdir)/config/rules.mk

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Chris Saari <saari@netscape.com>
* Arron Mogge <paper@animecity.nu>
*/
#ifndef _imgContainerGIF_h_
#define _imgContainerGIF_h_
#include "imgIContainerObserver.h"
#include "imgIContainer.h"
#include "nsSize.h"
#include "nsSupportsArray.h"
#include "nsCOMPtr.h"
#include "nsITimer.h"
#include "imgIDecoderObserver.h"
#include "gfxIImageFrame.h"
#include "nsWeakReference.h"
#define NS_GIFCONTAINER_CID \
{ /* da72e7ee-4821-4452-802d-5eb2d865dd3c */ \
0xda72e7ee, \
0x4821, \
0x4452, \
{0x80, 0x2d, 0x5e, 0xb2, 0xd8, 0x65, 0xdd, 0x3c} \
}
class imgContainerGIF : public imgIContainer,
public nsITimerCallback,
public imgIDecoderObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMGICONTAINER
NS_DECL_IMGIDECODEROBSERVER
NS_DECL_IMGICONTAINEROBSERVER
NS_DECL_NSITIMERCALLBACK
imgContainerGIF();
virtual ~imgContainerGIF();
private:
inline PRUint32 inlinedGetNumFrames() {
PRUint32 nframes;
mFrames.Count(&nframes);
return nframes;
}
inline nsresult inlinedGetFrameAt(PRUint32 index, gfxIImageFrame **_retval) {
// callers DO try to go past the end
nsISupports *_elem = mFrames.ElementAt(index);
if (!_elem) return NS_ERROR_FAILURE;
*_retval = NS_STATIC_CAST(gfxIImageFrame*, _elem);
return NS_OK;
}
inline nsresult inlinedGetCurrentFrame(gfxIImageFrame **_retval) {
if (mCompositingFrame) {
*_retval = mCompositingFrame;
NS_ADDREF(*_retval);
return NS_OK;
}
return inlinedGetFrameAt(mCurrentAnimationFrameIndex, _retval);
}
/* additional members */
nsSupportsArray mFrames;
nsSize mSize;
nsWeakPtr mObserver;
PRUint32 mCurrentDecodingFrameIndex; // 0 to numFrames-1
PRUint32 mCurrentAnimationFrameIndex; // 0 to numFrames-1
PRBool mCurrentFrameIsFinishedDecoding;
PRBool mDoneDecoding;
PRBool mAnimating;
PRUint16 mAnimationMode;
PRInt32 mLoopCount;
private:
// GIF specific bits
nsCOMPtr<nsITimer> mTimer;
// GIF animations will use the mCompositingFrame to composite images
// and just hand this back to the caller when it is time to draw the frame.
nsCOMPtr<gfxIImageFrame> mCompositingFrame;
nsCOMPtr<gfxIImageFrame> mCompositingPrevFrame;
// Private function for doing the frame compositing of animations and in cases
// where there is a backgound color and single frame placed withing a larger
// logical screen size. Smart GIF compressors may do this to save space.
void DoComposite(gfxIImageFrame** aFrameToUse, nsRect* aDirtyRect,
PRInt32 aPrevFrame, PRInt32 aNextFrame);
void BuildCompositeMask(gfxIImageFrame* aCompositingFrame, gfxIImageFrame* aOverlayFrame);
void ZeroMask(gfxIImageFrame *aCompositingFrame);
void ZeroMaskArea(gfxIImageFrame *aCompositingFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void OneMaskArea(gfxIImageFrame *aCompositingFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void BlackenFrame(gfxIImageFrame* aFrame);
void BlackenFrame(gfxIImageFrame *aFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
};
#endif /* __imgContainerGIF_h__ */

Просмотреть файл

@ -127,7 +127,7 @@ NS_IMETHODIMP nsGIFDecoder2::Init(imgILoad *aLoad)
{
mObserver = do_QueryInterface(aLoad);
mImageContainer = do_CreateInstance("@mozilla.org/image/container;1");
mImageContainer = do_CreateInstance("@mozilla.org/image/container;1?type=image/gif");
aLoad->SetImage(mImageContainer);
/* do gif init stuff */

Просмотреть файл

@ -960,6 +960,13 @@
<FILEKIND>Library</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>imgContainerGIF.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -1077,6 +1084,11 @@
<PATH>zlibDebug.shlb</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>imgContainerGIF.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
<TARGET>
@ -1926,6 +1938,13 @@
<FILEKIND>Library</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>imgContainerGIF.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -2043,6 +2062,11 @@
<PATH>zlib.shlb</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>imgContainerGIF.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
</TARGETLIST>
@ -2104,6 +2128,12 @@
<PATH>GIF2.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>libimg2Debug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>imgContainerGIF.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>libimg2Debug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
@ -2122,6 +2152,12 @@
<PATH>nsICODecoder.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>libimg2.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsJPEGDecoder.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>libimg2Debug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -4,20 +4,20 @@
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*
* The Original Code is mozilla.org code.
*
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Chris Saari <saari@netscape.com>
*/
@ -25,21 +25,10 @@
#ifndef __imgContainer_h__
#define __imgContainer_h__
#include "imgIContainer.h"
#include "imgIContainerObserver.h"
#include "nsSize.h"
#include "nsSupportsArray.h"
#include "nsCOMPtr.h"
#include "nsITimer.h"
#include "imgIDecoderObserver.h"
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include "nsWeakReference.h"
#define NS_IMGCONTAINER_CID \
{ /* 5e04ec5e-1dd2-11b2-8fda-c4db5fb666e0 */ \
@ -49,83 +38,18 @@
{0x8f, 0xda, 0xc4, 0xdb, 0x5f, 0xb6, 0x66, 0xe0} \
}
class imgContainer : public imgIContainer,
public nsITimerCallback,
public imgIDecoderObserver
class imgContainer : public imgIContainer
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMGICONTAINER
NS_DECL_IMGIDECODEROBSERVER
NS_DECL_IMGICONTAINEROBSERVER
NS_DECL_NSITIMERCALLBACK
imgContainer();
virtual ~imgContainer();
private:
inline PRUint32 inlinedGetNumFrames() {
PRUint32 nframes;
mFrames.Count(&nframes);
return nframes;
}
inline nsresult inlinedGetFrameAt(PRUint32 index, gfxIImageFrame **_retval) {
// callers DO try to go past the end
nsISupports *_elem = mFrames.ElementAt(index);
if (!_elem) return NS_ERROR_FAILURE;
*_retval = NS_STATIC_CAST(gfxIImageFrame*, _elem);
return NS_OK;
}
inline nsresult inlinedGetCurrentFrame(gfxIImageFrame **_retval) {
if (mCompositingFrame) {
*_retval = mCompositingFrame;
NS_ADDREF(*_retval);
return NS_OK;
}
return inlinedGetFrameAt(mCurrentAnimationFrameIndex, _retval);
}
/* additional members */
nsSupportsArray mFrames;
nsSize mSize;
nsWeakPtr mObserver;
PRUint32 mCurrentDecodingFrameIndex; // 0 to numFrames-1
PRUint32 mCurrentAnimationFrameIndex; // 0 to numFrames-1
PRBool mCurrentFrameIsFinishedDecoding;
PRBool mDoneDecoding;
PRBool mAnimating;
PRUint16 mAnimationMode;
PRInt32 mLoopCount;
private:
// GIF specific bits
nsCOMPtr<nsITimer> mTimer;
// GIF animations will use the mCompositingFrame to composite images
// and just hand this back to the caller when it is time to draw the frame.
nsCOMPtr<gfxIImageFrame> mCompositingFrame;
nsCOMPtr<gfxIImageFrame> mCompositingPrevFrame;
// Private function for doing the frame compositing of animations and in cases
// where there is a backgound color and single frame placed withing a larger
// logical screen size. Smart GIF compressors may do this to save space.
void DoComposite(gfxIImageFrame** aFrameToUse, nsRect* aDirtyRect,
PRInt32 aPrevFrame, PRInt32 aNextFrame);
void BuildCompositeMask(gfxIImageFrame* aCompositingFrame, gfxIImageFrame* aOverlayFrame);
void ZeroMask(gfxIImageFrame *aCompositingFrame);
void ZeroMaskArea(gfxIImageFrame *aCompositingFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void OneMaskArea(gfxIImageFrame *aCompositingFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void BlackenFrame(gfxIImageFrame* aFrame);
void BlackenFrame(gfxIImageFrame *aFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
nsCOMPtr<gfxIImageFrame> mFrame;
};
#endif /* __imgContainer_h__ */