paper@animecity.nu (Arron), r=pavlov, sr=tor, a=asa git-svn-id: svn://10.0.0.236/trunk@131673 18797224-902f-48f8-a5cc-f745e15eee43
249 lines
7.3 KiB
C++
249 lines
7.3 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Mozilla Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/MPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 2001 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Stuart Parmenter <pavlov@netscape.com>
|
|
* Chris Saari <saari@netscape.com>
|
|
* Asko Tontti <atontti@cc.hut.fi>
|
|
* Arron Mogge <paper@animecity.nu>
|
|
*/
|
|
|
|
#include "imgContainer.h"
|
|
|
|
NS_IMPL_ISUPPORTS1(imgContainer, imgIContainer)
|
|
|
|
//******************************************************************************
|
|
imgContainer::imgContainer() :
|
|
mSize(0,0),
|
|
mFrame(nsnull)
|
|
{
|
|
NS_INIT_ISUPPORTS();
|
|
}
|
|
|
|
//******************************************************************************
|
|
imgContainer::~imgContainer()
|
|
{
|
|
mFrame = nsnull;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void init (in nscoord aWidth, in nscoord aHeight, in imgIContainerObserver aObserver); */
|
|
NS_IMETHODIMP imgContainer::Init(nscoord aWidth, nscoord aHeight, imgIContainerObserver *aObserver)
|
|
{
|
|
if (aWidth <= 0 || aHeight <= 0) {
|
|
NS_WARNING("error - negative image size\n");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
mSize.SizeTo(aWidth, aHeight);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* readonly attribute gfx_format preferredAlphaChannelFormat; */
|
|
NS_IMETHODIMP imgContainer::GetPreferredAlphaChannelFormat(gfx_format *aFormat)
|
|
{
|
|
NS_ASSERTION(aFormat, "imgContainer::GetPreferredAlphaChannelFormat; Invalid Arg");
|
|
if (!aFormat)
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
/* default.. platform's should probably overwrite this */
|
|
*aFormat = gfxIFormats::RGB_A8;
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* readonly attribute nscoord width; */
|
|
NS_IMETHODIMP imgContainer::GetWidth(nscoord *aWidth)
|
|
{
|
|
NS_ASSERTION(aWidth, "imgContainer::GetWidth; Invalid Arg");
|
|
if (!aWidth)
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
*aWidth = mSize.width;
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* readonly attribute nscoord height; */
|
|
NS_IMETHODIMP imgContainer::GetHeight(nscoord *aHeight)
|
|
{
|
|
NS_ASSERTION(aHeight, "imgContainer::GetHeight; Invalid Arg");
|
|
if (!aHeight)
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
*aHeight = mSize.height;
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* readonly attribute gfxIImageFrame currentFrame; */
|
|
NS_IMETHODIMP imgContainer::GetCurrentFrame(gfxIImageFrame **aCurrentFrame)
|
|
{
|
|
NS_ASSERTION(aCurrentFrame, "imgContainer::GetCurrentFrame; Invalid Arg");
|
|
if (!aCurrentFrame)
|
|
return NS_ERROR_INVALID_POINTER;
|
|
|
|
if (mFrame) {
|
|
*aCurrentFrame = mFrame;
|
|
NS_ADDREF(*aCurrentFrame);
|
|
return NS_OK;
|
|
} else {
|
|
*aCurrentFrame = nsnull;
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* readonly attribute unsigned long numFrames; */
|
|
NS_IMETHODIMP imgContainer::GetNumFrames(PRUint32 *aNumFrames)
|
|
{
|
|
NS_ASSERTION(aNumFrames, "imgContainer::GetNumFrames; Invalid Arg");
|
|
if (!aNumFrames)
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
*aNumFrames = mFrame ? 1 : 0;
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* gfxIImageFrame getFrameAt (in unsigned long index); */
|
|
NS_IMETHODIMP imgContainer::GetFrameAt(PRUint32 index, gfxIImageFrame **_retval)
|
|
{
|
|
NS_ASSERTION(_retval, "imgContainer::GetFrameAt; Invalid Arg");
|
|
if (!_retval)
|
|
return NS_ERROR_INVALID_POINTER;
|
|
|
|
if (!mFrame || index != 0)
|
|
return NS_ERROR_FAILURE;
|
|
*_retval = mFrame;
|
|
NS_ADDREF(*_retval);
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void appendFrame (in gfxIImageFrame item); */
|
|
NS_IMETHODIMP imgContainer::AppendFrame(gfxIImageFrame *item)
|
|
{
|
|
NS_ASSERTION(item, "imgContainer::AppendFrame; Invalid Arg");
|
|
if (!item)
|
|
return NS_ERROR_INVALID_ARG;
|
|
NS_ASSERTION(!mFrame, "imgContainer::AppendFrame; Tried to add another frame when only 1 is allowed");
|
|
|
|
if (mFrame)
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
mFrame = item;
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void removeFrame (in gfxIImageFrame item); */
|
|
NS_IMETHODIMP imgContainer::RemoveFrame(gfxIImageFrame *item)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void endFrameDecode (in gfxIImageFrame item, in unsigned long timeout); */
|
|
NS_IMETHODIMP imgContainer::EndFrameDecode(PRUint32 aFrameNum, PRUint32 aTimeout)
|
|
{
|
|
NS_ASSERTION(aFrameNum == 0, "Received an EndFrameDecode call with an invalid frame number");
|
|
|
|
if (aFrameNum != 0 || !mFrame)
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
mFrame->SetTimeout(aTimeout);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void decodingComplete (); */
|
|
NS_IMETHODIMP imgContainer::DecodingComplete(void)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* nsIEnumerator enumerate (); */
|
|
NS_IMETHODIMP imgContainer::Enumerate(nsIEnumerator **_retval)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void clear (); */
|
|
NS_IMETHODIMP imgContainer::Clear()
|
|
{
|
|
mFrame = nsnull;
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
NS_IMETHODIMP imgContainer::GetAnimationMode(PRUint16 *aAnimationMode)
|
|
{
|
|
NS_ASSERTION(aAnimationMode, "imgContainer::GetAnimationMode; Invalid Arg");
|
|
if (!aAnimationMode)
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
*aAnimationMode = kDontAnimMode;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP imgContainer::SetAnimationMode(PRUint16 aAnimationMode)
|
|
{
|
|
// Ignore setting of animation mode
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void startAnimation () */
|
|
NS_IMETHODIMP imgContainer::StartAnimation()
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void stopAnimation (); */
|
|
NS_IMETHODIMP imgContainer::StopAnimation()
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* attribute long loopCount; */
|
|
NS_IMETHODIMP imgContainer::GetLoopCount(PRInt32 *aLoopCount)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP imgContainer::SetLoopCount(PRInt32 aLoopCount)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
//******************************************************************************
|
|
/* void resetAnimation (); */
|
|
NS_IMETHODIMP imgContainer::ResetAnimation()
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|