| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/gtk_util.h" | 5 #include "ui/gfx/gtk_util.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 const std::vector<Rect>& cutouts) { | 157 const std::vector<Rect>& cutouts) { |
| 158 for (size_t i = 0; i < cutouts.size(); ++i) { | 158 for (size_t i = 0; i < cutouts.size(); ++i) { |
| 159 GdkRectangle rect = cutouts[i].ToGdkRectangle(); | 159 GdkRectangle rect = cutouts[i].ToGdkRectangle(); |
| 160 GdkRegion* rect_region = gdk_region_rectangle(&rect); | 160 GdkRegion* rect_region = gdk_region_rectangle(&rect); |
| 161 gdk_region_subtract(region, rect_region); | 161 gdk_region_subtract(region, rect_region); |
| 162 // TODO(deanm): It would be nice to be able to reuse the GdkRegion here. | 162 // TODO(deanm): It would be nice to be able to reuse the GdkRegion here. |
| 163 gdk_region_destroy(rect_region); | 163 gdk_region_destroy(rect_region); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 PangoContext* GetPangoContext() { |
| 168 #if defined(USE_WAYLAND) |
| 169 PangoFontMap* font_map = pango_cairo_font_map_get_default(); |
| 170 PangoContext* default_context = pango_font_map_create_context(font_map); |
| 171 #else |
| 172 PangoContext* default_context = gdk_pango_context_get(); |
| 173 #endif |
| 174 return default_context; |
| 175 } |
| 176 |
| 167 double GetPangoResolution() { | 177 double GetPangoResolution() { |
| 168 static double resolution; | 178 static double resolution; |
| 169 static bool determined_resolution = false; | 179 static bool determined_resolution = false; |
| 170 if (!determined_resolution) { | 180 if (!determined_resolution) { |
| 171 determined_resolution = true; | 181 determined_resolution = true; |
| 172 PangoContext* default_context = gdk_pango_context_get(); | 182 PangoContext* default_context = GetPangoContext(); |
| 173 resolution = pango_cairo_context_get_resolution(default_context); | 183 resolution = pango_cairo_context_get_resolution(default_context); |
| 174 g_object_unref(default_context); | 184 g_object_unref(default_context); |
| 175 } | 185 } |
| 176 return resolution; | 186 return resolution; |
| 177 } | 187 } |
| 178 | 188 |
| 179 GdkCursor* GetCursor(int type) { | 189 GdkCursor* GetCursor(int type) { |
| 180 static GdkCursorCache impl; | 190 static GdkCursorCache impl; |
| 181 return impl.GetCursorImpl(static_cast<GdkCursorType>(type)); | 191 return impl.GetCursorImpl(static_cast<GdkCursorType>(type)); |
| 182 } | 192 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 203 new_pixels[idx + 1] = pixels[idx + 1]; | 213 new_pixels[idx + 1] = pixels[idx + 1]; |
| 204 new_pixels[idx + 2] = pixels[idx]; | 214 new_pixels[idx + 2] = pixels[idx]; |
| 205 new_pixels[idx + 3] = pixels[idx + 3]; | 215 new_pixels[idx + 3] = pixels[idx + 3]; |
| 206 } | 216 } |
| 207 } | 217 } |
| 208 | 218 |
| 209 return new_pixels; | 219 return new_pixels; |
| 210 } | 220 } |
| 211 | 221 |
| 212 } // namespace gfx | 222 } // namespace gfx |
| OLD | NEW |