зеркало из https://github.com/mozilla/gecko-dev.git
Bug 537890. Part 3: Remove gfxPlatform::GetDPI(). r=vlad
This commit is contained in:
Родитель
a4e6996a16
Коммит
6f3648b4f2
|
@ -65,7 +65,7 @@ nsSystemFontsAndroid::GetSystemFontInfo(const char *aClassName, nsString *aFontN
|
|||
*aFontName = NS_LITERAL_STRING("Droid Sans");
|
||||
aFontStyle->weight = 400;
|
||||
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
||||
aFontStyle->size = 9.0 * float(gfxPlatform::GetDPI()) / 72.0f;
|
||||
aFontStyle->size = 9.0 * 96.0f / 72.0f;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 *= float(gfxPlatform::GetDPI()) / POINTS_PER_INCH_FLOAT;
|
||||
size *= float(gfxPlatformGtk::GetDPI()) / POINTS_PER_INCH_FLOAT;
|
||||
}
|
||||
|
||||
// |size| is now pixels
|
||||
|
|
|
@ -84,9 +84,7 @@ nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
|
|||
if (qFont.pixelSize() != -1) {
|
||||
aFontStyle->size = qFont.pixelSize();
|
||||
} else {
|
||||
aFontStyle->size = qFont.pointSizeF()
|
||||
* float(gfxPlatform::GetDPI())
|
||||
/ 72.0f;
|
||||
aFontStyle->size = qFont.pointSizeF() * 96.0f / 72.0f;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -221,22 +221,3 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,8 +87,6 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void InitDisplayCaps();
|
||||
|
||||
static gfxFontconfigUtils *sFontconfigUtils;
|
||||
|
||||
private:
|
||||
|
|
|
@ -712,6 +712,18 @@ gfx_pango_fc_font_get_coverage(PangoFont *font, PangoLanguage *lang)
|
|||
return pango_coverage_ref(self->mCoverage);
|
||||
}
|
||||
|
||||
static PRInt32
|
||||
GetDPI()
|
||||
{
|
||||
#if defined(MOZ_WIDGET_GTK2)
|
||||
return gfxPlatformGtk::GetDPI();
|
||||
#elif defined(MOZ_WIDGET_QT)
|
||||
return gfxQtPlatform::GetDPI();
|
||||
#else
|
||||
return 96;
|
||||
#endif
|
||||
}
|
||||
|
||||
static PangoFontDescription *
|
||||
gfx_pango_fc_font_describe(PangoFont *font)
|
||||
{
|
||||
|
@ -723,7 +735,7 @@ gfx_pango_fc_font_describe(PangoFont *font)
|
|||
gfxFcFont *gfxFont = gfxPangoFcFont::GfxFont(self);
|
||||
if (gfxFont) {
|
||||
double pixelsize = gfxFont->GetStyle()->size;
|
||||
double dpi = gfxPlatform::GetDPI();
|
||||
double dpi = GetDPI();
|
||||
gint size = moz_pango_units_from_double(pixelsize * dpi / 72.0);
|
||||
pango_font_description_set_size(result, size);
|
||||
}
|
||||
|
@ -1720,8 +1732,7 @@ 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 gfxPlatform::GetDPI() much of the time...
|
||||
return gfxPlatform::GetDPI();
|
||||
return GetDPI();
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
|
|
|
@ -86,8 +86,6 @@
|
|||
|
||||
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;
|
||||
|
@ -1063,13 +1061,6 @@ static void MigratePrefs()
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::InitDisplayCaps()
|
||||
{
|
||||
// Fall back to something sane
|
||||
gfxPlatform::sDPI = 96;
|
||||
}
|
||||
|
||||
// default SetupClusterBoundaries, based on Unicode properties;
|
||||
// platform subclasses may override if they wish
|
||||
static nsIUGenCategory* gGenCategory = nsnull;
|
||||
|
|
|
@ -337,17 +337,6 @@ 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;
|
||||
}
|
||||
|
||||
virtual void FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref);
|
||||
|
||||
protected:
|
||||
|
@ -359,12 +348,6 @@ protected:
|
|||
void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], PRUint32 &aLen,
|
||||
eFontPrefLang aCharLang, eFontPrefLang aPageLang);
|
||||
|
||||
/**
|
||||
* Initialize any needed display metrics (such as DPI)
|
||||
*/
|
||||
virtual void InitDisplayCaps();
|
||||
static PRInt32 sDPI;
|
||||
|
||||
PRBool mAllowDownloadableFonts;
|
||||
|
||||
// whether to use the HarfBuzz layout engine
|
||||
|
|
|
@ -475,17 +475,22 @@ gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
|
|||
|
||||
#endif
|
||||
|
||||
void
|
||||
gfxPlatformGtk::InitDisplayCaps()
|
||||
static PRInt32 sDPI = 0;
|
||||
|
||||
PRInt32
|
||||
gfxPlatformGtk::GetDPI()
|
||||
{
|
||||
// Make sure init is run so we have a resolution
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
gtk_settings_get_for_screen(screen);
|
||||
gfxPlatform::sDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
|
||||
if (gfxPlatform::sDPI <= 0) {
|
||||
// Fall back to something sane
|
||||
gfxPlatform::sDPI = 96;
|
||||
if (!sDPI) {
|
||||
// Make sure init is run so we have a resolution
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
gtk_settings_get_for_screen(screen);
|
||||
sDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
|
||||
if (sDPI <= 0) {
|
||||
// Fall back to something sane
|
||||
sDPI = 96;
|
||||
}
|
||||
}
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
qcms_profile *
|
||||
|
|
|
@ -122,9 +122,9 @@ public:
|
|||
GdkDrawable *drawable);
|
||||
static GdkDrawable *GetGdkDrawable(gfxASurface *target);
|
||||
|
||||
protected:
|
||||
void InitDisplayCaps();
|
||||
static PRInt32 GetDPI();
|
||||
|
||||
protected:
|
||||
static gfxFontconfigUtils *sFontconfigUtils;
|
||||
|
||||
private:
|
||||
|
|
|
@ -570,14 +570,13 @@ gfxQtPlatform::SetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFo
|
|||
{
|
||||
mPrefFonts.Put(aKey, array);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
gfxQtPlatform::InitDisplayCaps()
|
||||
PRInt32
|
||||
gfxQtPlatform::GetDPI()
|
||||
{
|
||||
QDesktopWidget* rootWindow = qApp->desktop();
|
||||
sDPI = rootWindow->logicalDpiY(); // y-axis DPI for fonts
|
||||
if (sDPI <= 0)
|
||||
sDPI = 96; // something more sensible
|
||||
PRInt32 dpi = rootWindow->logicalDpiY(); // y-axis DPI for fonts
|
||||
return dpi <= 0 ? 96 : dpi;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,9 +131,10 @@ public:
|
|||
RenderMode GetRenderMode() { return mRenderMode; }
|
||||
void SetRenderMode(RenderMode rmode) { mRenderMode = rmode; }
|
||||
|
||||
static PRInt32 GetDPI();
|
||||
|
||||
protected:
|
||||
static gfxFontconfigUtils *sFontconfigUtils;
|
||||
void InitDisplayCaps();
|
||||
|
||||
private:
|
||||
virtual qcms_profile *GetPlatformCMSOutputProfile();
|
||||
|
|
|
@ -627,16 +627,6 @@ gfxWindowsPlatform::WindowsOSVersion()
|
|||
return winVersion;
|
||||
}
|
||||
|
||||
void
|
||||
gfxWindowsPlatform::InitDisplayCaps()
|
||||
{
|
||||
HDC dc = GetDC((HWND)nsnull);
|
||||
|
||||
gfxPlatform::sDPI = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
|
||||
ReleaseDC((HWND)nsnull, dc);
|
||||
}
|
||||
|
||||
void
|
||||
gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
|
||||
{
|
||||
|
|
|
@ -226,8 +226,6 @@ public:
|
|||
#endif
|
||||
|
||||
protected:
|
||||
void InitDisplayCaps();
|
||||
|
||||
RenderMode mRenderMode;
|
||||
|
||||
PRBool mUseClearTypeForDownloadableFonts;
|
||||
|
|
|
@ -568,6 +568,28 @@ nsIWidget* nsWindow::GetParent()
|
|||
return mParent;
|
||||
}
|
||||
|
||||
static PRInt32 sDPI = 0;
|
||||
|
||||
float nsWindow::GetDPI()
|
||||
{
|
||||
if (!sDPI) {
|
||||
// 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))
|
||||
sDPI = lDPI;
|
||||
DevCloseDC(dc);
|
||||
}
|
||||
if (sDPI <= 0) {
|
||||
// Fall back to something sane
|
||||
sDPI = 96;
|
||||
}
|
||||
}
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsWindow::Enable(PRBool aState)
|
||||
|
|
|
@ -171,6 +171,7 @@ public:
|
|||
nsWidgetInitData* aInitData = nsnull);
|
||||
NS_IMETHOD Destroy();
|
||||
virtual nsIWidget* GetParent();
|
||||
virtual float GetDPI();
|
||||
NS_IMETHOD Enable(PRBool aState);
|
||||
NS_IMETHOD IsEnabled(PRBool* aState);
|
||||
NS_IMETHOD Show(PRBool aState);
|
||||
|
|
Загрузка…
Ссылка в новой задаче