diff options
Diffstat (limited to 'ui/gfx/gtk_util.cc')
-rw-r--r-- | ui/gfx/gtk_util.cc | 80 |
1 files changed, 4 insertions, 76 deletions
diff --git a/ui/gfx/gtk_util.cc b/ui/gfx/gtk_util.cc index 45ae56a..aa336e8 100644 --- a/ui/gfx/gtk_util.cc +++ b/ui/gfx/gtk_util.cc @@ -55,34 +55,6 @@ void FreePixels(guchar* pixels, gpointer data) { free(data); } -// Common implementation of ConvertAcceleratorsFromWindowsStyle() and -// RemoveWindowsStyleAccelerators(). -// Replaces all ampersands (as used in our grd files to indicate mnemonics) -// to |target|. Similarly any underscores get replaced with two underscores as -// is needed by GTK. -std::string ConvertAmperstandsTo(const std::string& label, - const std::string& target) { - std::string ret; - ret.reserve(label.length() * 2); - for (size_t i = 0; i < label.length(); ++i) { - if ('_' == label[i]) { - ret.push_back('_'); - ret.push_back('_'); - } else if ('&' == label[i]) { - if (i + 1 < label.length() && '&' == label[i + 1]) { - ret.push_back('&'); - ++i; - } else { - ret.append(target); - } - } else { - ret.push_back(label[i]); - } - } - - return ret; -} - } // namespace namespace gfx { @@ -164,60 +136,16 @@ void SubtractRectanglesFromRegion(GdkRegion* region, } } -PangoContext* GetPangoContext() { -#if defined(USE_WAYLAND) - PangoFontMap* font_map = pango_cairo_font_map_get_default(); - PangoContext* default_context = pango_font_map_create_context(font_map); -#else - PangoContext* default_context = gdk_pango_context_get(); -#endif - return default_context; -} - -double GetPangoResolution() { - static double resolution; - static bool determined_resolution = false; - if (!determined_resolution) { - determined_resolution = true; - PangoContext* default_context = GetPangoContext(); - resolution = pango_cairo_context_get_resolution(default_context); - g_object_unref(default_context); - } - return resolution; -} - GdkCursor* GetCursor(int type) { static GdkCursorCache impl; return impl.GetCursorImpl(static_cast<GdkCursorType>(type)); } -std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) { - return ConvertAmperstandsTo(label, "_"); -} - -std::string RemoveWindowsStyleAccelerators(const std::string& label) { - return ConvertAmperstandsTo(label, ""); -} - -uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) { - if (stride == 0) - stride = width * 4; - - uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride)); - - // We have to copy the pixels and swap from BGRA to RGBA. - for (int i = 0; i < height; ++i) { - for (int j = 0; j < width; ++j) { - int idx = i * stride + j * 4; - new_pixels[idx] = pixels[idx + 2]; - new_pixels[idx + 1] = pixels[idx + 1]; - new_pixels[idx + 2] = pixels[idx]; - new_pixels[idx + 3] = pixels[idx + 3]; - } - } - - return new_pixels; +#if !defined(USE_WAYLAND) && !defined(USE_AURA) +PangoContext* GetPangoContext() { + return gdk_pango_context_get(); } +#endif void InitRCStyles() { static const char kRCText[] = |