Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions | Variables
nsGfxFactoryOS2.cpp File Reference
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsBlender.h"
#include "nsFontMetricsOS2.h"
#include "nsRenderingContextOS2.h"
#include "nsDeviceContextSpecOS2.h"
#include "nsDeviceContextSpecFactoryO.h"
#include "nsScreenManagerOS2.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextOS2.h"
#include "nsImageOS2.h"
#include "nsRegionOS2.h"
#include "nsPrintOptionsOS2.h"
#include "nsFontList.h"
#include "nsPrintSession.h"
#include "gfxImageFrame.h"
#include "nsIServiceManager.h"
#include "prenv.h"
#include "nsOS2Uni.h"
#include "nsPaletteOS2.h"

Go to the source code of this file.

Defines

#define HKEY_LOCAL_MACHINE   0xFFFFFFEFL
#define HKEY_CURRENT_USER   0xFFFFFFEEL
#define READ_CONTROL   0x00020000
#define KEY_QUERY_VALUE   0x0001
#define KEY_ENUMERATE_SUB_KEYS   0x0008
#define KEY_NOTIFY   0x0010
#define KEY_READ
#define ERROR_SUCCESS   0L

Typedefs

typedef ULONG HKEY

Functions

static PRBool UseFTFunctions ()
static NS_IMETHODIMP nsFontMetricsOS2Constructor (nsISupports *aOuter, REFNSIID aIID, void **aResult)
static NS_IMETHODIMP nsScriptableRegionConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult)
 nsGfxOS2ModuleDtor (nsIModule *self)

Variables

static const nsModuleComponentInfo components []

Define Documentation

Definition at line 94 of file nsGfxFactoryOS2.cpp.

#define HKEY_CURRENT_USER   0xFFFFFFEEL

Definition at line 87 of file nsGfxFactoryOS2.cpp.

#define HKEY_LOCAL_MACHINE   0xFFFFFFEFL

Definition at line 86 of file nsGfxFactoryOS2.cpp.

Definition at line 90 of file nsGfxFactoryOS2.cpp.

#define KEY_NOTIFY   0x0010

Definition at line 91 of file nsGfxFactoryOS2.cpp.

#define KEY_QUERY_VALUE   0x0001

Definition at line 89 of file nsGfxFactoryOS2.cpp.

Value:
READ_CONTROL | KEY_QUERY_VALUE | \
                                KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY

Definition at line 92 of file nsGfxFactoryOS2.cpp.

#define READ_CONTROL   0x00020000

Definition at line 88 of file nsGfxFactoryOS2.cpp.


Typedef Documentation

typedef ULONG HKEY

Definition at line 85 of file nsGfxFactoryOS2.cpp.


Function Documentation

static NS_IMETHODIMP nsFontMetricsOS2Constructor ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 211 of file nsGfxFactoryOS2.cpp.

{
  *aResult = nsnull;

  if (aOuter)
    return NS_ERROR_NO_AGGREGATION;

  nsFontMetricsOS2* result;
  if (UseFTFunctions())
    result = new nsFontMetricsOS2FT();
  else
    result = new nsFontMetricsOS2();

  if (! result)
    return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv;
  NS_ADDREF(result);
  rv = result->QueryInterface(aIID, aResult);
  NS_RELEASE(result);
  return rv;
}

Here is the call graph for this function:

Definition at line 359 of file nsGfxFactoryOS2.cpp.

{
  OS2Uni::FreeUconvObjects();
  nsPaletteOS2::FreeGlobalPalette();
//  nsRenderingContextOS2::Shutdown();
}

Here is the call graph for this function:

static NS_IMETHODIMP nsScriptableRegionConstructor ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 236 of file nsGfxFactoryOS2.cpp.

{
  nsresult rv;

  nsIScriptableRegion *inst = NULL;

  if ( !aResult )
  {
    rv = NS_ERROR_NULL_POINTER;
    return rv;
  }
  *aResult = nsnull;
  if (aOuter)
  {
    rv = NS_ERROR_NO_AGGREGATION;
    return rv;
  }
  // create an nsRegionOS2 and get the scriptable region from it
  nsCOMPtr <nsIRegion> rgn;
  NS_NEWXPCOM(rgn, nsRegionOS2);
  nsCOMPtr<nsIScriptableRegion> scriptableRgn;
  if (rgn != nsnull)
  {
    scriptableRgn = new nsScriptableRegion(rgn);
    inst = scriptableRgn;
  }
  if (!inst)
  {
    rv = NS_ERROR_OUT_OF_MEMORY;
    return rv;
  }
  NS_ADDREF(inst);
  // release our variable above now that we have created our owning
  // reference - we don't want this to go out of scope early!
  scriptableRgn = nsnull;
  rv = inst->QueryInterface(aIID, aResult);
  NS_RELEASE(inst);

  return rv;
}

Here is the call graph for this function:

static PRBool UseFTFunctions ( ) [static]

Definition at line 97 of file nsGfxFactoryOS2.cpp.

{
  static PRBool init = PR_FALSE;
  if (!init) {
    init = PR_TRUE;

    // For now, since this is somewhat experimental, we'll check for an
    // environment variable, rather than making this the default for anyone
    // that uses the FT2LIB.
    char* useFT = PR_GetEnv("MOZILLA_USE_EXTENDED_FT2LIB");
    if (useFT == nsnull || *useFT == '\0' || stricmp(useFT, "t") != 0) {
      return PR_FALSE;
    }

    // Test for availability of registry functions and query their addresses
    APIRET rc;
    HMODULE hmod = NULLHANDLE;
    char LoadError[CCHMAXPATH];
    rc = DosLoadModule(LoadError, CCHMAXPATH, "REGISTRY", &hmod);
    if (rc != NO_ERROR) {
      NS_WARNING("REGISTRY.DLL could not be loaded");
      return PR_FALSE;
    }
    LONG _System (*APIENTRY RegOpenKeyEx)(HKEY, const char*, ULONG, ULONG,
                                           HKEY* );
    LONG _System (*APIENTRY RegQueryValueEx)(HKEY, const char*, ULONG*, ULONG*,
                                              UCHAR*, ULONG*);

    rc = DosQueryProcAddr(hmod, 0L, "RegOpenKeyExA", (PFN*)&RegOpenKeyEx);
    rc += DosQueryProcAddr(hmod, 0L, "RegQueryValueExA", (PFN*)&RegQueryValueEx);
    if (rc != NO_ERROR) {
      NS_WARNING("Registry function(s) were not found in REGISTRY.DLL");
      DosFreeModule(hmod);
      return PR_FALSE;
    }

    // Is FT2LIB enabled?
    HKEY key;
    LONG result = RegOpenKeyEx(HKEY_CURRENT_USER,
                               "Software\\Innotek\\InnoTek Font Engine", 0,
                               KEY_READ, &key);
    if (result != ERROR_SUCCESS) {
      result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                            "Software\\Innotek\\InnoTek Font Engine", 0,
                            KEY_READ, &key);
      if (result != ERROR_SUCCESS) {
        DosFreeModule(hmod);
        return PR_FALSE;
      }
    }

    ULONG value;
    ULONG length = sizeof(value);
    result = RegQueryValueEx(key, "Enabled", NULL, NULL, (UCHAR*)&value,
                             &length);
    if (result != ERROR_SUCCESS || value == 0) {
      // check if "Innotek Font Engine" is disabled (value == 0)
      DosFreeModule(hmod);
      return PR_FALSE;
    }

    // Is FT2LIB enabled for this app?
    PPIB ppib;
    PTIB ptib;
    char buffer[CCHMAXPATH], name[_MAX_FNAME], ext[_MAX_EXT], keystr[256];
    DosGetInfoBlocks(&ptib, &ppib);
    DosQueryModuleName(ppib->pib_hmte, CCHMAXPATH, buffer);
    _splitpath(buffer, NULL, NULL, name, ext);
    strcpy(keystr, "Software\\Innotek\\InnoTek Font Engine\\Applications\\");
    strcat(keystr, name);
    strcat(keystr, ext);
    result = RegOpenKeyEx(HKEY_CURRENT_USER, keystr, 0, KEY_READ, &key);
    if (result != ERROR_SUCCESS) {
      result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keystr, 0, KEY_READ, &key);
      if (result != ERROR_SUCCESS) {
        DosFreeModule(hmod);
        return PR_FALSE;
      }
    }
    result = RegQueryValueEx(key, "Enabled", NULL, NULL, (UCHAR*)&value,
                             &length);
    if (result != ERROR_SUCCESS || value == 0) {
      // check if FT2LIB is disabled for our application (value == 0)
      DosFreeModule(hmod);
      return PR_FALSE;
    }

    // REGISTRY.DLL use ends here
    DosFreeModule(hmod);

    // Load lib and functions
    rc = DosLoadModule(LoadError, 0, "FT2LIB", &hmod);
    if (rc == NO_ERROR) {
      rc = DosQueryProcAddr(hmod, 0, "Ft2EnableFontEngine",
                            (PFN*)&nsFontMetricsOS2FT::pfnFt2EnableFontEngine);
      if (rc == NO_ERROR) {
        DosQueryProcAddr(hmod, 0, "Ft2FontSupportsUnicodeChar1",
                         (PFN*)&nsFontOS2FT::pfnFt2FontSupportsUnicodeChar1);
#ifdef USE_EXPANDED_FREETYPE_FUNCS
        DosQueryProcAddr(hmod, 0, "Ft2QueryTextBoxW",
                         (PFN*)&nsFontOS2FT::pfnFt2QueryTextBoxW);
        DosQueryProcAddr(hmod, 0, "Ft2CharStringPosAtW",
                         (PFN*)&nsFontOS2FT::pfnFt2CharStringPosAtW);
#endif /* use_expanded_freetype_funcs */
        NS_WARNING("*** Now using Freetype functions ***");
        nsFontMetricsOS2::gUseFTFunctions = PR_TRUE;
      }
      DosFreeModule(hmod);
    }
  }
  return nsFontMetricsOS2::gUseFTFunctions;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 277 of file nsGfxFactoryOS2.cpp.