Bug 1350643 - Part 1: Rename gfxPlatformGtk::GetDPI/GetDPIScale to GetFontScaleDPI/GetFontScaleFactor to better distinguish from nsIWidget::GetDPI. r?karlt
MozReview-Commit-ID: 4fxMG1FBlM8
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -332,40 +332,40 @@ gfxPlatformGtk::IsFontFormatSupported(ui
// no format hint set, need to look at data
return true;
}
static int32_t sDPI = 0;
int32_t
-gfxPlatformGtk::GetDPI()
+gfxPlatformGtk::GetFontScaleDPI()
{
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 = int32_t(round(gdk_screen_get_resolution(screen)));
if (sDPI <= 0) {
// Fall back to something sane
sDPI = 96;
}
}
return sDPI;
}
double
-gfxPlatformGtk::GetDPIScale()
+gfxPlatformGtk::GetFontScaleFactor()
{
// Integer scale factors work well with GTK window scaling, image scaling,
// and pixel alignment, but there is a range where 1 is too small and 2 is
// too big. An additional step of 1.5 is added because this is common
// scale on WINNT and at this ratio the advantages of larger rendering
// outweigh the disadvantages from scaling and pixel mis-alignment.
- int32_t dpi = GetDPI();
+ int32_t dpi = GetFontScaleDPI();
if (dpi < 132) {
return 1.0;
}
if (dpi < 168) {
return 1.5;
}
return round(dpi/96.0);
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -97,18 +97,18 @@ public:
FT_Library GetFTLibrary() override;
#if (MOZ_WIDGET_GTK == 2)
static void SetGdkDrawable(cairo_surface_t *target,
GdkDrawable *drawable);
static GdkDrawable *GetGdkDrawable(cairo_surface_t *target);
#endif
- static int32_t GetDPI();
- static double GetDPIScale();
+ static int32_t GetFontScaleDPI();
+ static double GetFontScaleFactor();
#ifdef MOZ_X11
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) override {
gfxPlatform::GetAzureBackendInfo(aObj);
aObj.DefineProperty("CairoUseXRender", mozilla::gfx::gfxVars::UseXRender());
}
#endif
--- a/widget/gtk/ScreenHelperGTK.cpp
+++ b/widget/gtk/ScreenHelperGTK.cpp
@@ -140,17 +140,17 @@ ScreenHelperGTK::GetGTKMonitorScaleFacto
}
#endif
return 1;
}
static float
GetDefaultCssScale()
{
- return ScreenHelperGTK::GetGTKMonitorScaleFactor() * gfxPlatformGtk::GetDPIScale();
+ return ScreenHelperGTK::GetGTKMonitorScaleFactor() * gfxPlatformGtk::GetFontScaleFactor();
}
static uint32_t
GetGTKPixelDepth()
{
GdkVisual * visual = gdk_screen_get_system_visual(gdk_screen_get_default());
return gdk_visual_get_depth(visual);
}
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -923,17 +923,17 @@ GetSystemFontInfo(GtkWidget *aWidget,
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE;
// |size| is now either pixels or pango-points (not Mozilla-points!)
if (!pango_font_description_get_size_is_absolute(desc)) {
// |size| is in pango-points, so convert to pixels.
- size *= float(gfxPlatformGtk::GetDPI()) / POINTS_PER_INCH_FLOAT;
+ size *= float(gfxPlatformGtk::GetFontScaleDPI()) / POINTS_PER_INCH_FLOAT;
}
// Scale fonts up on HiDPI displays.
// This would be done automatically with cairo, but we manually manage
// the display scale for platform consistency.
size *= ScreenHelperGTK::GetGTKMonitorScaleFactor();
// |size| is now pixels
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -811,17 +811,17 @@ nsWindow::GetDPI()
return 96.0f;
}
return float(gdk_screen_get_height(screen)/heightInches);
}
double
nsWindow::GetDefaultScaleInternal()
{
- return GdkScaleFactor() * gfxPlatformGtk::GetDPIScale();
+ return GdkScaleFactor() * gfxPlatformGtk::GetFontScaleFactor();
}
void
nsWindow::SetParent(nsIWidget *aNewParent)
{
if (mContainer || !mGdkWindow) {
NS_NOTREACHED("nsWindow::SetParent called illegally");
return;