mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 449283: DPI on n810 is incorrect, r=roc
This commit is contained in:
parent
141db18455
commit
50bf449113
@ -221,7 +221,7 @@ nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
|
||||
|
||||
if (!MOZ_pango_font_description_get_size_is_absolute(desc)) {
|
||||
// |size| is in pango-points, so convert to pixels.
|
||||
size *= gfxPlatformGtk::DPI() / POINTS_PER_INCH_FLOAT;
|
||||
size *= float(gfxPlatform::GetDPI()) / POINTS_PER_INCH_FLOAT;
|
||||
}
|
||||
|
||||
// |size| is now pixels
|
||||
|
@ -79,7 +79,7 @@ nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
|
||||
aFontStyle->weight = qFont.weight();
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle->size = qFont.pointSizeF() * float(gfxQtPlatform::DPI()) / 72.0f;
|
||||
aFontStyle->size = qFont.pointSizeF() * float(gfxPlatform::GetDPI()) / 72.0f;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "nsThebesDeviceContext.h"
|
||||
#include "nsThebesRenderingContext.h"
|
||||
#include "gfxUserFontSet.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIView.h"
|
||||
@ -656,11 +657,30 @@ nsThebesDeviceContext::SetDPI()
|
||||
}
|
||||
|
||||
// PostScript, PDF and Mac (when printing) all use 72 dpi
|
||||
if (mPrintingSurface &&
|
||||
(mPrintingSurface->GetType() == gfxASurface::SurfaceTypePDF ||
|
||||
mPrintingSurface->GetType() == gfxASurface::SurfaceTypePS ||
|
||||
mPrintingSurface->GetType() == gfxASurface::SurfaceTypeQuartz)) {
|
||||
dpi = 72;
|
||||
// Use a printing DC to determine the other dpi values
|
||||
if (mPrintingSurface) {
|
||||
switch (mPrintingSurface->GetType()) {
|
||||
case gfxASurface::SurfaceTypePDF:
|
||||
case gfxASurface::SurfaceTypePS:
|
||||
case gfxASurface::SurfaceTypeQuartz:
|
||||
dpi = 72;
|
||||
break;
|
||||
#ifdef XP_WIN
|
||||
case gfxASurface::SurfaceTypeWin32:
|
||||
case gfxASurface::SurfaceTypeWin32Printing:
|
||||
PRInt32 OSVal = GetDeviceCaps(GetPrintHDC(), LOGPIXELSY);
|
||||
dpi = 144;
|
||||
mPrintingScale = float(OSVal) / dpi;
|
||||
break;
|
||||
#endif
|
||||
#ifdef XP_OS2
|
||||
case gfxASurface::SurfaceTypeOS2:
|
||||
LONG lDPI;
|
||||
if (DevQueryCaps(GetPrintHDC(), CAPS_VERTICAL_FONT_RES, 1, &lDPI))
|
||||
dpi = lDPI;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
dotsArePixels = PR_FALSE;
|
||||
} else {
|
||||
nsresult rv;
|
||||
@ -676,67 +696,7 @@ nsThebesDeviceContext::SetDPI()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MOZ_ENABLE_GTK2)
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
gtk_settings_get_for_screen(screen); // Make sure init is run so we have a resolution
|
||||
PRInt32 OSVal = PRInt32(round(gdk_screen_get_resolution(screen)));
|
||||
|
||||
if (prefDPI == 0) // Force the use of the OS dpi
|
||||
dpi = OSVal;
|
||||
else // Otherwise, the minimum dpi is 96dpi
|
||||
dpi = PR_MAX(OSVal, 96);
|
||||
|
||||
#elif defined(XP_WIN)
|
||||
// XXX we should really look at the widget if !dc but it is currently always null
|
||||
HDC dc = GetPrintHDC();
|
||||
if (dc) {
|
||||
PRInt32 OSVal = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
|
||||
dpi = 144;
|
||||
mPrintingScale = float(OSVal)/dpi;
|
||||
dotsArePixels = PR_FALSE;
|
||||
} else {
|
||||
dc = GetDC((HWND)nsnull);
|
||||
|
||||
PRInt32 OSVal = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
|
||||
ReleaseDC((HWND)nsnull, dc);
|
||||
|
||||
if (OSVal != 0)
|
||||
dpi = OSVal;
|
||||
}
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
// get a printer DC if available, otherwise create a new (memory) DC
|
||||
HDC dc = GetPrintHDC();
|
||||
PRBool doCloseDC = PR_FALSE;
|
||||
if (dc <= 0) { // test for NULLHANDLE/DEV_ERROR or HDC_ERROR
|
||||
// create DC compatible with the screen
|
||||
dc = DevOpenDC((HAB)1, OD_MEMORY,"*",0L, NULL, NULLHANDLE);
|
||||
doCloseDC = PR_TRUE;
|
||||
}
|
||||
if (dc > 0) {
|
||||
// we do have a DC and we can query the DPI setting from it
|
||||
LONG lDPI;
|
||||
if (DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &lDPI))
|
||||
dpi = lDPI;
|
||||
if (doCloseDC)
|
||||
DevCloseDC(dc);
|
||||
}
|
||||
if (dpi < 0) // something didn't work before, fall back to hardcoded DPI value
|
||||
dpi = 96;
|
||||
#elif defined(XP_MACOSX)
|
||||
|
||||
// we probably want to actually get a real DPI here?
|
||||
dpi = 96;
|
||||
|
||||
#elif defined(MOZ_WIDGET_QT)
|
||||
// TODO: get real DPI here with Qt methods
|
||||
dpi = 96;
|
||||
#else
|
||||
#error undefined platform dpi
|
||||
#endif
|
||||
|
||||
dpi = gfxPlatform::GetDPI();
|
||||
if (prefDPI > 0 && !mPrintingSurface)
|
||||
dpi = prefDPI;
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void InitDisplayCaps();
|
||||
|
||||
static gfxFontconfigUtils *sFontconfigUtils;
|
||||
|
||||
private:
|
||||
|
@ -303,10 +303,27 @@ public:
|
||||
*/
|
||||
static qcms_transform* GetCMSRGBATransform();
|
||||
|
||||
/**
|
||||
* Return display DPI
|
||||
*/
|
||||
static PRInt32 GetDPI() {
|
||||
if (sDPI < 0) {
|
||||
gfxPlatform::GetPlatform()->InitDisplayCaps();
|
||||
}
|
||||
NS_ASSERTION(sDPI > 0, "Something is wrong");
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
protected:
|
||||
gfxPlatform() { }
|
||||
virtual ~gfxPlatform();
|
||||
|
||||
/**
|
||||
* Initialize any needed display metrics (such as DPI)
|
||||
*/
|
||||
virtual void InitDisplayCaps();
|
||||
static PRInt32 sDPI;
|
||||
|
||||
private:
|
||||
virtual qcms_profile* GetPlatformCMSOutputProfile();
|
||||
|
||||
|
@ -121,14 +121,6 @@ public:
|
||||
void SetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<FontEntry> >& aFontEntryList);
|
||||
#endif
|
||||
|
||||
static double DPI() {
|
||||
if (sDPI < 0.0) {
|
||||
InitDPI();
|
||||
}
|
||||
NS_ASSERTION(sDPI > 0.0, "Something is wrong");
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
#ifndef MOZ_PANGO
|
||||
FT_Library GetFTLibrary();
|
||||
#endif
|
||||
@ -138,9 +130,8 @@ public:
|
||||
GdkDrawable *GetGdkDrawable(gfxASurface *target);
|
||||
|
||||
protected:
|
||||
static void InitDPI();
|
||||
void InitDisplayCaps();
|
||||
|
||||
static double sDPI;
|
||||
static gfxFontconfigUtils *sFontconfigUtils;
|
||||
|
||||
private:
|
||||
|
@ -83,20 +83,11 @@ public:
|
||||
PRBool GetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<FontEntry> > *aFontEntryList);
|
||||
void SetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<FontEntry> >& aFontEntryList);
|
||||
|
||||
static PRInt32 DPI() {
|
||||
if (sDPI == -1) {
|
||||
InitDPI();
|
||||
}
|
||||
NS_ASSERTION(sDPI > 0, "Something is wrong");
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
FT_Library GetFTLibrary();
|
||||
|
||||
protected:
|
||||
static void InitDPI();
|
||||
void InitDisplayCaps();
|
||||
|
||||
static PRInt32 sDPI;
|
||||
static gfxFontconfigUtils *sFontconfigUtils;
|
||||
|
||||
private:
|
||||
|
@ -163,6 +163,8 @@ private:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void InitDisplayCaps();
|
||||
|
||||
RenderMode mRenderMode;
|
||||
|
||||
private:
|
||||
|
@ -219,3 +219,22 @@ gfxOS2Platform::FindFontForChar(PRUint32 aCh, gfxOS2Font *aFont)
|
||||
mCodepointsWithNoFonts.set(aCh);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
gfxOS2Platform::InitDisplayCaps()
|
||||
{
|
||||
// create DC compatible with the screen
|
||||
HDC dc = DevOpenDC((HAB)1, OD_MEMORY,"*",0L, NULL, NULLHANDLE);
|
||||
if (dc > 0) {
|
||||
// we do have a DC and we can query the DPI setting from it
|
||||
LONG lDPI;
|
||||
if (DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &lDPI))
|
||||
gfxPlatform::sDPI = lDPI;
|
||||
DevCloseDC(dc);
|
||||
}
|
||||
|
||||
if (gfxPlatform::sDPI <= 0) {
|
||||
// Fall back to something sane
|
||||
gfxPlatform::sDPI = 96;
|
||||
}
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ gfx_pango_fc_font_describe(PangoFont *font)
|
||||
gfxFcFont *gfxFont = gfxPangoFcFont::GfxFont(self);
|
||||
if (gfxFont) {
|
||||
double pixelsize = gfxFont->GetStyle()->size;
|
||||
double dpi = gfxPlatformGtk::DPI();
|
||||
double dpi = gfxPlatform::GetDPI();
|
||||
gint size = moz_pango_units_from_double(pixelsize * dpi / 72.0);
|
||||
pango_font_description_set_size(result, size);
|
||||
}
|
||||
@ -1784,8 +1784,8 @@ gfx_pango_font_map_get_resolution(PangoFcFontMap *fcfontmap,
|
||||
PangoContext *context)
|
||||
{
|
||||
// This merely enables the FC_SIZE field of the pattern to be accurate.
|
||||
// We use gfxPlatformGtk::DPI() much of the time...
|
||||
return gfxPlatformGtk::DPI();
|
||||
// We use gfxPlatform::GetDPI() much of the time...
|
||||
return gfxPlatform::GetDPI();
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
|
@ -73,6 +73,8 @@
|
||||
|
||||
gfxPlatform *gPlatform = nsnull;
|
||||
|
||||
PRInt32 gfxPlatform::sDPI = -1;
|
||||
|
||||
// These two may point to the same profile
|
||||
static qcms_profile *gCMSOutputProfile = nsnull;
|
||||
static qcms_profile *gCMSsRGBProfile = nsnull;
|
||||
@ -764,3 +766,10 @@ static void MigratePrefs()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::InitDisplayCaps()
|
||||
{
|
||||
// Fall back to something sane
|
||||
gfxPlatform::sDPI = 96;
|
||||
}
|
||||
|
@ -91,7 +91,13 @@
|
||||
#include FT_FREETYPE_H
|
||||
#endif
|
||||
|
||||
double gfxPlatformGtk::sDPI = -1.0;
|
||||
#ifdef MOZ_PLATFORM_HILDON
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
#endif
|
||||
|
||||
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nsnull;
|
||||
|
||||
#ifndef MOZ_PANGO
|
||||
@ -128,8 +134,6 @@ gfxPlatformGtk::gfxPlatformGtk()
|
||||
gCodepointsWithNoFonts = new gfxSparseBitSet();
|
||||
UpdateFontList();
|
||||
#endif
|
||||
|
||||
InitDPI();
|
||||
}
|
||||
|
||||
gfxPlatformGtk::~gfxPlatformGtk()
|
||||
@ -523,16 +527,46 @@ gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* static */
|
||||
void
|
||||
gfxPlatformGtk::InitDPI()
|
||||
gfxPlatformGtk::InitDisplayCaps()
|
||||
{
|
||||
sDPI = gdk_screen_get_resolution(gdk_screen_get_default());
|
||||
#if defined(MOZ_PLATFORM_HILDON)
|
||||
// Check the cached value
|
||||
if (gfxPlatform::sDPI == -1) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
rv = NS_NewLocalFile(NS_LITERAL_STRING("/proc/component_version"),
|
||||
PR_TRUE, getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIInputStream> fileStream;
|
||||
NS_NewLocalFileInputStream(getter_AddRefs(fileStream), file);
|
||||
nsCOMPtr<nsILineInputStream> lineStream = do_QueryInterface(fileStream);
|
||||
|
||||
// Extract the product code from the component_version file
|
||||
nsCAutoString buffer;
|
||||
PRBool isMore = PR_TRUE;
|
||||
if (NS_SUCCEEDED(lineStream->ReadLine(buffer, &isMore))) {
|
||||
if (StringEndsWith(buffer, NS_LITERAL_CSTRING("RX-51"))) {
|
||||
gfxPlatform::sDPI = 265; // It's an N900
|
||||
}
|
||||
else if (StringEndsWith(buffer, NS_LITERAL_CSTRING("RX-48"))) {
|
||||
gfxPlatform::sDPI = 225; // It's an N810
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
gtk_settings_get_for_screen(screen); // Make sure init is run so we have a resolution
|
||||
gfxPlatform::sDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
|
||||
#endif
|
||||
|
||||
if (sDPI <= 0.0) {
|
||||
if (gfxPlatform::sDPI <= 0.0) {
|
||||
// Fall back to something sane
|
||||
sDPI = 96.0;
|
||||
gfxPlatform::sDPI = 96.0;
|
||||
} else {
|
||||
// Minimum DPI is 96
|
||||
gfxPlatform::sDPI = PR_MAX(sDPI, 96);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,6 @@
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
PRInt32 gfxQtPlatform::sDPI = -1;
|
||||
gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nsnull;
|
||||
static cairo_user_data_key_t cairo_qt_pixmap_key;
|
||||
static void do_qt_pixmap_unref (void *data)
|
||||
@ -98,8 +97,6 @@ gfxQtPlatform::gfxQtPlatform()
|
||||
gPrefFonts->Init(100);
|
||||
gCodepointsWithNoFonts = new gfxSparseBitSet();
|
||||
UpdateFontList();
|
||||
|
||||
InitDPI();
|
||||
}
|
||||
|
||||
gfxQtPlatform::~gfxQtPlatform()
|
||||
@ -354,23 +351,12 @@ gfxQtPlatform::CreateFontGroup(const nsAString &aFamilies,
|
||||
return new gfxFT2FontGroup(aFamilies, aStyle);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
gfxQtPlatform::InitDPI()
|
||||
{
|
||||
if (sDPI <= 0) {
|
||||
// Fall back to something sane
|
||||
sDPI = 96;
|
||||
}
|
||||
}
|
||||
|
||||
qcms_profile*
|
||||
gfxQtPlatform::GetPlatformCMSOutputProfile()
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
FT_Library
|
||||
gfxQtPlatform::GetFTLibrary()
|
||||
{
|
||||
|
@ -981,3 +981,14 @@ gfxWindowsPlatform::GetFTLibrary()
|
||||
return gPlatformFTLibrary;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
gfxWindowsPlatform::InitDisplayCaps()
|
||||
{
|
||||
HDC dc = GetDC((HWND)nsnull);
|
||||
|
||||
gfxPlatform::sDPI = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
|
||||
ReleaseDC((HWND)nsnull, dc);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user