зеркало из https://github.com/mozilla/gecko-dev.git
Updating xlib. Not part of the build
This commit is contained in:
Родитель
2eeda04d75
Коммит
cc949a44bd
|
@ -28,6 +28,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = layout
|
||||
LIBRARY_NAME = gfx_xlib
|
||||
IS_COMPONENT = 1
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -40,6 +41,8 @@ CPPSRCS = \
|
|||
nsImageXlib.cpp \
|
||||
nsRegionXlib.cpp \
|
||||
nsRenderingContextXlib.cpp \
|
||||
nsScreenXlib.cpp \
|
||||
nsScreenManagerXlib.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "nsRenderingContextXlib.h"
|
||||
|
@ -105,7 +107,11 @@ NS_IMETHODIMP nsDeviceContextXlib::Init(nsNativeWidget aNativeWidget)
|
|||
void
|
||||
nsDeviceContextXlib::CommonInit(void)
|
||||
{
|
||||
static nscoord dpi = 100;
|
||||
// FIXME: PeterH
|
||||
// This was set to 100 dpi, then later on in the function is was changed
|
||||
// to a default of 96dpi IF we had a preference component. We need to
|
||||
// find a way to get the actual server dpi for a comparison ala GTK.
|
||||
static nscoord dpi = 96;
|
||||
static int initialized = 0;
|
||||
|
||||
if (!initialized) {
|
||||
|
@ -129,8 +135,9 @@ nsDeviceContextXlib::CommonInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
mTwipsToPixels = float(dpi) / float(NSIntPointsToTwips(72));
|
||||
mPixelsToTwips = 1.0f / mTwipsToPixels;
|
||||
// Do extra rounding (based on GTK). KenF
|
||||
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(72)) / float(dpi)));
|
||||
mTwipsToPixels = 1.0f / mPixelsToTwips;
|
||||
|
||||
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("GFX: dpi=%d t2p=%g p2t=%g\n", dpi, mTwipsToPixels, mPixelsToTwips));
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* David Smith <david@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContextXlib_h__
|
||||
|
@ -67,6 +68,7 @@ public:
|
|||
Screen * GetScreen() { return mScreen; }
|
||||
Visual * GetVisual() { return mVisual; }
|
||||
int GetDepth() { return mDepth; }
|
||||
NS_IMETHOD GetDepth( PRUint32 &depth ) { depth=(PRUint32)mDepth;return NS_OK; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* David Smith <david@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "nsDrawingSurfaceXlib.h"
|
||||
|
@ -88,6 +89,10 @@ nsDrawingSurfaceXlib::~nsDrawingSurfaceXlib()
|
|||
if (mImage) {
|
||||
XDestroyImage(mImage);
|
||||
}
|
||||
|
||||
// We are freeing the GC here now [See nsWidget::CreateGC()]
|
||||
if (mGC)
|
||||
XFreeGC(mDisplay, mGC);
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDrawingSurfaceXlib, kIDrawingSurfaceIID)
|
||||
|
@ -108,8 +113,15 @@ nsDrawingSurfaceXlib::Init(Display * aDisplay,
|
|||
mScreen = aScreen;
|
||||
mVisual = aVisual;
|
||||
mDepth = aDepth;
|
||||
// We Ignore the GC we are given, cos it is bad. [See nsWidget::CreateGC()]
|
||||
#if 0
|
||||
mGC = aGC;
|
||||
#endif
|
||||
mDrawable = aDrawable;
|
||||
|
||||
// Create a new GC
|
||||
mGC = XCreateGC(mDisplay, mDrawable, 0, NULL);
|
||||
|
||||
mIsOffscreen = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -128,7 +140,11 @@ nsDrawingSurfaceXlib::Init (Display * aDisplay,
|
|||
mScreen = aScreen;
|
||||
mVisual = aVisual;
|
||||
mDepth = aDepth;
|
||||
// We Ignore the GC we are given, cos it is bad. [See nsWidget::Create()]
|
||||
#if 0
|
||||
mGC = aGC;
|
||||
#endif
|
||||
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
mLockFlags = aFlags;
|
||||
|
@ -140,6 +156,9 @@ nsDrawingSurfaceXlib::Init (Display * aDisplay,
|
|||
mWidth,
|
||||
mHeight,
|
||||
mDepth);
|
||||
// Create a new GC
|
||||
mGC = XCreateGC(mDisplay, mDrawable, 0, NULL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -155,6 +174,12 @@ nsDrawingSurfaceXlib::Lock(PRInt32 aX, PRInt32 aY,
|
|||
NS_ASSERTION(0, "nested lock attempt");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (aWidth == 0 || aHeight == 0)
|
||||
{
|
||||
NS_ASSERTION(0, "Width or Height is 0");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mLocked = PR_TRUE;
|
||||
|
||||
mLockX = aX;
|
||||
|
@ -172,7 +197,7 @@ nsDrawingSurfaceXlib::Lock(PRInt32 aX, PRInt32 aY,
|
|||
*aBits = mImage->data;
|
||||
|
||||
*aWidthBytes = mImage->bytes_per_line;
|
||||
*aStride = mImage->bitmap_pad;
|
||||
*aStride = mImage->bytes_per_line;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Quy Tonthat <quy@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "xp_core.h"
|
||||
|
@ -464,12 +466,17 @@ void nsFontMetricsXlib::RealizeFont()
|
|||
float f;
|
||||
mDeviceContext->GetDevUnitsToAppUnits(f);
|
||||
|
||||
mAscent = nscoord(mFontHandle->ascent * f);
|
||||
mDescent = nscoord(mFontHandle->descent * f);
|
||||
mMaxAscent = nscoord(mFontHandle->ascent * f) ;
|
||||
mMaxDescent = nscoord(mFontHandle->descent * f);
|
||||
mAscent = nscoord(mFontHandle->max_bounds.ascent * f);
|
||||
mDescent = nscoord(mFontHandle->max_bounds.descent * f);
|
||||
mMaxAscent = nscoord(mFontHandle->max_bounds.ascent * f) ;
|
||||
mMaxDescent = nscoord(mFontHandle->max_bounds.descent * f);
|
||||
|
||||
mHeight = nscoord((mFontHandle->max_bounds.ascent +
|
||||
mFontHandle->max_bounds.descent) * f);
|
||||
|
||||
// Until we know what mEmHeight does, we will just set it to mHeight FIXME
|
||||
mEmHeight = mHeight;
|
||||
|
||||
mHeight = nscoord((mFontHandle->ascent + mFontHandle->descent) * f);
|
||||
mMaxAdvance = nscoord(mFontHandle->max_bounds.width * f);
|
||||
|
||||
// 56% of ascent, best guess for non-true type
|
||||
|
@ -2353,7 +2360,7 @@ nsFontMetricsXlib::FindGenericFont(nsFontSearch* aSearch)
|
|||
char name[128];
|
||||
if (mLangGroup) {
|
||||
nsAutoString pref = prefix;
|
||||
pref.Append('.');
|
||||
pref.AppendWithConversion('.');
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
pref.Append(langGroup);
|
||||
|
|
|
@ -18,174 +18,161 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGfxCIID.h"
|
||||
// our local includes for different interfaces
|
||||
|
||||
#include "nsBlender.h"
|
||||
#include "nsFontMetricsXlib.h"
|
||||
#include "nsRenderingContextXlib.h"
|
||||
// aka nsDeviceContextSpecXlib.h
|
||||
#include "nsDeviceContextSpecXlib.h"
|
||||
// aka nsDeviceContextSpecFactoryXlib.h
|
||||
#include "nsDeviceContextSpecFactoryX.h"
|
||||
#include "nsScreenManagerXlib.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsDeviceContextXlib.h"
|
||||
#include "nsImageXlib.h"
|
||||
#include "nsRegionXlib.h"
|
||||
#include "nsDrawingSurfaceXlib.h"
|
||||
#include "nsDeviceContextSpecXlib.h"
|
||||
#include "nsRenderingContextXlib.h"
|
||||
#include "nsDeviceContextSpecFactoryX.h"
|
||||
|
||||
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
|
||||
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
|
||||
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
|
||||
static NS_DEFINE_IID(kCDrawingSurface, NS_DRAWING_SURFACE_CID);
|
||||
// objects that just require generic constructors
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryXlib)
|
||||
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorXlib)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerXlib)
|
||||
|
||||
class nsGfxFactoryXlib : public nsIFactory
|
||||
// our custom constructors
|
||||
|
||||
static nsresult nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFACTORY
|
||||
nsresult rv;
|
||||
|
||||
nsGfxFactoryXlib(const nsCID &aClass);
|
||||
virtual ~nsGfxFactoryXlib();
|
||||
private:
|
||||
nsCID mClassID;
|
||||
nsIScriptableRegion *inst;
|
||||
|
||||
if ( NULL == aResult )
|
||||
{
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = NULL;
|
||||
if (NULL != aOuter)
|
||||
{
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
// create an nsRegionXlib and get the scriptable region from it
|
||||
nsCOMPtr <nsIRegion> rgn;
|
||||
NS_NEWXPCOM(rgn, nsRegionXlib);
|
||||
if (rgn != nsnull)
|
||||
{
|
||||
nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
|
||||
inst = scriptableRgn;
|
||||
}
|
||||
if (NULL == inst)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(inst);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult nsImageManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if ( NULL == aResult )
|
||||
{
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = NULL;
|
||||
if (NULL != aOuter)
|
||||
{
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
// this will return an image manager with a count of 1
|
||||
rv = NS_NewImageManager((nsIImageManager **)aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "Xlib Font Metrics",
|
||||
NS_FONT_METRICS_CID,
|
||||
// "mozilla.gfx.font_metrics.xlib.1",
|
||||
"component://netscape/gfx/fontmetrics",
|
||||
nsFontMetricsXlibConstructor },
|
||||
{ "Xlib Device Context",
|
||||
NS_DEVICE_CONTEXT_CID,
|
||||
// "mozilla.gfx.device_context.xlib.1",
|
||||
"component://netscape/gfx/devicecontext",
|
||||
nsDeviceContextXlibConstructor },
|
||||
{ "Xlib Rendering Context",
|
||||
NS_RENDERING_CONTEXT_CID,
|
||||
// "mozilla.gfx.rendering_context.xlib.1",
|
||||
"component://netscape/gfx/renderingcontext",
|
||||
nsRenderingContextXlibConstructor },
|
||||
{ "Xlib Image",
|
||||
NS_IMAGE_CID,
|
||||
// "mozilla.gfx.image.xlib.1",
|
||||
"component://netscape/gfx/image",
|
||||
nsImageXlibConstructor },
|
||||
{ "Xlib Region",
|
||||
NS_REGION_CID,
|
||||
"mozilla.gfx.region.xlib.1",
|
||||
nsRegionXlibConstructor },
|
||||
{ "Scriptable Region",
|
||||
NS_SCRIPTABLE_REGION_CID,
|
||||
// "mozilla.gfx.scriptable_region.1",
|
||||
"component://netscape/gfx/region",
|
||||
nsScriptableRegionConstructor },
|
||||
{ "Blender",
|
||||
NS_BLENDER_CID,
|
||||
// "mozilla.gfx.blender.1",
|
||||
"component://netscape/gfx/blender",
|
||||
nsBlenderConstructor },
|
||||
{ "Xlib Device Context Spec",
|
||||
NS_DEVICE_CONTEXT_SPEC_CID,
|
||||
// "mozilla.gfx.device_context_spec.xlib.1",
|
||||
"component://netscape/gfx/devicecontextspec",
|
||||
nsDeviceContextSpecXlibConstructor },
|
||||
{ "Xlib Device Context Spec Factory",
|
||||
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
|
||||
// "mozilla.gfx.device_context_spec_factory.xlib.1",
|
||||
"component://netscape/gfx/devicecontextspecfactory",
|
||||
nsDeviceContextSpecFactoryXlibConstructor },
|
||||
{ "Image Manager",
|
||||
NS_IMAGEMANAGER_CID,
|
||||
// "mozilla.gfx.image_manager.1",
|
||||
"component://netscape/gfx/imagemanager",
|
||||
nsImageManagerConstructor },
|
||||
//{ "Xlib Font Enumerator",
|
||||
//NS_FONT_ENUMERATOR_CID,
|
||||
// "mozilla.gfx.font_enumerator.xlib.1",
|
||||
//"component://netscape/gfx/fontenumerator",
|
||||
//nsFontEnumeratorXlibConstructor },
|
||||
{ "Xlib Screen Manager",
|
||||
NS_SCREENMANAGER_CID,
|
||||
// "mozilla.gfx.screenmanager.xlib.1",
|
||||
"component://netscape/gfx/screenmanager",
|
||||
nsScreenManagerXlibConstructor }
|
||||
};
|
||||
|
||||
nsGfxFactoryXlib::nsGfxFactoryXlib(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mClassID = aClass;
|
||||
}
|
||||
NS_IMPL_NSGETMODULE("nsGfxXlibModule", components)
|
||||
|
||||
nsGfxFactoryXlib::~nsGfxFactoryXlib()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult nsGfxFactoryXlib::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// always set this to zero, in case of a failure
|
||||
*aResult = NULL;
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = (void *)(nsIFactory*)this;
|
||||
}
|
||||
|
||||
if (*aResult == NULL) {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
AddRef(); // increase reference count for caller
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsGfxFactoryXlib);
|
||||
NS_IMPL_RELEASE(nsGfxFactoryXlib);
|
||||
|
||||
nsresult nsGfxFactoryXlib::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
|
||||
if (mClassID.Equals(kCFontMetrics)) {
|
||||
nsFontMetricsXlib* fm;
|
||||
NS_NEWXPCOM(fm, nsFontMetricsXlib);
|
||||
inst = (nsISupports *)fm;
|
||||
}
|
||||
else if (mClassID.Equals(kCDeviceContext)) {
|
||||
nsDeviceContextXlib* dc;
|
||||
NS_NEWXPCOM(dc, nsDeviceContextXlib);
|
||||
inst = (nsISupports *)dc;
|
||||
}
|
||||
else if (mClassID.Equals(kCRenderingContext)) {
|
||||
nsRenderingContextXlib* rc;
|
||||
NS_NEWXPCOM(rc, nsRenderingContextXlib);
|
||||
inst = (nsISupports *)((nsIRenderingContext*)rc);
|
||||
}
|
||||
else if (mClassID.Equals(kCImage)) {
|
||||
nsImageXlib* image;
|
||||
NS_NEWXPCOM(image, nsImageXlib);
|
||||
inst = (nsISupports *)image;
|
||||
}
|
||||
else if (mClassID.Equals(kCRegion)) {
|
||||
nsRegionXlib* region;
|
||||
NS_NEWXPCOM(region, nsRegionXlib);
|
||||
inst = (nsISupports *)region;
|
||||
}
|
||||
// XXX blender doesn't exist yet for xlib...
|
||||
// else if (mClassID.Equals(kCBlender)) {
|
||||
// nsBlenderXlib* blender;
|
||||
// NS_NEWXPCOM(blender, nsBlenderXlib);
|
||||
// inst = (nsISupports *)blender;
|
||||
// }
|
||||
else if (mClassID.Equals(kCBlender)) {
|
||||
nsDrawingSurfaceXlib* ds;
|
||||
NS_NEWXPCOM(ds, nsDrawingSurfaceXlib);
|
||||
inst = (nsISupports *)((nsIDrawingSurface *)ds);
|
||||
}
|
||||
else if (mClassID.Equals(kCDeviceContextSpec)) {
|
||||
nsDeviceContextSpecXlib* dcs;
|
||||
NS_NEWXPCOM(dcs, nsDeviceContextSpecXlib);
|
||||
inst = (nsISupports *)dcs;
|
||||
}
|
||||
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
|
||||
nsDeviceContextSpecFactoryXlib* dcs;
|
||||
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryXlib);
|
||||
inst = (nsISupports *)dcs;
|
||||
}
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (res != NS_OK) {
|
||||
// We didn't get the right interface, so clean up
|
||||
delete inst;
|
||||
}
|
||||
// else {
|
||||
// inst->Release();
|
||||
// }
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsGfxFactoryXlib::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports *servMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aFactory = new nsGfxFactoryXlib(aClass);
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return (*aFactory)->QueryInterface(kIFactoryIID, (void **)aFactory);
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -18,15 +18,17 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#ifndef nsImageXlib_h__
|
||||
#define nsImageXlib_h__
|
||||
|
||||
#include "nsIImage.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
|
||||
#include "X11/Xlib.h"
|
||||
#include "X11/Xutil.h"
|
||||
#include "X11/Xos.h"
|
||||
|
||||
class nsImageXlib : public nsIImage {
|
||||
public:
|
||||
|
@ -35,80 +37,143 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
|
||||
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
|
||||
virtual PRInt32 GetHeight();
|
||||
virtual PRInt32 GetWidth();
|
||||
virtual PRUint8* GetBits();
|
||||
virtual void* GetBitInfo();
|
||||
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
|
||||
virtual PRInt32 GetLineStride();
|
||||
|
||||
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
|
||||
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
|
||||
virtual PRInt32 GetDecodedX1() { return mDecodedX1;}
|
||||
virtual PRInt32 GetDecodedY1() { return mDecodedY1;}
|
||||
virtual PRInt32 GetDecodedX2() { return mDecodedX2;}
|
||||
virtual PRInt32 GetDecodedY2() { return mDecodedY2;}
|
||||
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY,
|
||||
PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
virtual nsColorMap* GetColorMap();
|
||||
virtual void ImageUpdated(nsIDeviceContext *aContext,
|
||||
PRUint8 aFlags, nsRect *aUpdateRect);
|
||||
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
nsRect &aSrcRect,
|
||||
nsRect &aTileRect);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect);
|
||||
|
||||
virtual void ImageUpdated(nsIDeviceContext *aContext,
|
||||
PRUint8 aFlags, nsRect *aUpdateRect);
|
||||
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
|
||||
PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
|
||||
PRInt32 aDepth,
|
||||
nsMaskRequirements aMaskRequirements);
|
||||
virtual PRBool IsOptimized();
|
||||
|
||||
virtual nsresult Optimize(nsIDeviceContext* aContext);
|
||||
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
|
||||
|
||||
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
|
||||
virtual PRUint8* GetAlphaBits();
|
||||
virtual PRInt32 GetAlphaWidth();
|
||||
virtual PRInt32 GetAlphaHeight();
|
||||
virtual PRInt32 GetAlphaLineStride();
|
||||
virtual nsIImage* DuplicateImage();
|
||||
|
||||
PRIntn GetSizeImage();
|
||||
void ComputeMetrics();
|
||||
PRInt32 CalcBytesSpan(PRUint32 aWidth);
|
||||
|
||||
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
|
||||
|
||||
virtual PRInt32 GetAlphaLevel();
|
||||
|
||||
void* GetBitInfo();
|
||||
virtual PRBool GetIsRowOrderTopToBottom() { return PR_TRUE; }
|
||||
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
|
||||
virtual PRInt32 GetAlphaLevel();
|
||||
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
|
||||
|
||||
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
|
||||
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
|
||||
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
|
||||
|
||||
private:
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
PRInt32 mDepth;
|
||||
PRInt32 mRowBytes;
|
||||
PRUint8 *mImageBits;
|
||||
PRUint32 mSizeImage;
|
||||
PRInt8 mNumBytesPixel;
|
||||
Pixmap mImagePixmap;
|
||||
Display * mDisplay;
|
||||
/**
|
||||
* Calculate the amount of memory needed for the initialization of the image
|
||||
*/
|
||||
void ComputeMetrics() {
|
||||
mRowBytes = (mWidth * mDepth) >> 5;
|
||||
|
||||
if (((PRUint32)mWidth * mDepth) & 0x1F)
|
||||
mRowBytes++;
|
||||
mRowBytes <<= 2;
|
||||
|
||||
mSizeImage = mRowBytes * mHeight;
|
||||
};
|
||||
void ComputePaletteSize(PRIntn nBitCount);
|
||||
|
||||
private:
|
||||
static unsigned scaled6[1<<6];
|
||||
static unsigned scaled5[1<<5];
|
||||
|
||||
void DrawComposited32(PRBool isLSB, PRBool flipBytes,
|
||||
unsigned offsetX, unsigned offsetY,
|
||||
unsigned width, unsigned height,
|
||||
XImage *ximage, unsigned char *readData);
|
||||
void DrawComposited24(PRBool isLSB, PRBool flipBytes,
|
||||
unsigned offsetX, unsigned offsetY,
|
||||
unsigned width, unsigned height,
|
||||
XImage *ximage, unsigned char *readData);
|
||||
void DrawComposited16(PRBool isLSB, PRBool flipBytes,
|
||||
unsigned offsetX, unsigned offsetY,
|
||||
unsigned width, unsigned height,
|
||||
XImage *ximage, unsigned char *readData);
|
||||
void DrawCompositedGeneral(PRBool isLSB, PRBool flipBytes,
|
||||
unsigned offsetX, unsigned offsetY,
|
||||
unsigned width, unsigned height,
|
||||
XImage *ximage, unsigned char *readData);
|
||||
inline void DrawComposited(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
inline void TilePixmap(Pixmap src, Pixmap dest, PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &destRect, const nsRect &clipRect, PRBool useClip);
|
||||
inline void CreateAlphaBitmap(PRInt32 aWidth, PRInt32 aHeight,
|
||||
nsDrawingSurface aSurface);
|
||||
inline void CreateOffscreenPixmap(PRInt32 aWidth, PRInt32 aHeight,
|
||||
nsDrawingSurface aSurface);
|
||||
inline void DrawImageOffscreen(PRInt32 validX, PRInt32 validY,
|
||||
PRInt32 validWidth, PRInt32 validHeight,
|
||||
nsDrawingSurface aSurface);
|
||||
inline void SetupGCForAlpha(GC aGC, PRInt32 aX, PRInt32 aY);
|
||||
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
PRInt32 mDepth; // bits per pixel
|
||||
PRInt32 mRowBytes;
|
||||
PRUint8 *mImageBits;
|
||||
PRUint8 *mConvertedBits;
|
||||
PRInt32 mSizeImage;
|
||||
PRBool mIsTopToBottom;
|
||||
|
||||
PRInt8 mNumBytesPixel;
|
||||
|
||||
PRInt32 mDecodedX1; //Keeps track of what part of image
|
||||
PRInt32 mDecodedY1; // has been decoded.
|
||||
PRInt32 mDecodedX2;
|
||||
PRInt32 mDecodedY2;
|
||||
|
||||
// for alpha mask
|
||||
PRUint8 *mAlphaBits;
|
||||
Pixmap mAlphaPixmap;
|
||||
PRUint8 mAlphaDepth;
|
||||
PRUint16 mAlphaRowBytes;
|
||||
PRUint16 mAlphaWidth;
|
||||
PRUint16 mAlphaHeight;
|
||||
nsPoint mLocation;
|
||||
|
||||
PRInt32 mDecodedX2;
|
||||
PRInt32 mDecodedY2;
|
||||
|
||||
// alpha layer members
|
||||
PRUint8 *mAlphaBits;
|
||||
Pixmap mAlphaPixmap;
|
||||
PRInt8 mAlphaDepth; // alpha layer depth
|
||||
PRInt16 mAlphaRowBytes; // alpha bytes per row
|
||||
PRInt16 mAlphaWidth; // alpha layer width
|
||||
PRInt16 mAlphaHeight; // alpha layer height
|
||||
nsPoint mLocation; // alpha mask location
|
||||
Pixmap mImagePixmap;
|
||||
Display *mDisplay;
|
||||
|
||||
PRUint8 mFlags; // flags set by ImageUpdated
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "nsRenderingContextXlib.h"
|
||||
|
@ -29,6 +31,8 @@
|
|||
|
||||
static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsRenderingContextXlib, nsIRenderingContext)
|
||||
|
||||
static PRLogModuleInfo * RenderingContextXlibLM = PR_NewLogModule("RenderingContextXlib");
|
||||
|
||||
class GraphicsState
|
||||
|
@ -105,6 +109,7 @@ nsRenderingContextXlib::~nsRenderingContextXlib()
|
|||
NS_IF_RELEASE(mContext);
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsresult
|
||||
nsRenderingContextXlib::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -133,6 +138,7 @@ nsRenderingContextXlib::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
|
||||
NS_IMPL_ADDREF(nsRenderingContextXlib)
|
||||
NS_IMPL_RELEASE(nsRenderingContextXlib)
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsIWidget *aWindow)
|
||||
|
@ -658,6 +664,8 @@ nsRenderingContextXlib::DestroyDrawingSurface(nsDrawingSurface aDS)
|
|||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
|
||||
{
|
||||
nscoord diffX, diffY;
|
||||
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawLine()\n"));
|
||||
if (nsnull == mTMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -665,8 +673,18 @@ nsRenderingContextXlib::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord
|
|||
mTMatrix->TransformCoord(&aX0,&aY0);
|
||||
mTMatrix->TransformCoord(&aX1,&aY1);
|
||||
|
||||
diffX = aX1-aX0;
|
||||
diffY = aY1-aY0;
|
||||
|
||||
if (0!=diffX) {
|
||||
diffX = (diffX>0?1:-1);
|
||||
}
|
||||
if (0!=diffY) {
|
||||
diffY = (diffY>0?1:-1);
|
||||
}
|
||||
|
||||
::XDrawLine(mDisplay, mRenderingSurface->GetDrawable(),
|
||||
mRenderingSurface->GetGC(), aX0, aY0, aX1, aY1);
|
||||
mRenderingSurface->GetGC(), aX0, aY0, aX1 - diffX, aY1 - diffY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1079,8 +1097,14 @@ nsRenderingContextXlib::GetWidth(const char* aString, PRUint32 aLength, nscoord&
|
|||
aWidth = 0;
|
||||
}
|
||||
else {
|
||||
// XXX fix this...
|
||||
int rawWidth = XTextWidth16(mCurrentFont, (XChar2b *)aString, aLength / 2);
|
||||
|
||||
int rawWidth;
|
||||
|
||||
if ((mCurrentFont->min_byte1 == 0) && (mCurrentFont->max_byte1 == 0))
|
||||
rawWidth = XTextWidth(mCurrentFont, (char *)aString, aLength);
|
||||
else
|
||||
rawWidth = XTextWidth16(mCurrentFont, (XChar2b *)aString, aLength / 2);
|
||||
|
||||
aWidth = NSToCoordRound(rawWidth * mP2T);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -1139,6 +1163,7 @@ FoundFont:
|
|||
if (nsnull != aFontID)
|
||||
*aFontID = 0;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1409,6 +1434,26 @@ nsRenderingContextXlib::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoor
|
|||
}
|
||||
#endif
|
||||
|
||||
// this method of DrawTile is not implemented in nsRenderingContextImpl
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawTile(nsIImage *aImage,
|
||||
nscoord aSrcXOffset, nscoord aSrcYOffset,
|
||||
const nsRect &aTileRect)
|
||||
{
|
||||
nsRect tileRect(aTileRect);
|
||||
nsRect srcRect(0, 0, aSrcXOffset, aSrcYOffset);
|
||||
mTMatrix->TransformCoord(&srcRect.x, &srcRect.y, &srcRect.width,
|
||||
&srcRect.height);
|
||||
mTMatrix->TransformCoord(&tileRect.x, &tileRect.y,
|
||||
&tileRect.width, &tileRect.height);
|
||||
|
||||
if((tileRect.width > 0) && (tileRect.height > 0))
|
||||
((nsImageXlib*)aImage)->DrawTile(*this, mRenderingSurface, srcRect.width, srcRect.height, tileRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#ifndef nsRenderingContextXlib_h___
|
||||
|
@ -168,8 +169,8 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
|
|||
// in nsRenderingContextImpl
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight);
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&);
|
||||
#endif
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&);
|
||||
|
||||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "nsScreenManagerXlib.h"
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#ifndef nsScreenManagerXlib_h___
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#include "nsScreenXlib.h"
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
*/
|
||||
|
||||
#ifndef nsScreenXlib_h___
|
||||
|
|
Загрузка…
Ссылка в новой задаче