This commit is contained in:
Edward Lee 2010-08-13 21:52:38 -07:00
Родитель c15ca2c814 045a437294
Коммит fffd0774de
63 изменённых файлов: 1019 добавлений и 712 удалений

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

@ -156,7 +156,7 @@ nsImageLoadingContent::~nsImageLoadingContent()
*/
NS_IMETHODIMP
nsImageLoadingContent::FrameChanged(imgIContainer* aContainer,
nsIntRect* aDirtyRect)
const nsIntRect* aDirtyRect)
{
LOOP_OVER_OBSERVERS(FrameChanged(aContainer, aDirtyRect));
return NS_OK;

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

@ -108,7 +108,7 @@ nsStubImageDecoderObserver::OnDiscard(imgIRequest *aRequest)
NS_IMETHODIMP
nsStubImageDecoderObserver::FrameChanged(imgIContainer *aContainer,
nsIntRect * aDirtyRect)
const nsIntRect *aDirtyRect)
{
return NS_OK;
}

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

@ -5337,7 +5337,8 @@ public:
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIntRect *dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
// imgIContainerObserver
NS_IMETHOD OnStartContainer(imgIRequest *aRequest,
imgIContainer *aContainer);
@ -5606,10 +5607,10 @@ nsSVGFEImageElement::OnStopDecode(imgIRequest *aRequest,
NS_IMETHODIMP
nsSVGFEImageElement::FrameChanged(imgIContainer *aContainer,
nsIntRect *dirtyRect)
const nsIntRect *aDirtyRect)
{
nsresult rv =
nsImageLoadingContent::FrameChanged(aContainer, dirtyRect);
nsImageLoadingContent::FrameChanged(aContainer, aDirtyRect);
Invalidate();
return rv;
}

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

@ -626,12 +626,12 @@ protected:
template<size_t setlen>
struct ExtensionBitset {
ExtensionBitset() {
for (int i = 0; i < setlen; ++i)
for (size_t i = 0; i < setlen; ++i)
values[i] = false;
}
bool& operator[](const int index) {
NS_ASSERTION(index >= 0 && index < setlen, "out of range");
bool& operator[](size_t index) {
NS_ASSERTION(index < setlen, "out of range");
return values[index];
}

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

@ -196,7 +196,7 @@ NS_IMETHODIMP nsImageLoader::OnStopRequest(imgIRequest *aRequest,
}
NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
nsIntRect *dirtyRect)
const nsIntRect *aDirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
@ -206,7 +206,7 @@ NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
return NS_OK;
}
nsRect r = dirtyRect->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel());
nsRect r = aDirtyRect->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel());
DoRedraw(&r);

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

@ -91,7 +91,8 @@ public:
// incrementally in nsImageFrame.cpp.
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIntRect *dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
void Destroy();

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

@ -76,7 +76,8 @@ public:
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIntRect *dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *dirtyRect);
void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
@ -1504,7 +1505,7 @@ NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest,
}
NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer,
nsIntRect *aDirtyRect)
const nsIntRect *aDirtyRect)
{
// Invalidate the entire content area. Maybe it's not optimal but it's simple and
// always correct.
@ -1581,10 +1582,10 @@ NS_IMETHODIMP nsBulletListener::OnStopDecode(imgIRequest *aRequest,
}
NS_IMETHODIMP nsBulletListener::FrameChanged(imgIContainer *aContainer,
nsIntRect *dirtyRect)
const nsIntRect *aDirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
return mFrame->FrameChanged(aContainer, dirtyRect);
return mFrame->FrameChanged(aContainer, aDirtyRect);
}

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

@ -88,7 +88,7 @@ public:
nsresult aStatus,
const PRUnichar *aStatusArg);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
nsIntRect *aDirtyRect);
const nsIntRect *aDirtyRect);
/* get list item text, without '.' */
static PRBool AppendCounterText(PRInt32 aListStyleType,

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

@ -609,7 +609,8 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest,
}
nsresult
nsImageFrame::FrameChanged(imgIContainer *aContainer, nsIntRect *aDirtyRect)
nsImageFrame::FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect)
{
if (!GetStyleVisibility()->IsVisible()) {
return NS_OK;
@ -1878,7 +1879,7 @@ nsImageFrame::IconLoad::OnDiscard(imgIRequest *aRequest)
NS_IMETHODIMP
nsImageFrame::IconLoad::FrameChanged(imgIContainer *aContainer,
nsIntRect * aDirtyRect)
const nsIntRect *aDirtyRect)
{
nsTObserverArray<nsImageFrame*>::ForwardIterator iter(mIconObservers);
nsImageFrame *frame;
@ -1933,12 +1934,12 @@ NS_IMETHODIMP nsImageListener::OnStopDecode(imgIRequest *aRequest,
}
NS_IMETHODIMP nsImageListener::FrameChanged(imgIContainer *aContainer,
nsIntRect * dirtyRect)
const nsIntRect *aDirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
return mFrame->FrameChanged(aContainer, dirtyRect);
return mFrame->FrameChanged(aContainer, aDirtyRect);
}
static PRBool

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

@ -79,7 +79,8 @@ public:
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIntRect * dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *dirtyRect);
void SetFrame(nsImageFrame *frame) { mFrame = frame; }
@ -226,7 +227,8 @@ protected:
nsresult OnStopDecode(imgIRequest *aRequest,
nsresult aStatus,
const PRUnichar *aStatusArg);
nsresult FrameChanged(imgIContainer *aContainer, nsIntRect *aDirtyRect);
nsresult FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
private:
// random helpers

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

@ -264,7 +264,7 @@ random == 99850-1b.html 99850-1-ref.html # bug 471629
== 283686-2.html 283686-2-ref.html
== 283686-3.html about:blank
== 289384-1.xhtml 289384-ref.xhtml
fails-if(gtk2Widget) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 409329 for the non-Mac failures
fails-if(gtk2Widget||d2d) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 409329 for the non-Mac failures
asserts(1) == 290129-1.html 290129-1-ref.html # bug 315549/460637
== 291078-1.html 291078-1-ref.html
== 291078-2.html 291078-2-ref.html
@ -648,8 +648,8 @@ fails == 374927-1.html 374927-1-ref.html # Was broken by patch for bug 368600; f
random-if(cocoaWidget) == 379316-2.html 379316-2-ref.html # bug 379786
== 379328-1.html 379328-1-ref.html
== 379349-1a.xhtml 379349-1-ref.xhtml
== 379349-1b.xhtml 379349-1-ref.xhtml
== 379349-1c.xhtml 379349-1-ref.xhtml
fails-if(d2d) == 379349-1b.xhtml 379349-1-ref.xhtml # bug 578116
fails-if(d2d) == 379349-1c.xhtml 379349-1-ref.xhtml # bug 578116
== 379349-2a.xhtml 379349-2-ref.xhtml
== 379349-2b.xhtml 379349-2-ref.xhtml
== 379349-3a.xhtml 379349-3-ref.xhtml
@ -1270,8 +1270,8 @@ fails == 472020-2.xul 472020-2-ref.xul
!= 481948-2.html 481948-2-ref.html
random-if(winWidget) fails-if(gtk2Widget) == 481948-3.html 481948-3-ref.html # questionable test, see bug 488364
== 482398-1.html 482398-1-ref.html
== 482592-1a.xhtml 482592-1-ref.html
== 482592-1b.xhtml 482592-1-ref.html
random-if(d2d) == 482592-1a.xhtml 482592-1-ref.html # bug 586771
random-if(d2d) == 482592-1b.xhtml 482592-1-ref.html # bug 586771
== 482659-1a.html 482659-1-ref.html
== 482659-1b.html 482659-1-ref.html
== 482659-1c.html 482659-1-ref.html
@ -1385,7 +1385,7 @@ HTTP(..) == 518172-2b.html 518172-b-ref.html
== 521685-1.html 521685-1-ref.html
== 522632-1.html 522632-1-ref.html
== 523096-1.html 523096-1-ref.html
== 523468-1.html 523468-1-ref.html
random-if(d2d) == 523468-1.html 523468-1-ref.html
== 524175-1.html 524175-1-ref.html
== 526463-1.html 526463-1-ref.html
== 527464-1.html 527464-ref.html
@ -1427,7 +1427,7 @@ random-if(!haveTestPlugin) == 546071-1.html 546071-1-ref.html
== 551463-1.html 551463-1-ref.html
== 551699-1.html 551699-1-ref.html
== 552334-1.html 552334-1-ref.html
== 555388-1.html 555388-1-ref.html
random-if(d2d) == 555388-1.html 555388-1-ref.html
== 556661-1.html 556661-1-ref.html
== 557736-1.html 557736-1-ref.html
== 559284-1.html 559284-1-ref.html

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

@ -16,12 +16,12 @@
== linear-diagonal-8a.html linear-diagonal-8-ref.html
== linear-position-1a.html linear-position-1-ref.html
== linear-repeat-1a.html linear-repeat-1-ref.html
== linear-repeat-1b.html linear-repeat-1-ref.html
fails-if(d2d) == linear-repeat-1b.html linear-repeat-1-ref.html # bug 582236
== linear-repeat-1c.html linear-repeat-1-ref.html
== linear-repeat-1d.html linear-repeat-1-ref.html
fails-if(d2d) == linear-repeat-1d.html linear-repeat-1-ref.html # bug 582236
== linear-repeat-1e.html linear-repeat-1-ref.html
== linear-repeat-1f.html linear-repeat-1-ref.html
== linear-repeat-1g.html linear-repeat-1-ref.html
fails-if(d2d) == linear-repeat-1f.html linear-repeat-1-ref.html # bug 582236
fails-if(d2d) == linear-repeat-1g.html linear-repeat-1-ref.html # bug 582236
== linear-size-1a.html linear-size-1-ref.html
== linear-stops-1a.html linear-stops-1-ref.html
== linear-stops-1b.html linear-stops-1-ref.html
@ -39,7 +39,7 @@
== linear-zero-length-1c.html linear-zero-length-1-ref.html
== nostops.html about:blank
== onestop.html about:blank
== radial-1a.html radial-1-ref.html
random-if(d2d) == radial-1a.html radial-1-ref.html
== radial-2a.html radial-2-ref.html
== radial-2b.html radial-2-ref.html
== radial-position-1a.html radial-position-1-ref.html
@ -54,21 +54,21 @@
== radial-zero-length-1d.html radial-zero-length-1-ref.html
== radial-zero-length-1e.html radial-zero-length-1-ref.html
== radial-zero-length-1f.html radial-zero-length-1-ref.html
== repeating-linear-1a.html repeating-linear-1-ref.html
== repeating-linear-1b.html repeating-linear-1-ref.html
fails-if(d2d) == repeating-linear-1a.html repeating-linear-1-ref.html
fails-if(d2d) == repeating-linear-1b.html repeating-linear-1-ref.html
== repeating-linear-2a.html repeating-linear-2-ref.html
== repeating-radial-1a.html repeating-radial-1-ref.html
== repeating-radial-1b.html repeating-radial-1-ref.html
== repeating-radial-2a.html repeating-radial-2-ref.html
== twostops-1a.html twostops-1-ref.html
== twostops-1b.html twostops-1-ref.html
fails == twostops-1c.html twostops-1-ref.html # bug 524173
fails-if(!d2d) == twostops-1c.html twostops-1-ref.html # bug 524173
== twostops-1d.html twostops-1-ref.html
fails-if(!cocoaWidget) == twostops-1e.html twostops-1-ref.html # bug 524173
fails-if(!cocoaWidget&&!d2d) == twostops-1e.html twostops-1-ref.html # bug 524173
# from http://www.xanthir.com/:4bhipd by way of http://a-ja.net/newgrad.html
== aja-linear-1a.html aja-linear-1-ref.html
fails == aja-linear-1b.html aja-linear-1-ref.html # bug 526694
fails-if(!d2d) == aja-linear-1b.html aja-linear-1-ref.html # bug 526694
== aja-linear-1c.html aja-linear-1-ref.html
== aja-linear-1d.html aja-linear-1-ref.html
== aja-linear-1e.html aja-linear-1-ref.html
@ -77,7 +77,7 @@ fails == aja-linear-1b.html aja-linear-1-ref.html # bug 526694
== aja-linear-2a.html aja-linear-2-ref.html
== aja-linear-2b.html aja-linear-2-ref.html
fails == aja-linear-2c.html aja-linear-2-ref.html # bug 522607
fails == aja-linear-2d.html aja-linear-2-ref.html # bug 526694
fails-if(!d2d) == aja-linear-2d.html aja-linear-2-ref.html # bug 526694
== aja-linear-3a.html aja-linear-3-ref.html
== aja-linear-3b.html aja-linear-3-ref.html
== aja-linear-4a.html aja-linear-4-ref.html

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

@ -23,7 +23,7 @@ fails == quote-1e.html quote-1-ref.html # bug 509685
== quote-1e.html quote-1b.html
== quote-1f.html quote-1-ref.html
fails == dynamic-1.html dynamic-1-ref.html # bug 8253
== dynamic-2.html dynamic-2-ref.html
random-if(d2d) == dynamic-2.html dynamic-2-ref.html
== dynamic-3a.html dynamic-3-ref.html
random == dynamic-3b.html dynamic-3-ref.html
== 23605-1.html 23605-1-ref.html

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

@ -11,7 +11,7 @@
== element-paint-recursion.html element-paint-recursion-ref.html
HTTP(..) == element-paint-continuation.html element-paint-continuation-ref.html
== element-paint-transform-01.html element-paint-transform-01-ref.html
== element-paint-transform-02.html element-paint-transform-02-ref.html
random-if(d2d) == element-paint-transform-02.html element-paint-transform-02-ref.html # bug 587133
== element-paint-background-size-01.html element-paint-background-size-01-ref.html
== element-paint-background-size-02.html element-paint-background-size-02-ref.html
== element-paint-transform-repeated.html element-paint-transform-repeated-ref.html

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

@ -49,7 +49,7 @@
== filter-clipped-rect-01.svg pass.svg
== filter-filterRes-high-01.svg pass.svg
== filter-filterRes-high-02.svg pass.svg
== filter-filterRes-low-01.svg pass.svg
random-if(d2d) == filter-filterRes-low-01.svg pass.svg
== filter-inner-svg-01.svg pass.svg
== filter-inner-svg-02.svg pass.svg
== filter-inner-svg-03.svg pass.svg

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

@ -5,7 +5,7 @@
random == enveloped-tree-1.xhtml enveloped-tree-1-ref.xhtml # bug 470868
== promoted-tree-1.xhtml promoted-tree-1-ref.xhtml
random == moved-tree-1.xhtml moved-tree-1-ref.xhtml # bug 470868
random-if(cocoaWidget) == deferred-anim-1.xhtml deferred-anim-1-ref.xhtml # bug 470868
random-if(cocoaWidget||d2d) == deferred-anim-1.xhtml deferred-anim-1-ref.xhtml # bug 470868, bug 585484
== deferred-tree-1.xhtml deferred-tree-1-ref.xhtml
== deferred-tree-2a.xhtml deferred-tree-2-ref.xhtml
== deferred-tree-2b.xhtml deferred-tree-2-ref.xhtml

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

@ -27,8 +27,8 @@ fails == 156888-1.html 156888-1-ref.html # bug 484825
== 372641-1c.xhtml 372641-1-ref.xhtml
== 372649-1.html 372649-1-ref.html
== 373379-1.html 373379-1-ref.html
== 394402-1a.html 394402-1-ref.html
== 394402-1b.html 394402-1-ref.html
random-if(d2d) == 394402-1a.html 394402-1-ref.html # bug 586833
== 394402-1b.html 394402-1-ref.html # bug 586833
== 398095-1.html 398095-1-ref.html
== 407115-1.html 407115-1-ref.html
== 443616-1a.xhtml 443616-1-ref.html

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

@ -17,6 +17,6 @@ fails == underline-block-propagation-2-quirks.html underline-block-propagation-2
== underline-table-cell-standards.html underline-table-cell-standards-ref.html
!= underline-table-cell-standards.html underline-table-cell-standards-notref.html
fails == underline-block-propagation-standards.html underline-block-propagation-standards-ref.html # bug that decoration is drawn through non-text child (bug 428599)
== underline-block-propagation-2-standards.html underline-block-propagation-2-standards-ref.html
fails-if(d2d) == underline-block-propagation-2-standards.html underline-block-propagation-2-standards-ref.html # bug 585684
== text-decoration-zorder-1-standards.html text-decoration-zorder-1-ref.html
fails == text-decoration-zorder-1-quirks.html text-decoration-zorder-1-ref.html # bug 403524

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

@ -58,7 +58,8 @@ public:
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIntRect * dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD OnStartContainer(imgIRequest *aRequest,
imgIContainer *aContainer);
@ -402,7 +403,7 @@ NS_IMETHODIMP nsSVGImageListener::OnStopDecode(imgIRequest *aRequest,
}
NS_IMETHODIMP nsSVGImageListener::FrameChanged(imgIContainer *aContainer,
nsIntRect * dirtyRect)
const nsIntRect *aDirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;

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

@ -547,8 +547,8 @@ NS_IMETHODIMP nsImageBoxFrame::OnStopDecode(imgIRequest *request,
return NS_OK;
}
NS_IMETHODIMP nsImageBoxFrame::FrameChanged(imgIContainer *container,
nsIntRect *dirtyRect)
NS_IMETHODIMP nsImageBoxFrame::FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect)
{
nsBoxLayoutState state(PresContext());
this->Redraw(state);
@ -594,12 +594,12 @@ NS_IMETHODIMP nsImageBoxListener::OnStopDecode(imgIRequest *request,
return mFrame->OnStopDecode(request, status, statusArg);
}
NS_IMETHODIMP nsImageBoxListener::FrameChanged(imgIContainer *container,
nsIntRect *dirtyRect)
NS_IMETHODIMP nsImageBoxListener::FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
return mFrame->FrameChanged(container, dirtyRect);
return mFrame->FrameChanged(aContainer, aDirtyRect);
}

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

@ -59,7 +59,8 @@ public:
NS_IMETHOD OnStopDecode(imgIRequest *request, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD FrameChanged(imgIContainer *container, nsIntRect *dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
@ -121,7 +122,8 @@ public:
NS_IMETHOD OnStopDecode(imgIRequest *request,
nsresult status,
const PRUnichar *statusArg);
NS_IMETHOD FrameChanged(imgIContainer *container, nsIntRect *dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
virtual ~nsImageBoxFrame();

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

@ -72,7 +72,7 @@ NS_IMETHODIMP nsTreeImageListener::OnDataAvailable(imgIRequest *aRequest,
}
NS_IMETHODIMP nsTreeImageListener::FrameChanged(imgIContainer *aContainer,
nsIntRect *dirtyRect)
const nsIntRect *aDirtyRect)
{
Invalidate();
return NS_OK;

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

@ -75,7 +75,8 @@ public:
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, PRBool aCurrentFrame,
const nsIntRect *aRect);
// imgIContainerObserver (override nsStubImageDecoderObserver)
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIntRect *dirtyRect);
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
NS_IMETHOD AddCell(PRInt32 aIndex, nsITreeColumn* aCol);

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

@ -51,7 +51,7 @@
#include "nsXPCOMCID.h"
#include "nsServiceManagerUtils.h"
#include "imgContainer.h"
#include "RasterImage.h"
/* We end up pulling in windows.h because we eventually hit gfxWindowsSurface;
* windows.h defines LoadImage, so we have to #undef it or imgLoader::LoadImage
@ -65,7 +65,7 @@
#include "imgRequest.h"
#include "imgRequestProxy.h"
#include "imgTools.h"
#include "imgDiscardTracker.h"
#include "DiscardTracker.h"
#ifdef IMG_BUILD_DECODER_gif
// gif
@ -76,6 +76,7 @@
// bmp/ico
#include "nsBMPDecoder.h"
#include "nsICODecoder.h"
#include "nsIconDecoder.h"
#endif
#ifdef IMG_BUILD_DECODER_png
@ -98,8 +99,13 @@
#endif
// objects that just require generic constructors
namespace mozilla {
namespace imagelib {
NS_GENERIC_FACTORY_CONSTRUCTOR(RasterImage)
}
}
using namespace mozilla::imagelib;
NS_GENERIC_FACTORY_CONSTRUCTOR(imgContainer)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(imgLoader, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequestProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(imgTools)
@ -122,6 +128,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsJPEGEncoder)
// bmp
NS_GENERIC_FACTORY_CONSTRUCTOR(nsICODecoder)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBMPDecoder)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconDecoder)
#endif
#ifdef IMG_BUILD_DECODER_png
@ -134,9 +141,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPNGEncoder)
#endif
NS_DEFINE_NAMED_CID(NS_IMGLOADER_CID);
NS_DEFINE_NAMED_CID(NS_IMGCONTAINER_CID);
NS_DEFINE_NAMED_CID(NS_IMGREQUESTPROXY_CID);
NS_DEFINE_NAMED_CID(NS_IMGTOOLS_CID);
NS_DEFINE_NAMED_CID(NS_RASTERIMAGE_CID);
#ifdef IMG_BUILD_DECODER_gif
NS_DEFINE_NAMED_CID(NS_GIFDECODER2_CID);
#endif
@ -149,6 +156,7 @@ NS_DEFINE_NAMED_CID(NS_JPEGENCODER_CID);
#ifdef IMG_BUILD_DECODER_bmp
NS_DEFINE_NAMED_CID(NS_ICODECODER_CID);
NS_DEFINE_NAMED_CID(NS_BMPDECODER_CID);
NS_DEFINE_NAMED_CID(NS_ICONDECODER_CID);
#endif
#ifdef IMG_BUILD_DECODER_png
NS_DEFINE_NAMED_CID(NS_PNGDECODER_CID);
@ -160,9 +168,9 @@ NS_DEFINE_NAMED_CID(NS_PNGENCODER_CID);
static const mozilla::Module::CIDEntry kImageCIDs[] = {
{ &kNS_IMGLOADER_CID, false, NULL, imgLoaderConstructor, },
{ &kNS_IMGCONTAINER_CID, false, NULL, imgContainerConstructor, },
{ &kNS_IMGREQUESTPROXY_CID, false, NULL, imgRequestProxyConstructor, },
{ &kNS_IMGTOOLS_CID, false, NULL, imgToolsConstructor, },
{ &kNS_RASTERIMAGE_CID, false, NULL, RasterImageConstructor, },
#ifdef IMG_BUILD_DECODER_gif
{ &kNS_GIFDECODER2_CID, false, NULL, nsGIFDecoder2Constructor, },
#endif
@ -175,6 +183,7 @@ static const mozilla::Module::CIDEntry kImageCIDs[] = {
#ifdef IMG_BUILD_DECODER_bmp
{ &kNS_ICODECODER_CID, false, NULL, nsICODecoderConstructor, },
{ &kNS_BMPDECODER_CID, false, NULL, nsBMPDecoderConstructor, },
{ &kNS_ICONDECODER_CID, false, NULL, nsIconDecoderConstructor, },
#endif
#ifdef IMG_BUILD_DECODER_png
{ &kNS_PNGDECODER_CID, false, NULL, nsPNGDecoderConstructor, },
@ -187,10 +196,10 @@ static const mozilla::Module::CIDEntry kImageCIDs[] = {
static const mozilla::Module::ContractIDEntry kImageContracts[] = {
{ "@mozilla.org/image/cache;1", &kNS_IMGLOADER_CID },
{ "@mozilla.org/image/container;3", &kNS_IMGCONTAINER_CID },
{ "@mozilla.org/image/loader;1", &kNS_IMGLOADER_CID },
{ "@mozilla.org/image/request;1", &kNS_IMGREQUESTPROXY_CID },
{ "@mozilla.org/image/tools;1", &kNS_IMGTOOLS_CID },
{ "@mozilla.org/image/rasterimage;1", &kNS_RASTERIMAGE_CID },
#ifdef IMG_BUILD_DECODER_gif
{ "@mozilla.org/image/decoder;3?type=image/gif", &kNS_GIFDECODER2_CID },
#endif
@ -207,6 +216,7 @@ static const mozilla::Module::ContractIDEntry kImageContracts[] = {
{ "@mozilla.org/image/decoder;3?type=image/vnd.microsoft.icon", &kNS_ICODECODER_CID },
{ "@mozilla.org/image/decoder;3?type=image/bmp", &kNS_BMPDECODER_CID },
{ "@mozilla.org/image/decoder;3?type=image/x-ms-bmp", &kNS_BMPDECODER_CID },
{ "@mozilla.org/image/decoder;3?type=image/icon", &kNS_ICONDECODER_CID },
#endif
#ifdef IMG_BUILD_DECODER_png
{ "@mozilla.org/image/decoder;3?type=image/png", &kNS_PNGDECODER_CID },
@ -232,6 +242,7 @@ static const mozilla::Module::CategoryEntry kImageCategories[] = {
{ "Gecko-Content-Viewers", "image/vnd.microsoft.icon", "@mozilla.org/content/document-loader-factory;1" },
{ "Gecko-Content-Viewers", "image/bmp", "@mozilla.org/content/document-loader-factory;1" },
{ "Gecko-Content-Viewers", "image/x-ms-bmp", "@mozilla.org/content/document-loader-factory;1" },
{ "Gecko-Content-Viewers", "image/icon", "@mozilla.org/content/document-loader-factory;1" },
#endif
#ifdef IMG_BUILD_DECODER_png
{ "Gecko-Content-Viewers", "image/png", "@mozilla.org/content/document-loader-factory;1" },
@ -258,7 +269,7 @@ static void
imglib_Shutdown()
{
imgLoader::Shutdown();
imgDiscardTracker::Shutdown();
mozilla::imagelib::DiscardTracker::Shutdown();
}
static const mozilla::Module kImageModule = {

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

@ -50,6 +50,9 @@ MODULE_NAME = nsBMPModule
LIBXUL_LIBRARY = 1
CPPSRCS = nsBMPDecoder.cpp nsICODecoder.cpp
CPPSRCS = nsBMPDecoder.cpp nsICODecoder.cpp nsIconDecoder.cpp
# ns[BMP,ICO,Icon]Decoder.cpp all include RasterImage.h
LOCAL_INCLUDES += -I$(topsrcdir)/modules/libpr0n/src/
include $(topsrcdir)/config/rules.mk

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

@ -47,12 +47,15 @@
#include "nsIInputStream.h"
#include "nsIComponentManager.h"
#include "RasterImage.h"
#include "imgIContainerObserver.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "prlog.h"
using namespace mozilla::imagelib;
#ifdef PR_LOGGING
PRLogModuleInfo *gBMPLog = PR_NewLogModule("BMPDecoder");
#endif
@ -86,8 +89,12 @@ NS_IMETHODIMP nsBMPDecoder::Init(imgIContainer *aImage,
imgIDecoderObserver *aObserver,
PRUint32 aFlags)
{
NS_ABORT_IF_FALSE(aImage->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
PR_LOG(gBMPLog, PR_LOG_DEBUG, ("nsBMPDecoder::Init(%p)\n", aImage));
mImage = aImage;
mImage = static_cast<RasterImage*>(aImage);
mObserver = aObserver;
mFlags = aFlags;

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

@ -40,9 +40,8 @@
#ifndef _nsBMPDecoder_h
#define _nsBMPDecoder_h
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "imgIDecoder.h"
#include "imgIContainer.h"
#include "imgIDecoderObserver.h"
#include "gfxColor.h"
@ -140,6 +139,12 @@ enum ERLEState {
eRLEStateAbsoluteModePadded ///< As above, but another byte of data has to be read as padding
};
namespace mozilla {
namespace imagelib {
class RasterImage;
} // namespace imagelib
} // namespace mozilla
/**
* Decoder for BMP-Files, as used by Windows and OS/2
*/
@ -160,7 +165,7 @@ private:
nsCOMPtr<imgIDecoderObserver> mObserver;
nsCOMPtr<imgIContainer> mImage;
nsRefPtr<mozilla::imagelib::RasterImage> mImage;
PRUint32 mFlags;
PRUint32 mPos;

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

@ -47,6 +47,7 @@
#include "nsIInputStream.h"
#include "nsIComponentManager.h"
#include "RasterImage.h"
#include "imgIContainerObserver.h"
#include "nsIInterfaceRequestor.h"
@ -55,7 +56,7 @@
#include "nsIProperties.h"
#include "nsISupportsPrimitives.h"
#include "nsAutoPtr.h"
using namespace mozilla::imagelib;
NS_IMPL_ISUPPORTS1(nsICODecoder, imgIDecoder)
@ -93,8 +94,11 @@ NS_IMETHODIMP nsICODecoder::Init(imgIContainer *aImage,
imgIDecoderObserver *aObserver,
PRUint32 aFlags)
{
NS_ABORT_IF_FALSE(aImage->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
// Grab parameters
mImage = aImage;
mImage = static_cast<RasterImage*>(aImage);
mObserver = aObserver;
mFlags = aFlags;
@ -280,18 +284,15 @@ nsICODecoder::Write(const char* aBuffer, PRUint32 aCount)
}
if (mIsCursor) {
nsCOMPtr<nsIProperties> props(do_QueryInterface(mImage));
if (props) {
nsCOMPtr<nsISupportsPRUint32> intwrapx = do_CreateInstance("@mozilla.org/supports-PRUint32;1");
nsCOMPtr<nsISupportsPRUint32> intwrapy = do_CreateInstance("@mozilla.org/supports-PRUint32;1");
nsCOMPtr<nsISupportsPRUint32> intwrapx = do_CreateInstance("@mozilla.org/supports-PRUint32;1");
nsCOMPtr<nsISupportsPRUint32> intwrapy = do_CreateInstance("@mozilla.org/supports-PRUint32;1");
if (intwrapx && intwrapy) {
intwrapx->SetData(mDirEntry.mXHotspot);
intwrapy->SetData(mDirEntry.mYHotspot);
if (intwrapx && intwrapy) {
intwrapx->SetData(mDirEntry.mXHotspot);
intwrapy->SetData(mDirEntry.mYHotspot);
props->Set("hotspotX", intwrapx);
props->Set("hotspotY", intwrapy);
}
mImage->Set("hotspotX", intwrapx);
mImage->Set("hotspotY", intwrapy);
}
}

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

@ -41,7 +41,7 @@
#ifndef _nsICODecoder_h
#define _nsICODecoder_h
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "imgIDecoder.h"
#include "imgIContainer.h"
#include "imgIDecoderObserver.h"
@ -51,6 +51,12 @@
#define NS_ICODECODER_CID \
{ 0xcb3ede1a, 0xfa5, 0x4e27, { 0xaa, 0xfe, 0xf, 0x78, 0x1, 0xe5, 0xa1, 0xf1 } }
namespace mozilla {
namespace imagelib {
class RasterImage;
} // namespace imagelib
} // namespace mozilla
struct IconDirEntry
{
PRUint8 mWidth;
@ -88,7 +94,7 @@ private:
PRUint32 CalcAlphaRowSize();
private:
nsCOMPtr<imgIContainer> mImage;
nsRefPtr<mozilla::imagelib::RasterImage> mImage;
nsCOMPtr<imgIDecoderObserver> mObserver;
PRUint32 mFlags;

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

@ -40,7 +40,7 @@
#include "nsIconDecoder.h"
#include "nsIInputStream.h"
#include "imgIContainer.h"
#include "RasterImage.h"
#include "imgIContainerObserver.h"
#include "nspr.h"
#include "nsIComponentManager.h"
@ -50,6 +50,8 @@
#include "nsIInterfaceRequestorUtils.h"
#include "ImageErrors.h"
using namespace mozilla::imagelib;
NS_IMPL_THREADSAFE_ADDREF(nsIconDecoder)
NS_IMPL_THREADSAFE_RELEASE(nsIconDecoder)
@ -85,7 +87,10 @@ NS_IMETHODIMP nsIconDecoder::Init(imgIContainer *aImage,
{
// Grab parameters
mImage = aImage;
NS_ABORT_IF_FALSE(aImage->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
mImage = static_cast<RasterImage*>(aImage);
mObserver = aObserver;
mFlags = aFlags;

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

@ -56,6 +56,11 @@
{ 0x99, 0x5, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } \
}
namespace mozilla {
namespace imagelib {
class RasterImage;
} // namespace imagelib
} // namespace mozilla
//////////////////////////////////////////////////////////////////////////////////////////////
// The icon decoder is a decoder specifically tailored for loading icons
@ -85,7 +90,7 @@ public:
nsIconDecoder();
virtual ~nsIconDecoder();
nsCOMPtr<imgIContainer> mImage;
nsRefPtr<mozilla::imagelib::RasterImage> mImage;
nsCOMPtr<imgIDecoderObserver> mObserver;
PRUint32 mFlags;
PRUint8 mWidth;

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

@ -51,7 +51,7 @@ LIBXUL_LIBRARY = 1
CPPSRCS = nsGIFDecoder2.cpp
# nsGIFDecoder2.cpp includes imgContainer.h
# nsGIFDecoder2.cpp includes RasterImage.h
LOCAL_INCLUDES += -I$(topsrcdir)/modules/libpr0n/src
include $(topsrcdir)/config/rules.mk

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

@ -81,6 +81,7 @@ mailing address.
#include "nsIInputStream.h"
#include "nsIComponentManager.h"
#include "imgIContainerObserver.h"
#include "RasterImage.h"
#include "gfxColor.h"
#include "gfxPlatform.h"
@ -144,8 +145,11 @@ NS_IMETHODIMP nsGIFDecoder2::Init(imgIContainer *aImage,
imgIDecoderObserver *aObserver,
PRUint32 aFlags)
{
NS_ABORT_IF_FALSE(aImage->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
// Store parameters
mImageContainer = aImage;
mImageContainer = static_cast<mozilla::imagelib::RasterImage*>(aImage);
mObserver = aObserver;
mFlags = aFlags;

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

@ -56,6 +56,12 @@
{0xa7, 0xf8, 0xca, 0x39, 0x7e, 0x01, 0x79, 0xc4} \
}
namespace mozilla {
namespace imagelib {
class RasterImage;
} // namespace imagelib
} // namespace mozilla
//////////////////////////////////////////////////////////////////////
// nsGIFDecoder2 Definition
@ -85,7 +91,9 @@ private:
inline int ClearCode() const { return 1 << mGIFStruct.datasize; }
nsCOMPtr<imgIContainer> mImageContainer;
// XXXdholbert This member variable should probably be renamed to "mImage"
// for consistency with nsPNGDecoder
nsRefPtr<mozilla::imagelib::RasterImage> mImageContainer;
nsCOMPtr<imgIDecoderObserver> mObserver;
PRUint32 mFlags;
PRInt32 mCurrentRow;

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

@ -83,18 +83,6 @@ CPPSRCS = \
nsIconProtocolHandler.cpp \
$(NULL)
ifneq (,$(filter qt gtk2,$(MOZ_WIDGET_TOOLKIT)))
USE_ICON_DECODER = 1
endif
ifeq (,$(filter-out Darwin OS2 BeOS,$(OS_ARCH)))
USE_ICON_DECODER = 1
endif
ifdef USE_ICON_DECODER
CPPSRCS += nsIconDecoder.cpp
DEFINES += -DUSE_ICON_DECODER
endif
XPIDLSRCS = nsIIconURI.idl
SHARED_LIBRARY_LIBS = $(PLATFORM)/$(LIB_PREFIX)imgicon$(PLATFORM)_s.$(LIB_SUFFIX)

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

@ -40,9 +40,6 @@
#include "mozilla/ModuleUtils.h"
#include "nsServiceManagerUtils.h"
#ifdef USE_ICON_DECODER
#include "nsIconDecoder.h"
#endif
#include "nsIconProtocolHandler.h"
#include "nsIconURI.h"
#include "nsIconChannel.h"
@ -53,38 +50,21 @@
*/
#define NS_ICONPROTOCOL_CID { 0xd0f9db12, 0x249c, 0x11d5, { 0x99, 0x5, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } }
#ifdef USE_ICON_DECODER
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconDecoder)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconProtocolHandler)
#ifdef USE_ICON_DECODER
static const char gIconMimeType[] = "image/icon";
NS_DEFINE_NAMED_CID(NS_ICONDECODER_CID);
#endif
NS_DEFINE_NAMED_CID(NS_ICONPROTOCOL_CID);
static const mozilla::Module::CIDEntry kIconCIDs[] = {
#ifdef USE_ICON_DECODER
{ &kNS_ICONDECODER_CID, false, NULL, nsIconDecoderConstructor },
#endif
{ &kNS_ICONPROTOCOL_CID, false, NULL, nsIconProtocolHandlerConstructor },
{ NULL }
};
static const mozilla::Module::ContractIDEntry kIconContracts[] = {
#ifdef USE_ICON_DECODER
{ "@mozilla.org/image/decoder;3?type=image/icon", &kNS_ICONDECODER_CID },
#endif
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-icon", &kNS_ICONPROTOCOL_CID },
{ NULL }
};
static const mozilla::Module::CategoryEntry kIconCategories[] = {
#ifdef USE_ICON_DECODER
{ "Gecko-Content-Viewers", gIconMimeType, "@mozilla.org/content/document-loader-factory;1" },
#endif
{ NULL }
};

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

@ -53,5 +53,8 @@ CPPSRCS = nsJPEGDecoder.cpp
CSRCS = iccjpeg.c
# nsJPEGDecoder.cpp includes RasterImage.h
LOCAL_INCLUDES += -I$(topsrcdir)/modules/libpr0n/src/
include $(topsrcdir)/config/rules.mk

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

@ -56,6 +56,8 @@
#include "gfxPlatform.h"
using namespace mozilla::imagelib;
extern "C" {
#include "iccjpeg.h"
@ -145,9 +147,11 @@ NS_IMETHODIMP nsJPEGDecoder::Init(imgIContainer *aImage,
imgIDecoderObserver *aObserver,
PRUint32 aFlags)
{
NS_ABORT_IF_FALSE(aImage->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
/* Grab the parameters. */
mImage = aImage;
mImage = static_cast<RasterImage*>(aImage);
mObserver = aObserver;
mFlags = aFlags;

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

@ -41,11 +41,16 @@
#ifndef nsJPEGDecoder_h__
#define nsJPEGDecoder_h__
#include "RasterImage.h"
/* On Windows systems, RasterImage.h brings in 'windows.h', which defines INT32.
* But the jpeg decoder has its own definition of INT32. To avoid build issues,
* we need to undefine the version from 'windows.h'. */
#undef INT32
#include "imgIDecoder.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "imgIContainer.h"
#include "imgIDecoderObserver.h"
#include "nsIInputStream.h"
#include "nsIPipe.h"
@ -81,6 +86,12 @@ typedef enum {
JPEG_ERROR
} jstate;
namespace mozilla {
namespace imagelib {
class RasterImage;
} // namespace imagelib
} // namespace mozilla
class nsJPEGDecoder : public imgIDecoder
{
public:
@ -96,7 +107,7 @@ protected:
nsresult OutputScanlines(PRBool* suspend);
public:
nsCOMPtr<imgIContainer> mImage;
nsRefPtr<mozilla::imagelib::RasterImage> mImage;
nsCOMPtr<imgIDecoderObserver> mObserver;
PRUint32 mFlags;

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

@ -50,7 +50,6 @@ LIBXUL_LIBRARY = 1
EXTRA_DSO_LIBS = gkgfx
CPPSRCS = nsPNGDecoder.cpp
ifneq (,$(filter png,$(MOZ_IMG_ENCODERS)))
@ -61,5 +60,7 @@ ifneq (,$(filter png,$(MOZ_IMG_DECODERS)))
DEFINES += -DMOZ_PNG_READ
endif
include $(topsrcdir)/config/rules.mk
# nsPNGDecoder.cpp includes RasterImage.h
LOCAL_INCLUDES += -I$(topsrcdir)/modules/libpr0n/src/
include $(topsrcdir)/config/rules.mk

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

@ -49,6 +49,7 @@
#include "nsIComponentManager.h"
#include "nsIInputStream.h"
#include "RasterImage.h"
#include "imgIContainerObserver.h"
#include "nsIInterfaceRequestorUtils.h"
@ -60,6 +61,8 @@
#include "gfxPlatform.h"
using namespace mozilla::imagelib;
static void PNGAPI info_callback(png_structp png_ptr, png_infop info_ptr);
static void PNGAPI row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass);
@ -191,18 +194,18 @@ void nsPNGDecoder::SetAnimFrameInfo()
if (dispose_op == PNG_DISPOSE_OP_PREVIOUS)
mImage->SetFrameDisposalMethod(numFrames - 1,
imgIContainer::kDisposeRestorePrevious);
RasterImage::kDisposeRestorePrevious);
else if (dispose_op == PNG_DISPOSE_OP_BACKGROUND)
mImage->SetFrameDisposalMethod(numFrames - 1,
imgIContainer::kDisposeClear);
RasterImage::kDisposeClear);
else
mImage->SetFrameDisposalMethod(numFrames - 1,
imgIContainer::kDisposeKeep);
RasterImage::kDisposeKeep);
if (blend_op == PNG_BLEND_OP_SOURCE)
mImage->SetFrameBlendMethod(numFrames - 1, imgIContainer::kBlendSource);
mImage->SetFrameBlendMethod(numFrames - 1, RasterImage::kBlendSource);
/*else // 'over' is the default
mImage->SetFrameBlendMethod(numFrames - 1, imgIContainer::kBlendOver); */
mImage->SetFrameBlendMethod(numFrames - 1, RasterImage::kBlendOver); */
}
#endif
@ -264,8 +267,10 @@ NS_IMETHODIMP nsPNGDecoder::Init(imgIContainer *aImage,
116, 73, 77, 69, '\0', /* tIME */
122, 84, 88, 116, '\0'}; /* zTXt */
#endif
NS_ABORT_IF_FALSE(aImage->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
mImage = aImage;
mImage = static_cast<RasterImage*>(aImage);
mObserver = aObserver;
mFlags = aFlags;

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

@ -61,6 +61,12 @@
{0xbe, 0x07, 0xd1, 0x6e, 0xeb, 0x4c, 0x50, 0xed} \
}
namespace mozilla {
namespace imagelib {
class RasterImage;
} // namespace imagelib
} // namespace mozilla
class nsPNGDecoder : public imgIDecoder
{
public:
@ -79,7 +85,7 @@ public:
void NotifyDone(PRBool aSuccess);
public:
nsCOMPtr<imgIContainer> mImage;
nsRefPtr<mozilla::imagelib::RasterImage> mImage;
nsCOMPtr<imgIDecoderObserver> mObserver;
PRUint32 mFlags;

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

@ -71,7 +71,7 @@ native gfxGraphicsFilter(gfxPattern::GraphicsFilter);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, uuid(e6984403-1253-48fa-8a16-a350f76ab6c9)]
[scriptable, uuid(362e5b5f-f677-49e0-9a3c-03249c794624)]
interface imgIContainer : nsISupports
{
/**
@ -84,6 +84,25 @@ interface imgIContainer : nsISupports
*/
readonly attribute PRInt32 height;
/**
* Enumerated values for the 'type' attribute (below).
*/
const unsigned short TYPE_RASTER = 0;
const unsigned short TYPE_VECTOR = 1;
/**
* The type of this image (one of the TYPE_* values above).
*/
readonly attribute unsigned short type;
/**
* Direct C++ accessor for 'type' attribute, for convenience.
*/
%{C++
virtual PRUint16 GetType() = 0;
%}
/**
* Whether this image is animated. You can only be guaranteed that querying
* this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest.
@ -210,64 +229,6 @@ interface imgIContainer : nsISupports
*/
void unlockImage();
/************ Internal libpr0n use only below here. *****************/
/**
* Flags for imgIContainer initialization.
*
* Meanings:
*
* INIT_FLAG_NONE: Lack of flags
*
* INIT_FLAG_DISCARDABLE: The container should be discardable
*
* INIT_FLAG_DECODE_ON_DRAW: The container should decode on draw rather than
* decoding on load.
*
* INIT_FLAG_MULTIPART: The container will be used to display a stream of
* images in a multipart channel. If this flag is set, INIT_FLAG_DISCARDABLE
* and INIT_FLAG_DECODE_ON_DRAW must not be set.
*/
const long INIT_FLAG_NONE = 0x0;
const long INIT_FLAG_DISCARDABLE = 0x1;
const long INIT_FLAG_DECODE_ON_DRAW = 0x2;
const long INIT_FLAG_MULTIPART = 0x4;
/**
* Creates a new image container.
*
* @param aObserver Observer to send decoder and animation notifications to.
* @param aMimeType The mimetype of the image.
* @param aFlags Initialization flags of the INIT_FLAG_* variety.
*/
void init(in imgIDecoderObserver aObserver,
in string aMimeType,
in PRUint32 aFlags);
/**
* "Disposal" method indicates how the image should be handled before the
* subsequent image is displayed.
* Don't change these without looking at the implementations using them,
* struct gif_struct::disposal_method and gif_write() in particular.
*/
const long kDisposeClearAll = -1; // Clear the whole image, revealing
// what was there before the gif displayed
const long kDisposeNotSpecified = 0; // Leave frame, let new frame draw on top
const long kDisposeKeep = 1; // Leave frame, let new frame draw on top
const long kDisposeClear = 2; // Clear the frame's area, revealing bg
const long kDisposeRestorePrevious = 3; // Restore the previous (composited) frame
/*
* "Blend" method indicates how the current image is combined with the
* previous image.
*/
const long kBlendSource = 0; // All color components of the frame, including alpha,
// overwrite the current contents of the frame's
// output buffer region
const long kBlendOver = 1; // The frame should be composited onto the output buffer
// based on its alpha, using a simple OVER operation
/**
* Animation mode Constants
* 0 = normal
@ -280,100 +241,8 @@ interface imgIContainer : nsISupports
attribute unsigned short animationMode;
/**
* The rectangle defining the location and size of the currently displayed frame.
* Should be an attribute, but can't be because of reference/pointer
* conflicts with native types in xpidl.
*/
[noscript] void getCurrentFrameRect(in nsIntRect aFrameRect);
/**
* The index of the current frame that would be drawn if the image was to be
* drawn now.
*/
readonly attribute unsigned long currentFrameIndex;
/**
* The total number of frames in this image.
*/
readonly attribute unsigned long numFrames;
/**
* The size, in bytes, occupied by the significant data portions of the image.
* This includes both compressed source data and decoded frames.
*/
readonly attribute unsigned long dataSize;
void setFrameDisposalMethod(in unsigned long framenumber, in PRInt32 aDisposalMethod);
void setFrameBlendMethod(in unsigned long framenumber, in PRInt32 aBlendMethod);
void setFrameTimeout(in unsigned long framenumber, in PRInt32 aTimeout);
void setFrameHasNoAlpha(in unsigned long framenumber);
/**
* Sets the size of the container. This should only be called by the decoder. This function may be called multiple
* times, but will throw an error if subsequent calls do not match the first.
*/
[noscript] void setSize(in long aWidth, in long aHeight);
/**
* Create or re-use a frame at index aFrameNum. It is an error to call this with aFrameNum not in the range [0, numFrames].
*/
[noscript] void ensureCleanFrame(in unsigned long aFramenum, in PRInt32 aX, in PRInt32 aY, in PRInt32 aWidth, in PRInt32 aHeight, in gfxImageFormat aFormat,
[array, size_is(imageLength)] out PRUint8 imageData, out unsigned long imageLength);
/**
* Adds to the end of the list of frames.
*/
[noscript] void appendFrame(in PRInt32 aX, in PRInt32 aY, in PRInt32 aWidth, in PRInt32 aHeight, in gfxImageFormat aFormat,
[array, size_is(imageLength)] out PRUint8 imageData, out unsigned long imageLength);
[noscript] void appendPalettedFrame(in PRInt32 aX, in PRInt32 aY, in PRInt32 aWidth, in PRInt32 aHeight, in gfxImageFormat aFormat, in PRUint8 aPaletteDepth,
[array, size_is(imageLength)] out PRUint8 imageData, out unsigned long imageLength,
[array, size_is(paletteLength)] out PRUint32 paletteData, out unsigned long paletteLength);
[noscript] void frameUpdated(in unsigned long framenum, in nsIntRect aNewRect);
/* notification when the current frame is done decoding */
void endFrameDecode(in unsigned long framenumber);
/* notification that the entire image has been decoded */
void decodingComplete();
/* Methods to control animation */
void startAnimation();
void stopAnimation();
void resetAnimation();
/**
* number of times to loop the image.
* @note -1 means forever.
*/
attribute long loopCount;
/* Add compressed source data to the imgContainer.
*
* The decoder will use this data, either immediately or at draw time, do
* decode the image.
*/
[noscript] void addSourceData([array, size_is(aCount), const] in char data,
in unsigned long aCount);
/* Called after the all the source data has been added with addSourceData. */
[noscript] void sourceDataComplete();
/* Called for multipart images when there's a new source image to add. */
[noscript] void newSourceData();
/**
* A hint of the number of bytes of source data that the image contains. If
* called early on, this can help reduce copying and reallocations by
* appropriately preallocating the source data buffer.
*
* We take this approach rather than having the source data management code do
* something more complicated (like chunklisting) because HTTP is by far the
* dominant source of images, and the Content-Length header is quite reliable.
* Thus, pre-allocation simplifies code and reduces the total number of
* allocations.
*/
void setSourceSizeHint(in unsigned long sizeHint);
};

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

@ -52,8 +52,9 @@ interface imgIContainer;
* @author Stuart Parmenter <pavlov@netscape.com>
* @version 0.1
*/
[scriptable, uuid(e214c295-4b8e-4aa9-9907-45289e57295b)]
[scriptable, uuid(aa2068c1-6b91-4f52-8603-487b14ac5f04)]
interface imgIContainerObserver : nsISupports
{
[noscript] void frameChanged(in imgIContainer aContainer, in nsIntRect aDirtyRect);
[noscript] void frameChanged(in imgIContainer aContainer,
[const] in nsIntRect aDirtyRect);
};

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

@ -41,21 +41,24 @@
#include "nsComponentManagerUtils.h"
#include "nsITimer.h"
#include "imgContainer.h"
#include "imgDiscardTracker.h"
#include "RasterImage.h"
#include "DiscardTracker.h"
namespace mozilla {
namespace imagelib {
static PRBool sInitialized = PR_FALSE;
static PRBool sTimerOn = PR_FALSE;
static PRUint32 sMinDiscardTimeoutMs = 10000; /* Default if pref unreadable. */
static nsITimer *sTimer = nsnull;
static struct imgDiscardTrackerNode sHead, sSentinel, sTail;
static struct DiscardTrackerNode sHead, sSentinel, sTail;
/*
* Puts an image in the back of the tracker queue. If the image is already
* in the tracker, this removes it first.
*/
nsresult
imgDiscardTracker::Reset(imgDiscardTrackerNode *node)
DiscardTracker::Reset(DiscardTrackerNode *node)
{
nsresult rv;
#ifdef DEBUG
@ -98,7 +101,7 @@ imgDiscardTracker::Reset(imgDiscardTrackerNode *node)
* Removes a node from the tracker. No-op if the node is currently untracked.
*/
void
imgDiscardTracker::Remove(imgDiscardTrackerNode *node)
DiscardTracker::Remove(DiscardTrackerNode *node)
{
NS_ABORT_IF_FALSE(node != nsnull, "Can't pass null node");
@ -121,7 +124,7 @@ imgDiscardTracker::Remove(imgDiscardTrackerNode *node)
* Initialize the tracker.
*/
nsresult
imgDiscardTracker::Initialize()
DiscardTracker::Initialize()
{
nsresult rv;
@ -152,7 +155,7 @@ imgDiscardTracker::Initialize()
* Shut down the tracker, deallocating the timer.
*/
void
imgDiscardTracker::Shutdown()
DiscardTracker::Shutdown()
{
if (sTimer) {
sTimer->Cancel();
@ -165,7 +168,7 @@ imgDiscardTracker::Shutdown()
* Sets the minimum timeout.
*/
void
imgDiscardTracker::ReloadTimeout()
DiscardTracker::ReloadTimeout()
{
nsresult rv;
@ -196,7 +199,7 @@ imgDiscardTracker::ReloadTimeout()
* Enables the timer. No-op if the timer is already running.
*/
nsresult
imgDiscardTracker::TimerOn()
DiscardTracker::TimerOn()
{
// Nothing to do if the timer's already on.
if (sTimerOn)
@ -214,7 +217,7 @@ imgDiscardTracker::TimerOn()
* Disables the timer. No-op if the timer isn't running.
*/
void
imgDiscardTracker::TimerOff()
DiscardTracker::TimerOff()
{
// Nothing to do if the timer's already off.
if (!sTimerOn)
@ -231,9 +234,9 @@ imgDiscardTracker::TimerOff()
* list.
*/
void
imgDiscardTracker::TimerCallback(nsITimer *aTimer, void *aClosure)
DiscardTracker::TimerCallback(nsITimer *aTimer, void *aClosure)
{
imgDiscardTrackerNode *node;
DiscardTrackerNode *node;
// Remove and discard everything before the sentinel
for (node = sSentinel.prev; node != &sHead; node = sSentinel.prev) {
@ -250,3 +253,6 @@ imgDiscardTracker::TimerCallback(nsITimer *aTimer, void *aClosure)
if (sSentinel.prev == &sHead)
TimerOff();
}
} // namespace imagelib
} // namespace mozilla

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

@ -35,30 +35,33 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __imgDiscardTracker_h__
#define __imgDiscardTracker_h__
#ifndef mozilla_imagelib_DiscardTracker_h_
#define mozilla_imagelib_DiscardTracker_h_
#define DISCARD_TIMEOUT_PREF "image.mem.min_discard_timeout_ms"
class imgContainer;
class nsITimer;
// Struct to make an imgContainer insertable into the tracker list. This
// is embedded within each imgContainer object, and we do 'this->curr = this'
// on imgContainer construction. Thus, an imgContainer must always call
// imgDiscardTracker::Remove() in its destructor to avoid having the tracker
namespace mozilla {
namespace imagelib {
class RasterImage;
// Struct to make a RasterImage insertable into the tracker list. This
// is embedded within each RasterImage object, and we do 'this->curr = this'
// on RasterImage construction. Thus, a RasterImage must always call
// DiscardTracker::Remove() in its destructor to avoid having the tracker
// point to bogus memory.
struct imgDiscardTrackerNode
struct DiscardTrackerNode
{
// Pointer to the imgContainer that this node tracks
imgContainer *curr;
// Pointer to the RasterImage that this node tracks
RasterImage *curr;
// Pointers to the previous and next nodes in the list
imgDiscardTrackerNode *prev, *next;
DiscardTrackerNode *prev, *next;
};
/**
* This static class maintains a linked list of imgContainer nodes. When Reset()
* This static class maintains a linked list of RasterImage nodes. When Reset()
* is called, the node is removed from its position in the list (if it was there
* before) and appended to the end. When Remove() is called, the node is removed
* from the list. The timer fires once every MIN_DISCARD_TIMEOUT_MS ms. When it
@ -66,12 +69,11 @@ struct imgDiscardTrackerNode
* itself to the end of the list. Thus, the discard timeout varies between
* MIN_DISCARD_TIMEOUT_MS and 2*MIN_DISCARD_TIMEOUT_MS.
*/
class imgDiscardTracker
class DiscardTracker
{
public:
static nsresult Reset(struct imgDiscardTrackerNode *node);
static void Remove(struct imgDiscardTrackerNode *node);
static nsresult Reset(struct DiscardTrackerNode *node);
static void Remove(struct DiscardTrackerNode *node);
static void Shutdown();
static void ReloadTimeout();
private:
@ -81,4 +83,7 @@ class imgDiscardTracker
static void TimerCallback(nsITimer *aTimer, void *aClosure);
};
#endif /* __imgDiscardTracker_h__ */
} // namespace imagelib
} // namespace mozilla
#endif /* mozilla_imagelib_DiscardTracker_h_ */

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

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010.
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Image.h"
namespace mozilla {
namespace imagelib {
// Constructor
Image::Image() :
mStatusTracker(this),
mInitialized(PR_FALSE)
{
}
} // namespace imagelib
} // namespace mozilla

121
modules/libpr0n/src/Image.h Normal file
Просмотреть файл

@ -0,0 +1,121 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010.
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZILLA_IMAGELIB_IMAGE_H_
#define MOZILLA_IMAGELIB_IMAGE_H_
#include "imgIContainer.h"
#include "imgStatusTracker.h"
#include "prtypes.h"
namespace mozilla {
namespace imagelib {
class Image : public imgIContainer
{
public:
imgStatusTracker& GetStatusTracker() { return mStatusTracker; }
PRBool IsInitialized() const { return mInitialized; }
/**
* Flags for Image initialization.
*
* Meanings:
*
* INIT_FLAG_NONE: Lack of flags
*
* INIT_FLAG_DISCARDABLE: The container should be discardable
*
* INIT_FLAG_DECODE_ON_DRAW: The container should decode on draw rather than
* decoding on load.
*
* INIT_FLAG_MULTIPART: The container will be used to display a stream of
* images in a multipart channel. If this flag is set, INIT_FLAG_DISCARDABLE
* and INIT_FLAG_DECODE_ON_DRAW must not be set.
*/
static const PRUint32 INIT_FLAG_NONE = 0x0;
static const PRUint32 INIT_FLAG_DISCARDABLE = 0x1;
static const PRUint32 INIT_FLAG_DECODE_ON_DRAW = 0x2;
static const PRUint32 INIT_FLAG_MULTIPART = 0x4;
/**
* Creates a new image container.
*
* @param aObserver Observer to send decoder and animation notifications to.
* @param aMimeType The mimetype of the image.
* @param aFlags Initialization flags of the INIT_FLAG_* variety.
*/
virtual nsresult Init(imgIDecoderObserver* aObserver,
const char* aMimeType,
PRUint32 aFlags) = 0;
/**
* The rectangle defining the location and size of the currently displayed
* frame. Should be an attribute, but can't be because of reference/pointer
* conflicts with native types in xpidl.
*/
virtual nsresult GetCurrentFrameRect(nsIntRect& aRect) = 0;
/**
* The index of the current frame that would be drawn if the image was to be
* drawn now.
*/
virtual nsresult GetCurrentFrameIndex(PRUint32* aCurrentFrameIdx) = 0;
/**
* The total number of frames in this image.
*/
virtual nsresult GetNumFrames(PRUint32* aNumFrames) = 0;
/**
* The size, in bytes, occupied by the significant data portions of the image.
* This includes both compressed source data and decoded frames.
*/
virtual nsresult GetDataSize(PRUint32* aDataSize) = 0;
protected:
Image();
// Member data shared by all implementations of this abstract class
imgStatusTracker mStatusTracker;
PRPackedBool mInitialized; // Have we been initalized?
};
} // namespace imagelib
} // namespace mozilla
#endif // MOZILLA_IMAGELIB_IMAGE_H_

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

@ -51,13 +51,14 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \
imgContainer.cpp \
Image.cpp \
DiscardTracker.cpp \
RasterImage.cpp \
imgFrame.cpp \
imgLoader.cpp \
imgRequest.cpp \
imgRequestProxy.cpp \
imgTools.cpp \
imgDiscardTracker.cpp \
imgStatusTracker.cpp \
$(NULL)

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

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

@ -41,8 +41,8 @@
* ***** END LICENSE BLOCK ***** */
/** @file
* This file declares the imgContainer class, which
* handles static and animated image containers.
* This file declares the RasterImage class, which
* handles static and animated rasterized images.
*
* @author Stuart Parmenter <pavlov@netscape.com>
* @author Chris Saari <saari@netscape.com>
@ -50,23 +50,25 @@
* @author Andrew Smith <asmith15@learn.senecac.on.ca>
*/
#ifndef __imgContainer_h__
#define __imgContainer_h__
#ifndef mozilla_imagelib_RasterImage_h_
#define mozilla_imagelib_RasterImage_h_
#include "Image.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "imgIContainer.h"
#include "imgIDecoder.h"
#include "nsIProperties.h"
#include "nsITimer.h"
#include "nsWeakReference.h"
#include "nsTArray.h"
#include "imgFrame.h"
#include "nsThreadUtils.h"
#include "imgDiscardTracker.h"
#include "imgStatusTracker.h"
#include "DiscardTracker.h"
#define NS_IMGCONTAINER_CID \
class imgIDecoder;
class nsIInputStream;
#define NS_RASTERIMAGE_CID \
{ /* 376ff2c1-9bf6-418a-b143-3340c00112f7 */ \
0x376ff2c1, \
0x9bf6, \
@ -80,7 +82,7 @@
*
* @par A Quick Walk Through
* The decoder initializes this class and calls AppendFrame() to add a frame.
* Once imgContainer detects more than one frame, it starts the animation
* Once RasterImage detects more than one frame, it starts the animation
* with StartAnimation().
*
* @par
@ -105,12 +107,12 @@
* See comments in DoComposite() for more information and optimizations.
*
* @par
* The rest of the imgContainer specific functions are used by DoComposite to
* The rest of the RasterImage specific functions are used by DoComposite to
* destroy the old frame and build the new one.
*
* @note
* <li> "Mask", "Alpha", and "Alpha Level" are interchangeable phrases in
* respects to imgContainer.
* respects to RasterImage.
*
* @par
* <li> GIFs never have more than a 1 bit alpha.
@ -136,11 +138,16 @@
* because the first two have public setters and the observer we only get
* in Init().
*/
namespace mozilla {
namespace imagelib {
class imgDecodeWorker;
class imgContainer : public imgIContainer,
public nsITimerCallback,
public nsIProperties,
public nsSupportsWeakReference
class RasterImage : public mozilla::imagelib::Image,
public nsITimerCallback,
public nsIProperties,
public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
@ -148,13 +155,26 @@ public:
NS_DECL_NSITIMERCALLBACK
NS_DECL_NSIPROPERTIES
imgContainer();
virtual ~imgContainer();
RasterImage();
virtual ~RasterImage();
static NS_METHOD WriteToContainer(nsIInputStream* in, void* closure,
const char* fromRawSegment,
PRUint32 toOffset, PRUint32 count,
PRUint32 *writeCount);
// C++-only version of imgIContainer::GetType, for convenience
virtual PRUint16 GetType() { return imgIContainer::TYPE_RASTER; }
// Methods inherited from Image
nsresult Init(imgIDecoderObserver *aObserver,
const char* aMimeType,
PRUint32 aFlags);
nsresult GetCurrentFrameRect(nsIntRect& aRect);
nsresult GetCurrentFrameIndex(PRUint32* aCurrentFrameIdx);
nsresult GetNumFrames(PRUint32* aNumFrames);
nsresult GetDataSize(PRUint32* aDataSize);
// Raster-specific methods
static NS_METHOD WriteToRasterImage(nsIInputStream* aIn, void* aClosure,
const char* aFromRawSegment,
PRUint32 aToOffset, PRUint32 aCount,
PRUint32* aWriteCount);
PRUint32 GetDecodedDataSize();
PRUint32 GetSourceDataSize();
@ -162,8 +182,107 @@ public:
/* Triggers discarding. */
void Discard();
imgStatusTracker& GetStatusTracker() { return mStatusTracker; }
PRBool IsInitialized() const { return mInitialized; }
/* Callbacks for decoders */
nsresult SetFrameDisposalMethod(PRUint32 aFrameNum,
PRInt32 aDisposalMethod);
nsresult SetFrameTimeout(PRUint32 aFrameNum, PRInt32 aTimeout);
nsresult SetFrameBlendMethod(PRUint32 aFrameNum, PRInt32 aBlendMethod);
nsresult SetFrameHasNoAlpha(PRUint32 aFrameNum);
/**
* Sets the size of the container. This should only be called by the
* decoder. This function may be called multiple times, but will throw an
* error if subsequent calls do not match the first.
*/
nsresult SetSize(PRInt32 aWidth, PRInt32 aHeight);
nsresult EnsureCleanFrame(PRUint32 aFramenum, PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight,
gfxASurface::gfxImageFormat aFormat,
PRUint8** imageData,
PRUint32* imageLength);
/**
* Adds to the end of the list of frames.
*/
nsresult AppendFrame(PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight,
gfxASurface::gfxImageFormat aFormat,
PRUint8** imageData,
PRUint32* imageLength);
nsresult AppendPalettedFrame(PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight,
gfxASurface::gfxImageFormat aFormat,
PRUint8 aPaletteDepth,
PRUint8** imageData,
PRUint32* imageLength,
PRUint32** paletteData,
PRUint32* paletteLength);
nsresult FrameUpdated(PRUint32 aFrameNum, nsIntRect& aUpdatedRect);
/* notification when the current frame is done decoding */
nsresult EndFrameDecode(PRUint32 aFrameNum);
/* notification that the entire image has been decoded */
nsresult DecodingComplete();
/**
* Number of times to loop the image.
* @note -1 means forever.
*/
void SetLoopCount(PRInt32 aLoopCount);
/* Add compressed source data to the imgContainer.
*
* The decoder will use this data, either immediately or at draw time, to
* decode the image.
*
* XXX This method's only caller (WriteToContainer) ignores the return
* value. Should this just return void?
*/
nsresult AddSourceData(const char *aBuffer, PRUint32 aCount);
/* Called after the all the source data has been added with addSourceData. */
virtual nsresult SourceDataComplete();
/* Called for multipart images when there's a new source image to add. */
virtual nsresult NewSourceData();
/**
* A hint of the number of bytes of source data that the image contains. If
* called early on, this can help reduce copying and reallocations by
* appropriately preallocating the source data buffer.
*
* We take this approach rather than having the source data management code do
* something more complicated (like chunklisting) because HTTP is by far the
* dominant source of images, and the Content-Length header is quite reliable.
* Thus, pre-allocation simplifies code and reduces the total number of
* allocations.
*/
virtual nsresult SetSourceSizeHint(PRUint32 sizeHint);
// "Blend" method indicates how the current image is combined with the
// previous image.
enum {
// All color components of the frame, including alpha, overwrite the current
// contents of the frame's output buffer region
kBlendSource = 0,
// The frame should be composited onto the output buffer based on its alpha,
// using a simple OVER operation
kBlendOver
};
enum {
kDisposeClearAll = -1, // Clear the whole image, revealing
// what was there before the gif displayed
kDisposeNotSpecified, // Leave frame, let new frame draw on top
kDisposeKeep, // Leave frame, let new frame draw on top
kDisposeClear, // Clear the frame's area, revealing bg
kDisposeRestorePrevious // Restore the previous (composited) frame
};
private:
struct Anim
@ -316,7 +435,7 @@ private: // data
// IMPORTANT: if you use mAnim in a method, call EnsureImageIsDecoded() first to ensure
// that the frames actually exist (they may have been discarded to save memory, or
// we maybe decoding on draw).
imgContainer::Anim* mAnim;
RasterImage::Anim* mAnim;
//! See imgIContainer for mode constants
PRUint16 mAnimationMode;
@ -329,16 +448,14 @@ private: // data
// Discard members
PRUint32 mLockCount;
imgDiscardTrackerNode mDiscardTrackerNode;
DiscardTrackerNode mDiscardTrackerNode;
// Source data members
nsTArray<char> mSourceData;
nsCString mSourceDataMimeType;
imgStatusTracker mStatusTracker;
friend class imgDecodeWorker;
friend class imgDiscardTracker;
friend class DiscardTracker;
// Decoder and friends
nsCOMPtr<imgIDecoder> mDecoder;
@ -350,7 +467,6 @@ private: // data
PRPackedBool mHasSize:1; // Has SetSize() been called?
PRPackedBool mDecodeOnDraw:1; // Decoding on draw?
PRPackedBool mMultipart:1; // Multipart?
PRPackedBool mInitialized:1; // Have we been initalized?
PRPackedBool mDiscardable:1; // Is container discardable?
PRPackedBool mHasSourceData:1; // Do we have source data?
@ -389,6 +505,8 @@ private: // data
};
// XXXdholbert These helper classes should move to be inside the
// scope of the RasterImage class.
// Decoding Helper Class
//
// We use this class to mimic the interactivity benefits of threading
@ -432,6 +550,7 @@ class imgDecodeRequestor : public nsRunnable
nsWeakPtr mContainer;
};
} // namespace imagelib
} // namespace mozilla
#endif /* __imgContainer_h__ */
#endif /* mozilla_imagelib_RasterImage_h_ */

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

@ -39,8 +39,16 @@
* ***** END LICENSE BLOCK ***** */
#include "imgLoader.h"
#include "imgContainer.h"
#include "imgRequestProxy.h"
#include "RasterImage.h"
/* We end up pulling in windows.h because we eventually hit gfxWindowsSurface;
* windows.h defines LoadImage, so we have to #undef it or imgLoader::LoadImage
* gets changed.
* This #undef needs to be in multiple places because we don't always pull
* headers in in the same order.
*/
#undef LoadImage
#include "nsCOMPtr.h"
@ -62,9 +70,6 @@
#include "netCore.h"
#include "imgRequest.h"
#include "imgRequestProxy.h"
#include "nsURILoader.h"
#include "ImageLogging.h"
@ -85,6 +90,8 @@
#include "mozilla/FunctionTimer.h"
using namespace mozilla::imagelib;
#if defined(DEBUG_pavlov) || defined(DEBUG_timeless)
#include "nsISimpleEnumerator.h"
#include "nsXPCOM.h"
@ -92,6 +99,7 @@
#include "nsXPIDLString.h"
#include "nsComponentManagerUtils.h"
static void PrintImageDecoders()
{
nsCOMPtr<nsIComponentRegistrar> compMgr;
@ -217,14 +225,14 @@ public:
}
nsRefPtr<imgRequest> req = entry->GetRequest();
imgContainer *container = (imgContainer*) req->mImage.get();
if (!container)
RasterImage *image = static_cast<RasterImage*>(req->mImage.get());
if (!image)
return PL_DHASH_NEXT;
if (rtype & RAW_BIT) {
arg->value += container->GetSourceDataSize();
arg->value += image->GetSourceDataSize();
} else {
arg->value += container->GetDecodedDataSize();
arg->value += image->GetDecodedDataSize();
}
return PL_DHASH_NEXT;

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

@ -38,6 +38,9 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef imgLoader_h__
#define imgLoader_h__
#include "imgILoader.h"
#include "imgICache.h"
#include "nsWeakReference.h"
@ -54,14 +57,6 @@
#include "prlock.h"
#endif
/* We end up pulling in windows.h because we eventually hit gfxWindowsSurface;
* windows.h defines LoadImage, so we have to #undef it or imgLoader::LoadImage
* gets changed.
* This #undef needs to be in multiple places because we don't always pull
* headers in in the same order.
*/
#undef LoadImage
class imgRequest;
class imgRequestProxy;
class imgIRequest;
@ -410,3 +405,5 @@ private:
static imgLoader sImgLoader;
};
#endif // imgLoader_h__

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

@ -50,7 +50,7 @@
#include "imgLoader.h"
#include "imgRequestProxy.h"
#include "imgContainer.h"
#include "RasterImage.h"
#include "imgILoader.h"
#include "ImageLogging.h"
@ -82,11 +82,14 @@
#include "nsIPrefService.h"
#include "nsIPrefBranch2.h"
#include "imgDiscardTracker.h"
#include "DiscardTracker.h"
#include "nsAsyncRedirectVerifyHelper.h"
#define DISCARD_PREF "image.mem.discardable"
#define DECODEONDRAW_PREF "image.mem.decodeondraw"
#define SVG_MIMETYPE "image/svg+xml"
using namespace mozilla::imagelib;
/* Kept up to date by a pref observer. */
static PRBool gDecodeOnDraw = PR_FALSE;
@ -116,7 +119,7 @@ ReloadPrefs(nsIPrefBranch *aBranch)
gDecodeOnDraw = decodeondraw;
// Discard timeout
imgDiscardTracker::ReloadTimeout();
mozilla::imagelib::DiscardTracker::ReloadTimeout();
}
// Observer
@ -200,8 +203,11 @@ nsresult imgRequest::Init(nsIURI *aURI,
NS_ABORT_IF_FALSE(aChannel, "No channel");
mProperties = do_CreateInstance("@mozilla.org/properties;1");
nsCOMPtr<imgIContainer> comImg = do_CreateInstance("@mozilla.org/image/container;3");
mImage = static_cast<imgContainer*>(comImg.get());
// XXXdholbert For SVG support, this mImage-construction will need to happen
// later -- *after* we know image mimetype.
nsCOMPtr<imgIContainer> comImg = do_CreateInstance("@mozilla.org/image/rasterimage;1");
mImage = static_cast<Image*>(comImg.get());
mURI = aURI;
mKeyURI = aKeyURI;
@ -334,6 +340,12 @@ nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus, PRBoo
return NS_OK;
}
PRBool imgRequest::IsReusable(void *aCacheId)
{
return (mImage && mImage->GetStatusTracker().IsLoading()) ||
(aCacheId == mCacheId);
}
void imgRequest::CancelAndAbort(nsresult aStatus)
{
LOG_SCOPE(gImgLog, "imgRequest::CancelAndAbort");
@ -512,7 +524,7 @@ imgRequest::RequestDecode()
/* [noscript] void frameChanged (in imgIContainer container, in nsIntRect dirtyRect); */
NS_IMETHODIMP imgRequest::FrameChanged(imgIContainer *container,
nsIntRect * dirtyRect)
const nsIntRect *dirtyRect)
{
LOG_SCOPE(gImgLog, "imgRequest::FrameChanged");
@ -659,7 +671,7 @@ NS_IMETHODIMP imgRequest::OnStopDecode(imgIRequest *aRequest,
aStatusArg);
}
// ImgContainer and everything below it is completely correct and
// RasterImage and everything below it is completely correct and
// bulletproof about its handling of decoder notifications.
// Unfortunately, here and above we have to make some gross and
// inappropriate use of things to get things to work without
@ -668,7 +680,7 @@ NS_IMETHODIMP imgRequest::OnStopDecode(imgIRequest *aRequest,
// the time being), OnStopDecode is just a companion to OnStopRequest
// that signals success or failure of the _load_ (not the _decode_).
// Within imgStatusTracker, we ignore OnStopDecode notifications from the
// decoder and container and generate our own every time we send
// decoder and RasterImage and generate our own every time we send
// OnStopRequest. From within SendStopDecode, we actually send
// OnStopContainer. For more information, see bug 435296.
@ -717,10 +729,10 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
"Already have an image for non-multipart request");
// If we're multipart, and our image is initialized, fix things up for another round
if (mIsMultiPartChannel && mImage->IsInitialized()) {
// Inform the container that we have new source data
mImage->NewSourceData();
if (mIsMultiPartChannel && mImage->IsInitialized() &&
mImage->GetType() == imgIContainer::TYPE_RASTER) {
// Inform the RasterImage that we have new source data
static_cast<RasterImage*>(mImage.get())->NewSourceData();
}
/*
@ -855,10 +867,11 @@ NS_IMETHODIMP imgRequest::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt,
// Tell the image that it has all of the source data. Note that this can
// trigger a failure, since the image might be waiting for more non-optional
// data and this is the point where we break the news that it's not coming.
if (mImage->IsInitialized()) {
if (mImage->IsInitialized() &&
mImage->GetType() == imgIContainer::TYPE_RASTER) {
// Notify the image
nsresult rv = mImage->SourceDataComplete();
nsresult rv = static_cast<RasterImage*>(mImage.get())->SourceDataComplete();
// If we got an error in the SourceDataComplete() call, we don't want to
// proceed as if nothing bad happened. However, we also want to give
@ -906,7 +919,10 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
nsresult rv;
if (!mGotData) {
PRUint16 imageType;
if (mGotData) {
imageType = mImage->GetType();
} else {
LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |First time through... finding mimetype|");
mGotData = PR_TRUE;
@ -944,6 +960,10 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
LOG_MSG(gImgLog, "imgRequest::OnDataAvailable", "Got content type from the channel");
}
/* now we have mimetype, so we can infer the image type that we want */
imageType = mContentType.EqualsLiteral(SVG_MIMETYPE) ?
imgIContainer::TYPE_VECTOR : imgIContainer::TYPE_RASTER;
/* set our mimetype as a property */
nsCOMPtr<nsISupportsCString> contentType(do_CreateInstance("@mozilla.org/supports-cstring;1"));
if (contentType) {
@ -973,7 +993,7 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::OnDataAvailable", "content type", mContentType.get());
//
// Figure out if our container initialization flags
// Figure out our Image initialization flags
//
// We default to the static globals
@ -1000,38 +1020,41 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
isDiscardable = doDecodeOnDraw = PR_FALSE;
// We have all the information we need
PRUint32 containerFlags = imgIContainer::INIT_FLAG_NONE;
PRUint32 imageFlags = Image::INIT_FLAG_NONE;
if (isDiscardable)
containerFlags |= imgIContainer::INIT_FLAG_DISCARDABLE;
imageFlags |= Image::INIT_FLAG_DISCARDABLE;
if (doDecodeOnDraw)
containerFlags |= imgIContainer::INIT_FLAG_DECODE_ON_DRAW;
imageFlags |= Image::INIT_FLAG_DECODE_ON_DRAW;
if (mIsMultiPartChannel)
containerFlags |= imgIContainer::INIT_FLAG_MULTIPART;
imageFlags |= Image::INIT_FLAG_MULTIPART;
// Initialize the image that we created in OnStartRequest(). This
// instantiates a decoder behind the scenes, so if we don't have a decoder
// for this mimetype we'll find out about it here.
rv = mImage->Init(this, mContentType.get(), containerFlags);
rv = mImage->Init(this, mContentType.get(), imageFlags);
if (NS_FAILED(rv)) { // Probably bad mimetype
this->Cancel(rv);
return NS_BINDING_ABORTED;
}
/* Use content-length as a size hint for http channels. */
if (httpChannel) {
nsCAutoString contentLength;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-length"),
contentLength);
if (NS_SUCCEEDED(rv)) {
PRInt32 len = contentLength.ToInteger(&rv);
if (imageType == imgIContainer::TYPE_RASTER) {
/* Use content-length as a size hint for http channels. */
if (httpChannel) {
nsCAutoString contentLength;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-length"),
contentLength);
if (NS_SUCCEEDED(rv)) {
PRInt32 len = contentLength.ToInteger(&rv);
// Pass anything usable on so that the imgContainer can preallocate its
// source buffer
if (len > 0) {
PRUint32 sizeHint = (PRUint32) len;
sizeHint = PR_MIN(sizeHint, 20000000); /* Bound by something reasonable */
mImage->SetSourceSizeHint(sizeHint);
// Pass anything usable on so that the RasterImage can preallocate
// its source buffer
if (len > 0) {
PRUint32 sizeHint = (PRUint32) len;
sizeHint = PR_MIN(sizeHint, 20000000); /* Bound by something reasonable */
RasterImage* rasterImage = static_cast<RasterImage*>(mImage.get());
rasterImage->SetSourceSizeHint(sizeHint);
}
}
}
}
@ -1042,19 +1065,19 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
}
}
// WriteToContainer always consumes everything it gets
// WriteToRasterImage always consumes everything it gets
PRUint32 bytesRead;
rv = inStr->ReadSegments(imgContainer::WriteToContainer,
rv = inStr->ReadSegments(RasterImage::WriteToRasterImage,
static_cast<void*>(mImage),
count, &bytesRead);
if (NS_FAILED(rv)) {
PR_LOG(gImgLog, PR_LOG_WARNING,
("[this=%p] imgRequest::OnDataAvailable -- "
"copy to container failed\n", this));
"copy to RasterImage failed\n", this));
this->Cancel(NS_IMAGELIB_ERROR_FAILURE);
return NS_BINDING_ABORTED;
}
NS_ABORT_IF_FALSE(bytesRead == count, "WriteToContainer should consume everything!");
NS_ABORT_IF_FALSE(bytesRead == count, "WriteToRasterImage should consume everything!");
return NS_OK;
}

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

@ -41,7 +41,6 @@
#ifndef imgRequest_h__
#define imgRequest_h__
#include "imgContainer.h"
#include "imgIDecoder.h"
#include "imgIDecoderObserver.h"
@ -61,7 +60,6 @@
#include "nsWeakReference.h"
#include "ImageErrors.h"
#include "imgIRequest.h"
#include "imgContainer.h"
#include "nsIAsyncVerifyRedirectCallback.h"
class imgCacheValidator;
@ -71,6 +69,12 @@ class imgCacheEntry;
class imgMemoryReporter;
class imgRequestNotifyRunnable;
namespace mozilla {
namespace imagelib {
class Image;
} // namespace imagelib
} // namespace mozilla
class imgRequest : public imgIDecoderObserver,
public nsIStreamListener,
public nsSupportsWeakReference,
@ -103,17 +107,14 @@ public:
// a request is "reusable" if it has already been loaded, or it is
// currently being loaded on the same event queue as the new request
// being made...
PRBool IsReusable(void *aCacheId) {
return (mImage && mImage->GetStatusTracker().IsLoading()) ||
(aCacheId == mCacheId);
}
PRBool IsReusable(void *aCacheId);
// Cancel, but also ensure that all work done in Init() is undone. Call this
// only when the channel has failed to open, and so calling Cancel() on it
// won't be sufficient.
void CancelAndAbort(nsresult aStatus);
// Methods that get forwarded to the imgContainer, or deferred until it's
// Methods that get forwarded to the Image, or deferred until it's
// instantiated.
nsresult LockImage();
nsresult UnlockImage();
@ -195,7 +196,7 @@ private:
// The URI we are keyed on in the cache.
nsCOMPtr<nsIURI> mKeyURI;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsRefPtr<imgContainer> mImage;
nsRefPtr<mozilla::imagelib::Image> mImage;
nsCOMPtr<nsIProperties> mProperties;
nsCOMPtr<nsISupports> mSecurityInfo;
nsCOMPtr<nsIChannel> mChannel;

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

@ -49,11 +49,14 @@
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "Image.h"
#include "ImageErrors.h"
#include "ImageLogging.h"
#include "nspr.h"
using namespace mozilla::imagelib;
NS_IMPL_ISUPPORTS4(imgRequestProxy, imgIRequest, nsIRequest,
nsISupportsPriority, nsISecurityInfoProvider)
@ -109,7 +112,7 @@ imgRequestProxy::~imgRequestProxy()
}
}
nsresult imgRequestProxy::Init(imgRequest* request, nsILoadGroup* aLoadGroup, imgContainer* aImage,
nsresult imgRequestProxy::Init(imgRequest* request, nsILoadGroup* aLoadGroup, Image* aImage,
nsIURI* aURI, imgIDecoderObserver* aObserver)
{
NS_PRECONDITION(!mOwner && !mListener, "imgRequestProxy is already initialized");
@ -510,7 +513,8 @@ NS_IMETHODIMP imgRequestProxy::GetHasTransferredData(PRBool* hasData)
/** imgIContainerObserver methods **/
void imgRequestProxy::FrameChanged(imgIContainer *container, nsIntRect * dirtyRect)
void imgRequestProxy::FrameChanged(imgIContainer *container,
const nsIntRect *dirtyRect)
{
LOG_FUNC(gImgLog, "imgRequestProxy::FrameChanged");
@ -709,7 +713,7 @@ imgRequestProxy::GetStaticRequest(imgIRequest** aReturn)
if (NS_FAILED(rv))
return rv;
nsRefPtr<imgContainer> frame = static_cast<imgContainer*>(currentFrame.get());
nsRefPtr<Image> frame = static_cast<Image*>(currentFrame.get());
// Create a static imgRequestProxy with our new extracted frame.
nsRefPtr<imgRequestProxy> req = new imgRequestProxy();

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

@ -44,7 +44,6 @@
#include "imgIDecoderObserver.h"
#include "nsISecurityInfoProvider.h"
#include "imgIContainer.h"
#include "imgIDecoder.h"
#include "nsIRequestObserver.h"
#include "nsIChannel.h"
@ -67,6 +66,12 @@
class imgRequestNotifyRunnable;
class imgStatusNotifyRunnable;
namespace mozilla {
namespace imagelib {
class Image;
} // namespace imagelib
} // namespace mozilla
class imgRequestProxy : public imgIRequest, public nsISupportsPriority, public nsISecurityInfoProvider
{
public:
@ -81,7 +86,8 @@ public:
// Callers to Init or ChangeOwner are required to call NotifyListener after
// (although not immediately after) doing so.
nsresult Init(imgRequest *request, nsILoadGroup *aLoadGroup, imgContainer* aImage,
nsresult Init(imgRequest *request, nsILoadGroup *aLoadGroup,
mozilla::imagelib::Image* aImage,
nsIURI* aURI, imgIDecoderObserver *aObserver);
nsresult ChangeOwner(imgRequest *aNewOwner); // this will change mOwner. Do not call this if the previous
@ -158,7 +164,8 @@ protected:
void OnDiscard ();
/* non-virtual imgIContainerObserver methods */
void FrameChanged(imgIContainer *aContainer, nsIntRect * aDirtyRect);
void FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
/* non-virtual sort-of-nsIRequestObserver methods */
void OnStartRequest();
@ -190,7 +197,7 @@ private:
// The image we represent. Is null until data has been received, and is then
// set by imgRequest.
nsRefPtr<imgContainer> mImage;
nsRefPtr<mozilla::imagelib::Image> mImage;
// Our principal. Is null until data has been received from the channel, and
// is then set by imgRequest.

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

@ -42,8 +42,11 @@
#include "imgRequest.h"
#include "imgIContainer.h"
#include "imgRequestProxy.h"
#include "Image.h"
#include "ImageLogging.h"
using namespace mozilla::imagelib;
static nsresult
GetResultFromImageStatus(PRUint32 aStatus)
{
@ -54,7 +57,7 @@ GetResultFromImageStatus(PRUint32 aStatus)
return NS_OK;
}
imgStatusTracker::imgStatusTracker(imgIContainer* aImage)
imgStatusTracker::imgStatusTracker(Image* aImage)
: mImage(aImage),
mState(0),
mImageStatus(imgIRequest::STATUS_NONE),
@ -169,7 +172,7 @@ class imgStatusNotifyRunnable : public nsRunnable
imgStatusTracker mStatus;
// We have to hold on to a reference to the tracker's image, just in case
// it goes away while we're in the event queue.
nsRefPtr<imgIContainer> mImage;
nsRefPtr<Image> mImage;
nsRefPtr<imgRequestProxy> mProxy;
};
@ -424,7 +427,8 @@ imgStatusTracker::SendDiscard(imgRequestProxy* aProxy)
/* non-virtual imgIContainerObserver methods */
void
imgStatusTracker::RecordFrameChanged(imgIContainer* aContainer, nsIntRect* aDirtyRect)
imgStatusTracker::RecordFrameChanged(imgIContainer* aContainer,
const nsIntRect* aDirtyRect)
{
// no bookkeeping necessary here - this is only for in-frame updates, which we
// don't fire while we're recording
@ -432,7 +436,7 @@ imgStatusTracker::RecordFrameChanged(imgIContainer* aContainer, nsIntRect* aDirt
void
imgStatusTracker::SendFrameChanged(imgRequestProxy* aProxy, imgIContainer* aContainer,
nsIntRect* aDirtyRect)
const nsIntRect* aDirtyRect)
{
if (!aProxy->NotificationsDeferred())
aProxy->FrameChanged(aContainer, aDirtyRect);

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

@ -46,6 +46,12 @@ class imgRequest;
class imgRequestProxy;
class imgStatusNotifyRunnable;
class imgRequestNotifyRunnable;
namespace mozilla {
namespace imagelib {
class Image;
} // namespace imagelib
} // namespace mozilla
#include "nsCOMPtr.h"
#include "nsIRunnable.h"
@ -63,9 +69,9 @@ enum {
/*
* The image status tracker is a class that encapsulates all the loading and
* decoding status about an image (imgContainer), and makes it possible to send
* notifications to imgRequestProxys, both synchronously (i.e., the status now)
* and asynchronously (the status later).
* decoding status about an Image, and makes it possible to send notifications
* to imgRequestProxys, both synchronously (i.e., the status now) and
* asynchronously (the status later).
*
* When a new proxy needs to be notified of the current state of an image, call
* the Notify() method on this class with the relevant proxy as its argument,
@ -78,7 +84,7 @@ public:
// aImage is the image that this status tracker will pass to the
// imgRequestProxys in SyncNotify() and EmulateRequestFinished(), and must be
// alive as long as this instance is, because we hold a weak reference to it.
imgStatusTracker(imgIContainer* aImage);
imgStatusTracker(mozilla::imagelib::Image* aImage);
imgStatusTracker(const imgStatusTracker& aOther);
// Schedule an asynchronous "replaying" of all the notifications that would
@ -149,8 +155,10 @@ public:
void SendDiscard(imgRequestProxy* aProxy);
/* non-virtual imgIContainerObserver methods */
void RecordFrameChanged(imgIContainer* aContainer, nsIntRect* aDirtyRect);
void SendFrameChanged(imgRequestProxy* aProxy, imgIContainer* aContainer, nsIntRect* aDirtyRect);
void RecordFrameChanged(imgIContainer* aContainer,
const nsIntRect* aDirtyRect);
void SendFrameChanged(imgRequestProxy* aProxy, imgIContainer* aContainer,
const nsIntRect* aDirtyRect);
/* non-virtual sort-of-nsIRequestObserver methods */
void RecordStartRequest();
@ -164,9 +172,9 @@ private:
nsCOMPtr<nsIRunnable> mRequestRunnable;
// A weak pointer to the imgIContainer, because the container owns us, and we
// A weak pointer to the Image, because it owns us, and we
// can't create a cycle.
imgIContainer* mImage;
mozilla::imagelib::Image* mImage;
PRUint32 mState;
nsresult mImageStatus;
PRPackedBool mHadLastPart;

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

@ -52,7 +52,9 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsStreamUtils.h"
#include "nsNetUtil.h"
#include "imgContainer.h"
#include "RasterImage.h"
using namespace mozilla::imagelib;
/* ========== imgITools implementation ========== */
@ -76,20 +78,24 @@ NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
imgIContainer **aContainer)
{
nsresult rv;
RasterImage* image; // convenience alias for *aContainer
NS_ENSURE_ARG_POINTER(aInStr);
// If the caller didn't provide a container, create one
if (!*aContainer) {
*aContainer = new imgContainer();
if (!*aContainer)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aContainer);
// If the caller didn't provide an imgIContainer, create one.
if (*aContainer) {
NS_ABORT_IF_FALSE((*aContainer)->GetType() == imgIContainer::TYPE_RASTER,
"wrong type of imgIContainer for decoding into");
image = static_cast<RasterImage*>(*aContainer);
} else {
*aContainer = image = new RasterImage();
NS_ADDREF(image);
}
// Initialize the container. If we're using the one from the caller, we
// require that it not be initialized
// Initialize the Image. If we're using the one from the caller, we
// require that it not be initialized.
nsCString mimeType(aMimeType);
rv = (*aContainer)->Init(nsnull, mimeType.get(), imgIContainer::INIT_FLAG_NONE);
rv = image->Init(nsnull, mimeType.get(), Image::INIT_FLAG_NONE);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> inStream = aInStr;
@ -105,17 +111,18 @@ NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
rv = inStream->Available(&length);
NS_ENSURE_SUCCESS(rv, rv);
// Send the source data to the container. WriteToContainer always
// Send the source data to the Image. WriteToRasterImage always
// consumes everything it gets.
PRUint32 bytesRead;
rv = inStream->ReadSegments(imgContainer::WriteToContainer,
static_cast<void*>(*aContainer),
rv = inStream->ReadSegments(RasterImage::WriteToRasterImage,
static_cast<void*>(image),
length, &bytesRead);
NS_ENSURE_SUCCESS(rv, rv);
NS_ABORT_IF_FALSE(bytesRead == length, "WriteToRasterImage should consume everything!");
// Let the container know we've sent all the data
rv = (*aContainer)->SourceDataComplete();
// Let the Image know we've sent all the data
rv = image->SourceDataComplete();
NS_ENSURE_SUCCESS(rv, rv);
// All done
@ -124,8 +131,8 @@ NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
const nsACString& aMimeType,
nsIInputStream **aStream)
const nsACString& aMimeType,
nsIInputStream **aStream)
{
return EncodeScaledImage(aContainer, aMimeType, 0, 0, aStream);
}

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

@ -153,7 +153,7 @@ nsAlertsIconListener::OnStopDecode(imgIRequest* aRequest,
NS_IMETHODIMP
nsAlertsIconListener::FrameChanged(imgIContainer* aContainer,
nsIntRect* aDirtyRect)
const nsIntRect* aDirtyRect)
{
return NS_OK;
}

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

@ -354,8 +354,8 @@ nsMenuItemIconX::LoadIcon(nsIURI* aIconURI)
//
NS_IMETHODIMP
nsMenuItemIconX::FrameChanged(imgIContainer* aContainer,
nsIntRect* aDirtyRect)
nsMenuItemIconX::FrameChanged(imgIContainer* aContainer,
const nsIntRect* aDirtyRect)
{
return NS_OK;
}

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

@ -758,12 +758,6 @@ nsresult nsWindowGfx::CreateIcon(imgIContainer *aContainer,
HICON *aIcon) {
nsresult rv;
PRUint32 nFrames;
rv = aContainer->GetNumFrames(&nFrames);
NS_ENSURE_SUCCESS(rv, rv);
if (!nFrames)
return NS_ERROR_INVALID_ARG;
// Get the image data
nsRefPtr<gfxImageSurface> frame;