зеркало из https://github.com/mozilla/pjs.git
changing to new interface names
This commit is contained in:
Родитель
dd7b2a9543
Коммит
75206ecbe9
|
@ -631,7 +631,7 @@ process_buffered_gif_input_data(gif_struct* gs)
|
|||
|
||||
/******************************************************************************/
|
||||
// XXX: this isn't how we work anymore. We don't delay decoding of subsequent
|
||||
// frames. The nsIImageContainer is notified of the delay times and it manages
|
||||
// frames. The gfxIImageContainer is notified of the delay times and it manages
|
||||
// the frame display. This means it must wait for a new frame's FrameEnd callback
|
||||
// before displaying it, and wait for the GIFEnd callback before starting the
|
||||
// second animation loop.
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include "nsGIFDecoder2.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
#include "nsIImageContainerObserver.h"
|
||||
#include "gfxIImageContainerObserver.h"
|
||||
|
||||
#ifndef XP_MAC
|
||||
#endif
|
||||
|
@ -320,9 +320,9 @@ int HaveDecodedRow(
|
|||
// is added in GIF89a and control blocks are how the extensions are done.
|
||||
// How annoying.
|
||||
if(! decoder->mImageFrame) {
|
||||
gfx_format format = nsIGFXFormat::RGB;
|
||||
gfx_format format = gfxIFormats::RGB;
|
||||
if (decoder->mGIFStruct.is_transparent)
|
||||
format = nsIGFXFormat::RGB_A1;
|
||||
format = gfxIFormats::RGB_A1;
|
||||
|
||||
#ifdef XP_PC
|
||||
// XXX this works...
|
||||
|
@ -343,7 +343,7 @@ int HaveDecodedRow(
|
|||
decoder->mImageFrame->GetImageBytesPerRow(&bpr);
|
||||
decoder->mImageFrame->GetAlphaBytesPerRow(&abpr);
|
||||
|
||||
if (format == nsIGFXFormat::RGB_A1 || format == nsIGFXFormat::BGR_A1)
|
||||
if (format == gfxIFormats::RGB_A1 || format == gfxIFormats::BGR_A1)
|
||||
decoder->alphaLine = (PRUint8 *)nsMemory::Alloc(abpr);
|
||||
} else {
|
||||
decoder->mImageFrame->GetImageBytesPerRow(&bpr);
|
||||
|
@ -374,8 +374,8 @@ int HaveDecodedRow(
|
|||
PRUint8* rowBufIndex = aRowBufPtr;
|
||||
|
||||
switch (format) {
|
||||
case nsIGFXFormat::RGB:
|
||||
case nsIGFXFormat::BGR:
|
||||
case gfxIFormats::RGB:
|
||||
case gfxIFormats::BGR:
|
||||
{
|
||||
while(rowBufIndex != decoder->mGIFStruct.rowend) {
|
||||
#ifdef XP_PC
|
||||
|
@ -393,8 +393,8 @@ int HaveDecodedRow(
|
|||
decoder->mImageFrame->SetImageData((PRUint8*)aRGBrowBufPtr, bpr, aRowNumber*bpr);
|
||||
}
|
||||
break;
|
||||
case nsIGFXFormat::RGB_A1:
|
||||
case nsIGFXFormat::BGR_A1:
|
||||
case gfxIFormats::RGB_A1:
|
||||
case gfxIFormats::BGR_A1:
|
||||
{
|
||||
memset(decoder->alphaLine, 0, abpr);
|
||||
PRUint32 iwidth = (PRUint32)width;
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIImageDecoder.h"
|
||||
#include "nsIImageContainer.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "lpIImageRequest.h"
|
||||
|
||||
#include "GIF2.h"
|
||||
|
@ -58,8 +58,8 @@ public:
|
|||
|
||||
NS_METHOD ProcessData(unsigned char *data, PRUint32 count);
|
||||
|
||||
nsCOMPtr<nsIImageContainer> mImageContainer;
|
||||
nsCOMPtr<nsIImageFrame> mImageFrame;
|
||||
nsCOMPtr<gfxIImageContainer> mImageContainer;
|
||||
nsCOMPtr<gfxIImageFrame> mImageFrame;
|
||||
nsCOMPtr<lpIImageRequest> mImageRequest;
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIImageContainerObserver.h"
|
||||
#include "gfxIImageContainerObserver.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsJPEGDecoder, nsIImageDecoder, nsIOutputStream)
|
||||
|
||||
|
@ -234,7 +234,7 @@ NS_IMETHODIMP nsJPEGDecoder::WriteFrom(nsIInputStream *inStr, PRUint32 count, PR
|
|||
mObserver->OnStartContainer(nsnull, nsnull, mImage);
|
||||
|
||||
mFrame = do_CreateInstance("@mozilla.org/gfx/image/frame;2");
|
||||
mFrame->Init(0, 0, mInfo.image_width, mInfo.image_height, nsIGFXFormat::RGB);
|
||||
mFrame->Init(0, 0, mInfo.image_width, mInfo.image_height, gfxIFormats::RGB);
|
||||
mImage->AppendFrame(mFrame);
|
||||
mObserver->OnStartFrame(nsnull, nsnull, mFrame);
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIImageContainer.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "lpIImageRequest.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -83,8 +83,8 @@ protected:
|
|||
int OutputScanlines(int num_scanlines);
|
||||
|
||||
public:
|
||||
nsCOMPtr<nsIImageContainer> mImage;
|
||||
nsCOMPtr<nsIImageFrame> mFrame;
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<lpIImageRequest> mRequest;
|
||||
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "nsMemory.h"
|
||||
|
||||
#include "nsIImageContainerObserver.h"
|
||||
#include "gfxIImageContainerObserver.h"
|
||||
|
||||
// XXX we need to be sure to fire onStopDecode messages to mObserver in error cases.
|
||||
|
||||
|
@ -346,12 +346,12 @@ nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
|
|||
gfx_format format;
|
||||
|
||||
if (channels == 3) {
|
||||
format = nsIGFXFormat::RGB;
|
||||
format = gfxIFormats::RGB;
|
||||
} else if (channels > 3) {
|
||||
if (alpha_bits == 8) {
|
||||
decoder->mImage->GetPreferredAlphaChannelFormat(&format);
|
||||
} else if (alpha_bits == 1) {
|
||||
format = nsIGFXFormat::RGB_A1;
|
||||
format = gfxIFormats::RGB_A1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,12 +449,12 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,
|
|||
PRUint8 *aptr, *cptr;
|
||||
|
||||
switch (format) {
|
||||
case nsIGFXFormat::RGB:
|
||||
case nsIGFXFormat::BGR:
|
||||
case gfxIFormats::RGB:
|
||||
case gfxIFormats::BGR:
|
||||
decoder->mFrame->SetImageData((PRUint8*)line, bpr, row_num*bpr);
|
||||
break;
|
||||
case nsIGFXFormat::RGB_A1:
|
||||
case nsIGFXFormat::BGR_A1:
|
||||
case gfxIFormats::RGB_A1:
|
||||
case gfxIFormats::BGR_A1:
|
||||
{
|
||||
cptr = decoder->colorLine;
|
||||
aptr = decoder->alphaLine;
|
||||
|
@ -471,8 +471,8 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,
|
|||
decoder->mFrame->SetAlphaData(decoder->alphaLine, abpr, row_num*abpr);
|
||||
}
|
||||
break;
|
||||
case nsIGFXFormat::RGB_A8:
|
||||
case nsIGFXFormat::BGR_A8:
|
||||
case gfxIFormats::RGB_A8:
|
||||
case gfxIFormats::BGR_A8:
|
||||
{
|
||||
cptr = decoder->colorLine;
|
||||
aptr = decoder->alphaLine;
|
||||
|
@ -486,8 +486,8 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,
|
|||
decoder->mFrame->SetAlphaData(decoder->alphaLine, abpr, row_num*abpr);
|
||||
}
|
||||
break;
|
||||
case nsIGFXFormat::RGBA:
|
||||
case nsIGFXFormat::BGRA:
|
||||
case gfxIFormats::RGBA:
|
||||
case gfxIFormats::BGRA:
|
||||
decoder->mFrame->SetImageData(line, bpr, row_num*bpr);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
|
||||
#include "nsIImageDecoder.h"
|
||||
|
||||
#include "nsIImageContainer.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "lpIImageRequest.h"
|
||||
|
||||
|
||||
|
@ -67,8 +67,8 @@ end_callback(png_structp png_ptr, png_infop info_ptr);
|
|||
|
||||
|
||||
public:
|
||||
nsCOMPtr<nsIImageContainer> mImage;
|
||||
nsCOMPtr<nsIImageFrame> mFrame;
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<lpIImageRequest> mRequest;
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include "nsPPMDecoder.h"
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIImageContainer.h"
|
||||
#include "nsIImageContainerObserver.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "gfxIImageContainerObserver.h"
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
|
@ -219,7 +219,7 @@ NS_IMETHODIMP nsPPMDecoder::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRU
|
|||
if (mObserver)
|
||||
mObserver->OnStartContainer(nsnull, nsnull, mImage);
|
||||
|
||||
mFrame->Init(0, 0, w, h, nsIGFXFormat::RGB);
|
||||
mFrame->Init(0, 0, w, h, gfxIFormats::RGB);
|
||||
mImage->AppendFrame(mFrame);
|
||||
if (mObserver)
|
||||
mObserver->OnStartFrame(nsnull, nsnull, mFrame);
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIImageContainer.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "lpIImageRequest.h"
|
||||
|
||||
#define NS_PPMDECODER_CID \
|
||||
|
@ -52,8 +52,8 @@ public:
|
|||
virtual ~nsPPMDecoder();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIImageContainer> mImage;
|
||||
nsCOMPtr<nsIImageFrame> mFrame;
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<lpIImageRequest> mRequest;
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
|
||||
|
|
|
@ -1,341 +0,0 @@
|
|||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#include "nsImageRequest.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIImageLoader.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include "ImageCache.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS5(nsImageRequest, lpIImageRequest,
|
||||
nsIImageDecoderObserver, nsIImageContainerObserver,
|
||||
nsIStreamListener, nsIStreamObserver)
|
||||
|
||||
nsImageRequest::nsImageRequest() :
|
||||
mObservers(0), mProcessing(PR_TRUE), mStatus(lpIImageRequest::STATUS_NONE), mState(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
nsImageRequest::~nsImageRequest()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
|
||||
nsresult nsImageRequest::Init(nsIChannel *aChannel)
|
||||
{
|
||||
// XXX we should save off the thread we are getting called on here so that we can proxy all calls to mDecoder to it.
|
||||
|
||||
NS_ASSERTION(!mImage, "nsImageRequest::Init -- Multiple calls to init");
|
||||
NS_ASSERTION(aChannel, "nsImageRequest::Init -- No channel");
|
||||
|
||||
mChannel = aChannel;
|
||||
|
||||
// XXX do not init the image here. this has to be done from the image decoder.
|
||||
mImage = do_CreateInstance("@mozilla.org/gfx/image;2");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsImageRequest::AddObserver(nsIImageDecoderObserver *observer)
|
||||
{
|
||||
mObservers.AppendElement(NS_STATIC_CAST(void*, observer));
|
||||
|
||||
if (mState & onStartDecode)
|
||||
observer->OnStartDecode(nsnull, nsnull);
|
||||
if (mState & onStartContainer)
|
||||
observer->OnStartContainer(nsnull, nsnull, mImage);
|
||||
|
||||
// XXX send the decoded rect in here
|
||||
|
||||
if (mState & onStopContainer)
|
||||
observer->OnStopContainer(nsnull, nsnull, mImage);
|
||||
if (mState & onStopDecode)
|
||||
observer->OnStopDecode(nsnull, nsnull, NS_OK, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsImageRequest::RemoveObserver(nsIImageDecoderObserver *observer, nsresult status)
|
||||
{
|
||||
mObservers.RemoveElement(NS_STATIC_CAST(void*, observer));
|
||||
|
||||
if ((mObservers.Count() == 0) && mChannel && mProcessing) {
|
||||
mChannel->Cancel(status);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** lpIImageRequest methods **/
|
||||
|
||||
|
||||
/* void cancel (in nsresult status); */
|
||||
NS_IMETHODIMP nsImageRequest::Cancel(nsresult status)
|
||||
{
|
||||
// XXX this method should not ever get called
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mChannel && mProcessing) {
|
||||
rv = mChannel->Cancel(status);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIImage image; */
|
||||
NS_IMETHODIMP nsImageRequest::GetImage(nsIImageContainer * *aImage)
|
||||
{
|
||||
*aImage = mImage;
|
||||
NS_IF_ADDREF(*aImage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageStatus; */
|
||||
NS_IMETHODIMP nsImageRequest::GetImageStatus(PRUint32 *aStatus)
|
||||
{
|
||||
*aStatus = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** nsIImageContainerObserver methods **/
|
||||
|
||||
/* [noscript] void frameChanged (in nsIImageContainer container, in nsISupports cx, in nsIImageFrame newframe, in nsRect dirtyRect); */
|
||||
NS_IMETHODIMP nsImageRequest::FrameChanged(nsIImageContainer *container, nsISupports *cx, nsIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->FrameChanged(container, cx, newframe, dirtyRect);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** nsIImageDecoderObserver methods **/
|
||||
|
||||
/* void onStartDecode (in lpIImageRequest request, in nsISupports cx); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStartDecode(lpIImageRequest *request, nsISupports *cx)
|
||||
{
|
||||
mState |= onStartDecode;
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStartDecode(request, cx);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartContainer (in lpIImageRequest request, in nsISupports cx, in nsIImageContainer image); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStartContainer(lpIImageRequest *request, nsISupports *cx, nsIImageContainer *image)
|
||||
{
|
||||
mState |= onStartContainer;
|
||||
|
||||
mStatus |= lpIImageRequest::STATUS_SIZE_AVAILABLE;
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStartContainer(request, cx, image);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartFrame (in lpIImageRequest request, in nsISupports cx, in nsIImageFrame frame); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStartFrame(lpIImageRequest *request, nsISupports *cx, nsIImageFrame *frame)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStartFrame(request, cx, frame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void onDataAvailable (in lpIImageRequest request, in nsISupports cx, in nsIImageFrame frame, [const] in nsRect rect); */
|
||||
NS_IMETHODIMP nsImageRequest::OnDataAvailable(lpIImageRequest *request, nsISupports *cx, nsIImageFrame *frame, const nsRect * rect)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnDataAvailable(request, cx, frame, rect);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopFrame (in lpIImageRequest request, in nsISupports cx, in nsIImageFrame frame); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStopFrame(lpIImageRequest *request, nsISupports *cx, nsIImageFrame *frame)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStopFrame(request, cx, frame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopContainer (in lpIImageRequest request, in nsISupports cx, in nsIImageContainer image); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStopContainer(lpIImageRequest *request, nsISupports *cx, nsIImageContainer *image)
|
||||
{
|
||||
mState |= onStopContainer;
|
||||
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStopContainer(request, cx, image);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopDecode (in lpIImageRequest request, in nsISupports cx, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStopDecode(lpIImageRequest *request, nsISupports *cx, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
mState |= onStopDecode;
|
||||
|
||||
if (NS_FAILED(status))
|
||||
mStatus = lpIImageRequest::STATUS_ERROR;
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStopDecode(request, cx, status, statusArg);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** nsIStreamObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIChannel channel, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStartRequest(nsIChannel *channel, nsISupports *ctxt)
|
||||
{
|
||||
NS_ASSERTION(!mDecoder, "nsImageRequest::OnStartRequest -- we already have a decoder");
|
||||
|
||||
nsXPIDLCString contentType;
|
||||
channel->GetContentType(getter_Copies(contentType));
|
||||
printf("content type is %s\n", contentType.get());
|
||||
|
||||
nsCAutoString conid("@mozilla.org/image/decoder;2?type=");
|
||||
conid += contentType.get();
|
||||
|
||||
mDecoder = do_CreateInstance(conid);
|
||||
|
||||
if (!mDecoder) {
|
||||
// no image decoder for this mimetype :(
|
||||
channel->Cancel(NS_BINDING_ABORTED);
|
||||
|
||||
// XXX notify the person that owns us now that wants the nsIImageContainer off of us?
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mDecoder->Init(NS_STATIC_CAST(lpIImageRequest*, this));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopRequest (in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP nsImageRequest::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
NS_ASSERTION(mChannel || mProcessing, "nsImageRequest::OnStopRequest -- received multiple OnStopRequest");
|
||||
|
||||
mProcessing = PR_FALSE;
|
||||
|
||||
// if we failed, we should remove ourself from the cache
|
||||
if (NS_FAILED(status)) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
ImageCache::Remove(uri);
|
||||
}
|
||||
|
||||
mChannel = nsnull; // we no longer need the channel
|
||||
|
||||
if (!mDecoder) return NS_ERROR_FAILURE;
|
||||
|
||||
mDecoder->Close();
|
||||
|
||||
mDecoder = nsnull; // release the decoder so that it can rest peacefully ;)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** nsIStreamListener methods **/
|
||||
|
||||
/* void onDataAvailable (in nsIChannel channel, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
|
||||
NS_IMETHODIMP nsImageRequest::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||
{
|
||||
if (!mDecoder) {
|
||||
NS_ASSERTION(mDecoder, "nsImageRequest::OnDataAvailable -- no decoder");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRUint32 wrote;
|
||||
return mDecoder->WriteFrom(inStr, count, &wrote);
|
||||
}
|
|
@ -29,7 +29,7 @@
|
|||
#include "nsIRunnable.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIImageContainer.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoder.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
private:
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsCOMPtr<nsIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<nsIImageDecoder> mDecoder;
|
||||
|
||||
nsVoidArray mObservers;
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#include "nsImageRequestProxy.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIImageLoader.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsImageRequest.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsImageRequestProxy, lpIImageRequest, nsIImageDecoderObserver, nsIImageContainerObserver)
|
||||
|
||||
nsImageRequestProxy::nsImageRequestProxy()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
nsImageRequestProxy::~nsImageRequestProxy()
|
||||
{
|
||||
/* destructor code */
|
||||
NS_REINTERPRET_CAST(nsImageRequest*, mOwner.get())->RemoveObserver(this, NS_ERROR_FAILURE); // XXX bogus result value
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult nsImageRequestProxy::Init(nsImageRequest *request, nsIImageDecoderObserver *aObserver, nsISupports *cx)
|
||||
{
|
||||
PR_ASSERT(request);
|
||||
|
||||
mOwner = NS_STATIC_CAST(lpIImageRequest*, request);
|
||||
|
||||
mObserver = aObserver;
|
||||
// XXX we should save off the thread we are getting called on here so that we can proxy all calls to mDecoder to it.
|
||||
|
||||
mContext = cx;
|
||||
|
||||
request->AddObserver(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* void cancel (in nsresult status); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::Cancel(nsresult status)
|
||||
{
|
||||
return NS_REINTERPRET_CAST(nsImageRequest*, mOwner.get())->RemoveObserver(this, status);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIImage image; */
|
||||
NS_IMETHODIMP nsImageRequestProxy::GetImage(nsIImageContainer * *aImage)
|
||||
{
|
||||
return mOwner->GetImage(aImage);
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageStatus; */
|
||||
NS_IMETHODIMP nsImageRequestProxy::GetImageStatus(PRUint32 *aStatus)
|
||||
{
|
||||
return mOwner->GetImageStatus(aStatus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** nsIImageContainerObserver methods **/
|
||||
|
||||
/* [noscript] void frameChanged (in nsIImageContainer container, in nsISupports cx, in nsIImageFrame newframe, in nsRect dirtyRect); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::FrameChanged(nsIImageContainer *container, nsISupports *cx, nsIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->FrameChanged(container, mContext, newframe, dirtyRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** nsIImageDecoderObserver methods **/
|
||||
|
||||
/* void onStartDecode (in lpIImageRequest request, in nsISupports cx); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnStartDecode(lpIImageRequest *request, nsISupports *cx)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStartDecode(this, mContext);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartContainer (in lpIImageRequest request, in nsISupports cx, in nsIImageContainer image); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnStartContainer(lpIImageRequest *request, nsISupports *cx, nsIImageContainer *image)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStartContainer(this, mContext, image);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartFrame (in lpIImageRequest request, in nsISupports cx, in nsIImageFrame frame); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnStartFrame(lpIImageRequest *request, nsISupports *cx, nsIImageFrame *frame)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStartFrame(this, mContext, frame);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void onDataAvailable (in lpIImageRequest request, in nsISupports cx, in nsIImageFrame frame, [const] in nsRect rect); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnDataAvailable(lpIImageRequest *request, nsISupports *cx, nsIImageFrame *frame, const nsRect * rect)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnDataAvailable(this, mContext, frame, rect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopFrame (in lpIImageRequest request, in nsISupports cx, in nsIImageFrame frame); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnStopFrame(lpIImageRequest *request, nsISupports *cx, nsIImageFrame *frame)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStopFrame(this, mContext, frame);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopContainer (in lpIImageRequest request, in nsISupports cx, in nsIImageContainer image); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnStopContainer(lpIImageRequest *request, nsISupports *cx, nsIImageContainer *image)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStopContainer(this, mContext, image);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopDecode (in lpIImageRequest request, in nsISupports cx, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP nsImageRequestProxy::OnStopDecode(lpIImageRequest *request, nsISupports *cx, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStopDecode(this, mContext, status, statusArg);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
#include "nsImageRequest.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
|
||||
#include "nsIImageContainer.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoder.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче