mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-15 11:13:29 +00:00
use the macros for NS_IMPL_ISUPPORTS[0-3]
make nsImageGTK a bit happier when it gets 8bit images remove excess code
This commit is contained in:
parent
37aa057cc9
commit
195848b693
@ -38,8 +38,8 @@
|
||||
#define GDK_COLOR_TO_NS_RGB(c) \
|
||||
((nscolor) NS_RGB(c.red, c.green, c.blue))
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextGTK, nsIDeviceContext)
|
||||
|
||||
nsDeviceContextGTK::nsDeviceContextGTK()
|
||||
{
|
||||
@ -63,12 +63,7 @@ nsDeviceContextGTK::~nsDeviceContextGTK()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextGTK, kDeviceContextIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextGTK)
|
||||
NS_IMPL_RELEASE(nsDeviceContextGTK)
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
|
||||
{
|
||||
@ -83,7 +78,7 @@ NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
|
||||
if (!initialized) {
|
||||
initialized = 1;
|
||||
nsIPref* prefs = nsnull;
|
||||
nsresult res = nsServiceManager::GetService(kPrefCID, kIPrefIID,
|
||||
nsresult res = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref),
|
||||
(nsISupports**) &prefs);
|
||||
if (NS_SUCCEEDED(res) && prefs) {
|
||||
PRInt32 intVal = 96;
|
||||
@ -414,7 +409,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCDeviceContextPS,
|
||||
nsnull,
|
||||
nsIDeviceContextPS::GetIID(),
|
||||
NS_GET_IID(nsIDeviceContextPS),
|
||||
(void **)&dcps);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context");
|
||||
@ -423,7 +418,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
|
||||
dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
|
||||
(nsIDeviceContext*)this);
|
||||
|
||||
rv = dcps->QueryInterface(nsIDeviceContext::GetIID(),
|
||||
rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
|
||||
(void **)&aContext);
|
||||
|
||||
NS_RELEASE(dcps);
|
||||
|
@ -27,8 +27,7 @@
|
||||
#endif /* USE_SHM */
|
||||
#include "nsDrawingSurfaceGTK.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID);
|
||||
static NS_DEFINE_IID(kIDrawingSurfaceGTKIID, NS_IDRAWING_SURFACE_GTK_IID);
|
||||
NS_IMPL_ISUPPORTS2(nsDrawingSurfaceGTK, nsIDrawingSurface, nsIDrawingSurfaceGTK)
|
||||
|
||||
nsDrawingSurfaceGTK :: nsDrawingSurfaceGTK()
|
||||
{
|
||||
@ -72,45 +71,6 @@ nsDrawingSurfaceGTK :: ~nsDrawingSurfaceGTK()
|
||||
::gdk_image_destroy(mImage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(kIDrawingSurfaceIID))
|
||||
{
|
||||
nsIDrawingSurface* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIDrawingSurfaceGTKIID))
|
||||
{
|
||||
nsDrawingSurfaceGTK* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
nsIDrawingSurface* tmp = this;
|
||||
nsISupports* tmp2 = tmp;
|
||||
*aInstancePtr = (void*) tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDrawingSurfaceGTK);
|
||||
NS_IMPL_RELEASE(nsDrawingSurfaceGTK);
|
||||
|
||||
|
||||
/**
|
||||
* Lock a rect of a drawing surface and return a
|
||||
* pointer to the upper left hand corner of the
|
||||
|
@ -31,6 +31,8 @@
|
||||
class nsIDrawingSurfaceGTK : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_GTK_IID)
|
||||
|
||||
/**
|
||||
* Initialize a drawing surface using a windows DC.
|
||||
* aDC is "owned" by the drawing surface until the drawing
|
||||
|
@ -33,7 +33,9 @@
|
||||
// ctor, dtor and update.
|
||||
#undef TRACE_IMAGE_ALLOCATION
|
||||
|
||||
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsImageGTK, nsIImage)
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
@ -47,7 +49,12 @@ nsImageGTK::nsImageGTK()
|
||||
mAlphaBits = nsnull;
|
||||
mAlphaPixmap = nsnull;
|
||||
mImagePixmap = nsnull;
|
||||
|
||||
mAlphaDepth = 0;
|
||||
mRowBytes = 0;
|
||||
mSizeImage = 0;
|
||||
mAlphaHeight = 0;
|
||||
mAlphaWidth = 0;
|
||||
mConvertedBits = nsnull;
|
||||
#ifdef TRACE_IMAGE_ALLOCATION
|
||||
printf("nsImageGTK::nsImageGTK(this=%p)\n",
|
||||
this);
|
||||
@ -81,8 +88,6 @@ nsImageGTK::~nsImageGTK()
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsImageGTK, kIImageIID);
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
|
||||
@ -159,10 +164,14 @@ nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
|
||||
break;
|
||||
|
||||
case nsMaskRequirements_kNeeds8Bit:
|
||||
mAlphaBits = nsnull;
|
||||
mAlphaWidth = 0;
|
||||
mAlphaHeight = 0;
|
||||
mAlphaRowBytes = aWidth;
|
||||
mAlphaDepth = 8;
|
||||
|
||||
// 32-bit align each row
|
||||
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
|
||||
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
|
||||
mAlphaWidth = aWidth;
|
||||
mAlphaHeight = aHeight;
|
||||
g_print("TODO: want an 8bit mask for an image..\n");
|
||||
break;
|
||||
}
|
||||
|
@ -37,9 +37,7 @@ nsRegionGTK::~nsRegionGTK()
|
||||
mRegion = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsRegionGTK, nsIRegion)
|
||||
NS_IMPL_ADDREF(nsRegionGTK)
|
||||
NS_IMPL_RELEASE(nsRegionGTK)
|
||||
NS_IMPL_ISUPPORTS1(nsRegionGTK, nsIRegion)
|
||||
|
||||
nsresult nsRegionGTK::Init(void)
|
||||
{
|
||||
|
@ -28,6 +28,9 @@
|
||||
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsRenderingContextGTK, nsIRenderingContext)
|
||||
|
||||
|
||||
#define NSRECT_TO_GDKRECT(ns,gdk) \
|
||||
PR_BEGIN_MACRO \
|
||||
gdk.x = ns.x; \
|
||||
@ -36,7 +39,6 @@
|
||||
gdk.height = ns.height; \
|
||||
PR_END_MACRO
|
||||
|
||||
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
|
||||
nsRenderingContextGTK::nsRenderingContextGTK()
|
||||
{
|
||||
@ -87,9 +89,6 @@ nsRenderingContextGTK::~nsRenderingContextGTK()
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsRenderingContextGTK, kRenderingContextIID)
|
||||
NS_IMPL_ADDREF(nsRenderingContextGTK)
|
||||
NS_IMPL_RELEASE(nsRenderingContextGTK)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
|
||||
nsIWidget *aWindow)
|
||||
@ -103,7 +102,6 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
|
||||
|
||||
if (mSurface)
|
||||
{
|
||||
#ifndef NS_GTK_REF
|
||||
// we want to ref the window here so that we can unref in the drawing surface.
|
||||
// otherwise, we can not unref and that causes windows that are created in the
|
||||
// drawing surface not to be freed.
|
||||
@ -120,9 +118,6 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
|
||||
gdk_rgb_get_visual()->depth);
|
||||
}
|
||||
|
||||
#else
|
||||
GdkDrawable *win = (GdkDrawable *)aWindow->GetNativeData(NS_NATIVE_WINDOW);
|
||||
#endif
|
||||
GdkGC *gc = (GdkGC *)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
|
||||
mSurface->Init(win,gc);
|
||||
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <limits.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
|
||||
extern "C" gint nsTimerExpired(gpointer aCallData);
|
||||
|
||||
/*
|
||||
@ -82,6 +80,8 @@ void TimerImpl::FireTimeout()
|
||||
// mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsTimer, nsITimer)
|
||||
|
||||
|
||||
TimerImpl::TimerImpl()
|
||||
{
|
||||
@ -162,8 +162,6 @@ TimerImpl::Init(PRUint32 aDelay)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
|
||||
|
||||
|
||||
void
|
||||
TimerImpl::Cancel()
|
||||
@ -186,7 +184,7 @@ NS_GFXNONXP nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
return timer->QueryInterface(NS_GET_IID(nsITimer), (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
gint nsTimerExpired(gpointer aCallData)
|
||||
|
Loading…
Reference in New Issue
Block a user