summaryrefslogtreecommitdiffstats
path: root/gfx
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 04:14:42 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 04:14:42 +0000
commit450d54eceb47146fb4fd9af724a8589e0c1baa69 (patch)
tree86befc74041c9a77529d850fe640d903d4a263b6 /gfx
parent8a12e2bc1f606a0b8436d7498ec49751baff178f (diff)
downloadchromium_src-450d54eceb47146fb4fd9af724a8589e0c1baa69.zip
chromium_src-450d54eceb47146fb4fd9af724a8589e0c1baa69.tar.gz
chromium_src-450d54eceb47146fb4fd9af724a8589e0c1baa69.tar.bz2
Also set the canvas size. I missed this in the last patch.
BUG=26354 Review URL: http://codereview.chromium.org/1243001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r--gfx/canvas_linux.cc17
-rw-r--r--gfx/font.h3
-rw-r--r--gfx/font_gtk.cc8
-rw-r--r--gfx/gtk_util.cc16
-rw-r--r--gfx/gtk_util.h4
5 files changed, 25 insertions, 23 deletions
diff --git a/gfx/canvas_linux.cc b/gfx/canvas_linux.cc
index 0981d56..6bc7690 100644
--- a/gfx/canvas_linux.cc
+++ b/gfx/canvas_linux.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "gfx/font.h"
+#include "gfx/gtk_util.h"
#include "gfx/rect.h"
namespace {
@@ -22,20 +23,6 @@ const gunichar kAcceleratorChar = '&';
// DrawStringInt().
static cairo_font_options_t* cairo_font_options = NULL;
-// Returns the resolution used by pango. A negative values means the resolution
-// hasn't been set.
-static double GetPangoResolution() {
- static double resolution;
- static bool determined_resolution = false;
- if (!determined_resolution) {
- determined_resolution = true;
- PangoContext* default_context = gdk_pango_context_get();
- resolution = pango_cairo_context_get_resolution(default_context);
- g_object_unref(default_context);
- }
- return resolution;
-}
-
// Update |cairo_font_options| based on GtkSettings, allocating it if needed.
static void UpdateCairoFontOptions() {
if (!cairo_font_options)
@@ -155,7 +142,7 @@ static void SetupPangoLayout(PangoLayout* layout,
// Set the resolution to match that used by Gtk. If we don't set the
// resolution and the resolution differs from the default, Gtk and Chrome end
// up drawing at different sizes.
- double resolution = GetPangoResolution();
+ double resolution = gfx::GetPangoResolution();
if (resolution > 0) {
pango_cairo_context_set_resolution(pango_layout_get_context(layout),
resolution);
diff --git a/gfx/font.h b/gfx/font.h
index 7395a4d..52a1bbb 100644
--- a/gfx/font.h
+++ b/gfx/font.h
@@ -232,8 +232,7 @@ class Font {
// The default font, used for the default constructor.
static Font* default_font_;
- // Return the scale factor for fonts that account for DPI. We clamp the
- // max DPI to prevent large fonts from overflowing UI elements.
+ // Return the scale factor for fonts that account for DPI.
static float GetPangoScaleFactor();
// The average width of a character, initialized and cached if needed.
diff --git a/gfx/font_gtk.cc b/gfx/font_gtk.cc
index 7dee3a1..644a7ff 100644
--- a/gfx/font_gtk.cc
+++ b/gfx/font_gtk.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
+#include "gfx/gtk_util.h"
namespace gfx {
@@ -56,14 +57,9 @@ static std::wstring FindBestMatchFontFamilyName(const char* family_name) {
// seems to give us the same sizes as used by Pango for all our fonts in both
// English and Thai.
float Font::GetPangoScaleFactor() {
- static float scale_factor = 0;
+ static float scale_factor = gfx::GetPangoResolution();
static bool determined_scale = false;
if (!determined_scale) {
- PangoContext* context = gdk_pango_context_get();
- scale_factor = pango_cairo_context_get_resolution(context);
- // Until we switch to vector graphics, force the max DPI to 96.0.
- scale_factor = std::min(scale_factor, 96.f);
- g_object_unref(context);
if (scale_factor <= 0)
scale_factor = 1;
else
diff --git a/gfx/gtk_util.cc b/gfx/gtk_util.cc
index 3485e6a..1f5b370 100644
--- a/gfx/gtk_util.cc
+++ b/gfx/gtk_util.cc
@@ -87,4 +87,20 @@ void SubtractRectanglesFromRegion(GdkRegion* region,
}
}
+double GetPangoResolution() {
+ static double resolution;
+ static bool determined_resolution = false;
+ if (!determined_resolution) {
+ determined_resolution = true;
+ PangoContext* default_context = gdk_pango_context_get();
+ resolution = pango_cairo_context_get_resolution(default_context);
+#if !defined(OS_CHROMEOS)
+ // Until we switch to vector graphics, force the max DPI to 96.0.
+ resolution = std::min(resolution, 96.);
+#endif
+ g_object_unref(default_context);
+ }
+ return resolution;
+}
+
} // namespace gfx
diff --git a/gfx/gtk_util.h b/gfx/gtk_util.h
index 3a30ad9..cc1fa8a 100644
--- a/gfx/gtk_util.h
+++ b/gfx/gtk_util.h
@@ -43,6 +43,10 @@ GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap);
void SubtractRectanglesFromRegion(GdkRegion* region,
const std::vector<Rect>& cutouts);
+// Returns the resolution (DPI) used by pango. A negative values means the
+// resolution hasn't been set.
+double GetPangoResolution();
+
} // namespace gfx
namespace {