removing lots of stuff (like all the platform specific code) moving gfxIImageContainer* into new image library
This commit is contained in:
Родитель
1d9ed4f572
Коммит
43be50d7ae
|
@ -35,7 +35,6 @@
|
|||
* @author Tim Rowley <tor@cs.brown.edu>
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see "gfx2"
|
||||
*/
|
||||
[scriptable, uuid(51cc27a8-1dd2-11b2-a1aa-dad33ab193b4)]
|
||||
interface gfxIImageFrame : nsISupports
|
||||
|
@ -57,7 +56,6 @@ interface gfxIImageFrame : nsISupports
|
|||
in nscoord aHeight,
|
||||
in gfx_format aFormat);
|
||||
|
||||
|
||||
/**
|
||||
* The x-offset of the image.
|
||||
*/
|
||||
|
@ -83,7 +81,6 @@ interface gfxIImageFrame : nsISupports
|
|||
*/
|
||||
[noscript] readonly attribute nsRect rect;
|
||||
|
||||
|
||||
/**
|
||||
* The image data format the image was created with.
|
||||
* @see gfxIFormats
|
||||
|
@ -96,11 +93,7 @@ interface gfxIImageFrame : nsISupports
|
|||
*/
|
||||
attribute long timeout;
|
||||
|
||||
|
||||
|
||||
/* data accessors */
|
||||
|
||||
|
||||
readonly attribute unsigned long imageBytesPerRow;
|
||||
|
||||
/**
|
||||
|
@ -123,10 +116,7 @@ interface gfxIImageFrame : nsISupports
|
|||
in unsigned long length,
|
||||
in long offset);
|
||||
|
||||
|
||||
|
||||
/* alpha stuff.. used for _A1 and _A8 formated images */
|
||||
|
||||
readonly attribute unsigned long alphaBytesPerRow;
|
||||
|
||||
/**
|
||||
|
@ -143,5 +133,4 @@ interface gfxIImageFrame : nsISupports
|
|||
void setAlphaData([array, size_is(length), const] in PRUint8 data,
|
||||
in unsigned long length,
|
||||
in long offset);
|
||||
|
||||
};
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
* @author Tim Rowley <tor@cs.brown.edu>
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see "gfx2"
|
||||
*/
|
||||
[scriptable, uuid(51cc27a8-1dd2-11b2-a1aa-dad33ab193b4)]
|
||||
interface gfxIImageFrame : nsISupports
|
||||
|
@ -57,7 +56,6 @@ interface gfxIImageFrame : nsISupports
|
|||
in nscoord aHeight,
|
||||
in gfx_format aFormat);
|
||||
|
||||
|
||||
/**
|
||||
* The x-offset of the image.
|
||||
*/
|
||||
|
@ -83,7 +81,6 @@ interface gfxIImageFrame : nsISupports
|
|||
*/
|
||||
[noscript] readonly attribute nsRect rect;
|
||||
|
||||
|
||||
/**
|
||||
* The image data format the image was created with.
|
||||
* @see gfxIFormats
|
||||
|
@ -96,11 +93,7 @@ interface gfxIImageFrame : nsISupports
|
|||
*/
|
||||
attribute long timeout;
|
||||
|
||||
|
||||
|
||||
/* data accessors */
|
||||
|
||||
|
||||
readonly attribute unsigned long imageBytesPerRow;
|
||||
|
||||
/**
|
||||
|
@ -123,10 +116,7 @@ interface gfxIImageFrame : nsISupports
|
|||
in unsigned long length,
|
||||
in long offset);
|
||||
|
||||
|
||||
|
||||
/* alpha stuff.. used for _A1 and _A8 formated images */
|
||||
|
||||
readonly attribute unsigned long alphaBytesPerRow;
|
||||
|
||||
/**
|
||||
|
@ -143,5 +133,4 @@ interface gfxIImageFrame : nsISupports
|
|||
void setAlphaData([array, size_is(length), const] in PRUint8 data,
|
||||
in unsigned long length,
|
||||
in long offset);
|
||||
|
||||
};
|
||||
|
|
|
@ -0,0 +1,282 @@
|
|||
/* -*- 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 "gfxImageFrame.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(gfxImageFrame, gfxIImageFrame, nsIInterfaceRequestor)
|
||||
|
||||
gfxImageFrame::gfxImageFrame() :
|
||||
mTimeout(0),
|
||||
mInitalized(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
gfxImageFrame::~gfxImageFrame()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* void init (in nscoord aX, in nscoord aY, in nscoord aWidth, in nscoord aHeight, in gfx_format aFormat); */
|
||||
NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, gfx_format aFormat)
|
||||
{
|
||||
if (aWidth <= 0 || aHeight <= 0) {
|
||||
printf("error - negative image size\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mInitalized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mInitalized = PR_TRUE;
|
||||
|
||||
mOffset.MoveTo(aX, aY);
|
||||
mSize.SizeTo(aWidth, aHeight);
|
||||
|
||||
mFormat = aFormat;
|
||||
|
||||
mImage = do_CreateInstance("@mozilla.org/gfx/image;1");
|
||||
|
||||
gfx_depth depth = 24;
|
||||
nsMaskRequirements maskReq;
|
||||
|
||||
switch (aFormat) {
|
||||
case gfxIFormats::BGR:
|
||||
case gfxIFormats::RGB:
|
||||
maskReq = nsMaskRequirements_kNoMask;
|
||||
break;
|
||||
|
||||
case gfxIFormats::BGRA:
|
||||
case gfxIFormats::RGBA:
|
||||
printf("we can't do this with the old image code\n");
|
||||
maskReq = nsMaskRequirements_kNeeds8Bit;
|
||||
break;
|
||||
|
||||
case gfxIFormats::BGR_A1:
|
||||
case gfxIFormats::RGB_A1:
|
||||
maskReq = nsMaskRequirements_kNeeds1Bit;
|
||||
break;
|
||||
|
||||
case gfxIFormats::BGR_A8:
|
||||
case gfxIFormats::RGB_A8:
|
||||
maskReq = nsMaskRequirements_kNeeds8Bit;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("unsupposed gfx_format\n");
|
||||
break;
|
||||
}
|
||||
|
||||
mImage->Init(aWidth, aHeight, depth, maskReq);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord x; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetX(nscoord *aX)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aX = mOffset.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord y; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetY(nscoord *aY)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aY = mOffset.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* readonly attribute nscoord width; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetWidth(nscoord *aWidth)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aWidth = mSize.width;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord height; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetHeight(nscoord *aHeight)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aHeight = mSize.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsRect rect; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetRect(nsRect **aRect)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsRect rect(mOffset.x, mOffset.y, mSize.width, mSize.height);
|
||||
*aRect = ▭
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute gfx_format format; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetFormat(gfx_format *aFormat)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aFormat = mFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long timeout; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
|
||||
{
|
||||
*aTimeout = mTimeout;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP gfxImageFrame::SetTimeout(PRInt32 aTimeout)
|
||||
{
|
||||
mTimeout = aTimeout;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageBytesPerRow; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetImageBytesPerRow(PRUint32 *aBytesPerRow)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBytesPerRow = mImage->GetLineStride();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageDataLength; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetImageDataLength(PRUint32 *aBitsLength)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBitsLength = mImage->GetBytesPix();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getImageData([array, size_is(length)] out PRUint8 bits, out unsigned long length); */
|
||||
NS_IMETHODIMP gfxImageFrame::GetImageData(PRUint8 **aData, PRUint32 *length)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aData = mImage->GetBits();
|
||||
*length = mImage->GetBytesPix() * mSize.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setImageData ([array, size_is (length), const] in PRUint8 data, in unsigned long length, in long offset); */
|
||||
NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength, PRInt32 aOffset)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRUint8 *imgData = mImage->GetBits();
|
||||
PRInt32 imgLen = mImage->GetBytesPix();
|
||||
|
||||
if (((aOffset + (PRInt32)aLength) > imgLen) || !imgData)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
memcpy(imgData + aOffset, aData, aLength);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long alphaBytesPerRow; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetAlphaBytesPerRow(PRUint32 *aBytesPerRow)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBytesPerRow = mImage->GetAlphaLineStride();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long alphaDataLength; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetAlphaDataLength(PRUint32 *aBitsLength)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBitsLength = mImage->GetAlphaLineStride() * mSize.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); */
|
||||
NS_IMETHODIMP gfxImageFrame::GetAlphaData(PRUint8 **aData, PRUint32 *length)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aData = mImage->GetAlphaBits();
|
||||
*length = mImage->GetAlphaLineStride() * mSize.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setAlphaData ([array, size_is (length), const] in PRUint8 data, in unsigned long length, in long offset); */
|
||||
NS_IMETHODIMP gfxImageFrame::SetAlphaData(const PRUint8 *aData, PRUint32 aLength, PRInt32 aOffset)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRUint8 *alphaData = mImage->GetAlphaBits();
|
||||
PRInt32 alphaLen = mImage->GetAlphaLineStride() * mSize.height;
|
||||
|
||||
if (((aOffset + (PRInt32)aLength) > alphaLen) || !alphaData)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
memcpy(alphaData + aOffset, aData, aLength);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP gfxImageFrame::GetInterface(const nsIID & aIID, void * *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
if (NS_SUCCEEDED(QueryInterface(aIID, result)))
|
||||
return NS_OK;
|
||||
if (mImage && aIID.Equals(NS_GET_IID(nsIImage)))
|
||||
return mImage->QueryInterface(aIID, result);
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- 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) 2000-2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsIImage.h"
|
||||
|
||||
#include "nsPoint.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define GFX_IMAGEFRAME_CID \
|
||||
{ /* aa699204-1dd1-11b2-84a9-a280c268e4fb */ \
|
||||
0xaa699204, \
|
||||
0x1dd1, \
|
||||
0x11b2, \
|
||||
{0x84, 0xa9, 0xa2, 0x80, 0xc2, 0x68, 0xe4, 0xfb} \
|
||||
}
|
||||
|
||||
class gfxImageFrame : public gfxIImageFrame,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_GFXIIMAGEFRAME
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
gfxImageFrame();
|
||||
virtual ~gfxImageFrame();
|
||||
|
||||
protected:
|
||||
nsSize mSize;
|
||||
|
||||
private:
|
||||
/* private members */
|
||||
nsCOMPtr<nsIImage> mImage;
|
||||
nsPoint mOffset;
|
||||
|
||||
PRInt32 mTimeout;
|
||||
|
||||
PRPackedBool mInitalized; // 8 bits
|
||||
gfx_format mFormat; // 16 bits
|
||||
};
|
|
@ -1,6 +0,0 @@
|
|||
gfxtypes.idl
|
||||
gfx2types.idl
|
||||
gfxIFormats.idl
|
||||
gfxIImageContainer.idl
|
||||
gfxIImageContainerObserver.idl
|
||||
gfxIImageFrame.idl
|
|
@ -1,48 +0,0 @@
|
|||
#
|
||||
# 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) 2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Stuart Parmenter <pavlov@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx2
|
||||
XPIDL_MODULE = gfx2
|
||||
|
||||
XPIDLSRCS = \
|
||||
gfxtypes.idl \
|
||||
gfx2types.idl \
|
||||
gfxIFormats.idl \
|
||||
gfxIImageContainer.idl \
|
||||
gfxIImageContainerObserver.idl \
|
||||
gfxIImageFrame.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
gfxcompat.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
* @author Tim Rowley <tor@cs.brown.edu>
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see "gfx2"
|
||||
*/
|
||||
[scriptable, uuid(51cc27a8-1dd2-11b2-a1aa-dad33ab193b4)]
|
||||
interface gfxIImageFrame : nsISupports
|
||||
|
@ -57,7 +56,6 @@ interface gfxIImageFrame : nsISupports
|
|||
in nscoord aHeight,
|
||||
in gfx_format aFormat);
|
||||
|
||||
|
||||
/**
|
||||
* The x-offset of the image.
|
||||
*/
|
||||
|
@ -83,7 +81,6 @@ interface gfxIImageFrame : nsISupports
|
|||
*/
|
||||
[noscript] readonly attribute nsRect rect;
|
||||
|
||||
|
||||
/**
|
||||
* The image data format the image was created with.
|
||||
* @see gfxIFormats
|
||||
|
@ -96,11 +93,7 @@ interface gfxIImageFrame : nsISupports
|
|||
*/
|
||||
attribute long timeout;
|
||||
|
||||
|
||||
|
||||
/* data accessors */
|
||||
|
||||
|
||||
readonly attribute unsigned long imageBytesPerRow;
|
||||
|
||||
/**
|
||||
|
@ -123,10 +116,7 @@ interface gfxIImageFrame : nsISupports
|
|||
in unsigned long length,
|
||||
in long offset);
|
||||
|
||||
|
||||
|
||||
/* alpha stuff.. used for _A1 and _A8 formated images */
|
||||
|
||||
readonly attribute unsigned long alphaBytesPerRow;
|
||||
|
||||
/**
|
||||
|
@ -143,5 +133,4 @@ interface gfxIImageFrame : nsISupports
|
|||
void setAlphaData([array, size_is(length), const] in PRUint8 data,
|
||||
in unsigned long length,
|
||||
in long offset);
|
||||
|
||||
};
|
||||
|
|
|
@ -31,8 +31,6 @@ XPIDLSRCS = \
|
|||
.\gfxtypes.idl \
|
||||
.\gfx2types.idl \
|
||||
.\gfxIFormats.idl \
|
||||
.\gfxIImageContainer.idl \
|
||||
.\gfxIImageContainerObserver.idl \
|
||||
.\gfxIImageFrame.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -28,17 +28,18 @@ VPATH = @srcdir@
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx2
|
||||
LIBRARY_NAME = gfx_base
|
||||
LIBRARY_NAME = gfx2
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
gfxImageContainer.cpp \
|
||||
gfxImageFrame.cpp \
|
||||
nsGfxFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
DIRS = gtk
|
||||
|
||||
#DIRS = gtk
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
#override NO_SHARED_LIB=1
|
||||
#override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -0,0 +1,282 @@
|
|||
/* -*- 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 "gfxImageFrame.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(gfxImageFrame, gfxIImageFrame, nsIInterfaceRequestor)
|
||||
|
||||
gfxImageFrame::gfxImageFrame() :
|
||||
mTimeout(0),
|
||||
mInitalized(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
gfxImageFrame::~gfxImageFrame()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* void init (in nscoord aX, in nscoord aY, in nscoord aWidth, in nscoord aHeight, in gfx_format aFormat); */
|
||||
NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, gfx_format aFormat)
|
||||
{
|
||||
if (aWidth <= 0 || aHeight <= 0) {
|
||||
printf("error - negative image size\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mInitalized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mInitalized = PR_TRUE;
|
||||
|
||||
mOffset.MoveTo(aX, aY);
|
||||
mSize.SizeTo(aWidth, aHeight);
|
||||
|
||||
mFormat = aFormat;
|
||||
|
||||
mImage = do_CreateInstance("@mozilla.org/gfx/image;1");
|
||||
|
||||
gfx_depth depth = 24;
|
||||
nsMaskRequirements maskReq;
|
||||
|
||||
switch (aFormat) {
|
||||
case gfxIFormats::BGR:
|
||||
case gfxIFormats::RGB:
|
||||
maskReq = nsMaskRequirements_kNoMask;
|
||||
break;
|
||||
|
||||
case gfxIFormats::BGRA:
|
||||
case gfxIFormats::RGBA:
|
||||
printf("we can't do this with the old image code\n");
|
||||
maskReq = nsMaskRequirements_kNeeds8Bit;
|
||||
break;
|
||||
|
||||
case gfxIFormats::BGR_A1:
|
||||
case gfxIFormats::RGB_A1:
|
||||
maskReq = nsMaskRequirements_kNeeds1Bit;
|
||||
break;
|
||||
|
||||
case gfxIFormats::BGR_A8:
|
||||
case gfxIFormats::RGB_A8:
|
||||
maskReq = nsMaskRequirements_kNeeds8Bit;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("unsupposed gfx_format\n");
|
||||
break;
|
||||
}
|
||||
|
||||
mImage->Init(aWidth, aHeight, depth, maskReq);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord x; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetX(nscoord *aX)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aX = mOffset.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord y; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetY(nscoord *aY)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aY = mOffset.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* readonly attribute nscoord width; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetWidth(nscoord *aWidth)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aWidth = mSize.width;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord height; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetHeight(nscoord *aHeight)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aHeight = mSize.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsRect rect; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetRect(nsRect **aRect)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsRect rect(mOffset.x, mOffset.y, mSize.width, mSize.height);
|
||||
*aRect = ▭
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute gfx_format format; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetFormat(gfx_format *aFormat)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aFormat = mFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long timeout; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
|
||||
{
|
||||
*aTimeout = mTimeout;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP gfxImageFrame::SetTimeout(PRInt32 aTimeout)
|
||||
{
|
||||
mTimeout = aTimeout;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageBytesPerRow; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetImageBytesPerRow(PRUint32 *aBytesPerRow)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBytesPerRow = mImage->GetLineStride();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageDataLength; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetImageDataLength(PRUint32 *aBitsLength)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBitsLength = mImage->GetBytesPix();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getImageData([array, size_is(length)] out PRUint8 bits, out unsigned long length); */
|
||||
NS_IMETHODIMP gfxImageFrame::GetImageData(PRUint8 **aData, PRUint32 *length)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aData = mImage->GetBits();
|
||||
*length = mImage->GetBytesPix() * mSize.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setImageData ([array, size_is (length), const] in PRUint8 data, in unsigned long length, in long offset); */
|
||||
NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength, PRInt32 aOffset)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRUint8 *imgData = mImage->GetBits();
|
||||
PRInt32 imgLen = mImage->GetBytesPix();
|
||||
|
||||
if (((aOffset + (PRInt32)aLength) > imgLen) || !imgData)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
memcpy(imgData + aOffset, aData, aLength);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long alphaBytesPerRow; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetAlphaBytesPerRow(PRUint32 *aBytesPerRow)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBytesPerRow = mImage->GetAlphaLineStride();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long alphaDataLength; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetAlphaDataLength(PRUint32 *aBitsLength)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aBitsLength = mImage->GetAlphaLineStride() * mSize.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); */
|
||||
NS_IMETHODIMP gfxImageFrame::GetAlphaData(PRUint8 **aData, PRUint32 *length)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
*aData = mImage->GetAlphaBits();
|
||||
*length = mImage->GetAlphaLineStride() * mSize.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setAlphaData ([array, size_is (length), const] in PRUint8 data, in unsigned long length, in long offset); */
|
||||
NS_IMETHODIMP gfxImageFrame::SetAlphaData(const PRUint8 *aData, PRUint32 aLength, PRInt32 aOffset)
|
||||
{
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRUint8 *alphaData = mImage->GetAlphaBits();
|
||||
PRInt32 alphaLen = mImage->GetAlphaLineStride() * mSize.height;
|
||||
|
||||
if (((aOffset + (PRInt32)aLength) > alphaLen) || !alphaData)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
memcpy(alphaData + aOffset, aData, aLength);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP gfxImageFrame::GetInterface(const nsIID & aIID, void * *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
if (NS_SUCCEEDED(QueryInterface(aIID, result)))
|
||||
return NS_OK;
|
||||
if (mImage && aIID.Equals(NS_GET_IID(nsIImage)))
|
||||
return mImage->QueryInterface(aIID, result);
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- 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) 2000-2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsIImage.h"
|
||||
|
||||
#include "nsPoint.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define GFX_IMAGEFRAME_CID \
|
||||
{ /* aa699204-1dd1-11b2-84a9-a280c268e4fb */ \
|
||||
0xaa699204, \
|
||||
0x1dd1, \
|
||||
0x11b2, \
|
||||
{0x84, 0xa9, 0xa2, 0x80, 0xc2, 0x68, 0xe4, 0xfb} \
|
||||
}
|
||||
|
||||
class gfxImageFrame : public gfxIImageFrame,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_GFXIIMAGEFRAME
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
gfxImageFrame();
|
||||
virtual ~gfxImageFrame();
|
||||
|
||||
protected:
|
||||
nsSize mSize;
|
||||
|
||||
private:
|
||||
/* private members */
|
||||
nsCOMPtr<nsIImage> mImage;
|
||||
nsPoint mOffset;
|
||||
|
||||
PRInt32 mTimeout;
|
||||
|
||||
PRPackedBool mInitalized; // 8 bits
|
||||
gfx_format mFormat; // 16 bits
|
||||
};
|
|
@ -21,30 +21,33 @@
|
|||
# Stuart Parmenter <pavlov@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH = ..\..
|
||||
DEPTH=..\..
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
MODULE = gfx2
|
||||
LIBRARY_NAME= gfx2
|
||||
DLL = $(OBJDIR)\$(LIBRARY_NAME).dll
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
MODULE=gfx2
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\gfxImageContainer.obj \
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=gfx2
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
LCFLAGS = -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsGfxFactory.obj \
|
||||
.\$(OBJDIR)\gfxImageFrame.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gfx2_s.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(NULL)
|
||||
|
||||
DIRS = windows
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(DIST)\lib\xpcom.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\components\$(LIBRARY_NAME).dll
|
||||
rm -f $(PDBFILE).pdb
|
||||
$(RM) $(DIST)\lib\$(MODULE).lib
|
||||
$(RM) $(DIST)\bin\components\$(MODULE).dll
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- 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) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
|
||||
#include "gfxImageFrame.h"
|
||||
|
||||
// objects that just require generic constructors
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "windows image frame",
|
||||
GFX_IMAGEFRAME_CID,
|
||||
"@mozilla.org/gfx/image/frame;2",
|
||||
gfxImageFrameConstructor, },
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsGfx2Module", components)
|
||||
|
Загрузка…
Ссылка в новой задаче