Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: chrome/browser/ui/gtk/gtk_theme_service.h

Issue 8769017: GTK: Move CairoCachedSurface from being owned by GtkThemeService to gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase for commit Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | chrome/browser/ui/gtk/gtk_theme_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_
6 #define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ 6 #define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/prefs/pref_change_registrar.h" 14 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/browser/themes/theme_service.h" 15 #include "chrome/browser/themes/theme_service.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "ui/base/glib/glib_integers.h" 17 #include "ui/base/glib/glib_integers.h"
18 #include "ui/base/gtk/gtk_signal.h" 18 #include "ui/base/gtk/gtk_signal.h"
19 #include "ui/base/gtk/owned_widget_gtk.h" 19 #include "ui/base/gtk/owned_widget_gtk.h"
20 #include "ui/gfx/color_utils.h" 20 #include "ui/gfx/color_utils.h"
21 21
22 class Profile;
23
24 namespace gfx {
22 class CairoCachedSurface; 25 class CairoCachedSurface;
23 class Profile; 26 }
24 27
25 namespace ui { 28 namespace ui {
26 class GtkSignalRegistrar; 29 class GtkSignalRegistrar;
27 } 30 }
28 31
29 typedef struct _GdkDisplay GdkDisplay; 32 typedef struct _GdkDisplay GdkDisplay;
30 typedef struct _GdkEventExpose GdkEventExpose; 33 typedef struct _GdkEventExpose GdkEventExpose;
31 typedef struct _GdkPixbuf GdkPixbuf; 34 typedef struct _GdkPixbuf GdkPixbuf;
32 typedef struct _GtkIconSet GtkIconSet; 35 typedef struct _GtkIconSet GtkIconSet;
33 typedef struct _GtkStyle GtkStyle; 36 typedef struct _GtkStyle GtkStyle;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void GetScrollbarColors(GdkColor* thumb_active_color, 112 void GetScrollbarColors(GdkColor* thumb_active_color,
110 GdkColor* thumb_inactive_color, 113 GdkColor* thumb_inactive_color,
111 GdkColor* track_color); 114 GdkColor* track_color);
112 115
113 // Expose the inner label. Only used for testing. 116 // Expose the inner label. Only used for testing.
114 GtkWidget* fake_label() { return fake_label_.get(); } 117 GtkWidget* fake_label() { return fake_label_.get(); }
115 118
116 // Returns a CairoCachedSurface for a particular Display. CairoCachedSurfaces 119 // Returns a CairoCachedSurface for a particular Display. CairoCachedSurfaces
117 // (hopefully) live on the X server, instead of the client so we don't have 120 // (hopefully) live on the X server, instead of the client so we don't have
118 // to send the image to the server on each expose. 121 // to send the image to the server on each expose.
119 CairoCachedSurface* GetSurfaceNamed(int id, GtkWidget* widget_on_display); 122 gfx::CairoCachedSurface* GetSurfaceNamed(
123 int id, GtkWidget* widget_on_display);
120 124
121 // Same as above, but auto-mirrors the underlying pixbuf in RTL mode. 125 // Same as above, but auto-mirrors the underlying pixbuf in RTL mode.
122 CairoCachedSurface* GetRTLEnabledSurfaceNamed(int id, 126 gfx::CairoCachedSurface* GetRTLEnabledSurfaceNamed(
123 GtkWidget* widget_on_display); 127 int id, GtkWidget* widget_on_display);
124 128
125 // Same as above, but gets the resource from the ResourceBundle instead of the 129 // Same as above, but gets the resource from the ResourceBundle instead of the
126 // ThemeService. 130 // ThemeService.
127 // NOTE: Never call this with resource IDs that are ever passed to the above 131 // NOTE: Never call this with resource IDs that are ever passed to the above
128 // two functions! Depending on which call comes first, all callers will 132 // two functions! Depending on which call comes first, all callers will
129 // either get the themed or the unthemed version. 133 // either get the themed or the unthemed version.
130 CairoCachedSurface* GetUnthemedSurfaceNamed(int id, 134 gfx::CairoCachedSurface* GetUnthemedSurfaceNamed(
131 GtkWidget* widget_on_display); 135 int id, GtkWidget* widget_on_display);
132 136
133 // A way to get a cached cairo surface for the equivalent of GetFolderIcon() 137 // A way to get a cached cairo surface for the equivalent of GetFolderIcon()
134 // or GetDefaultFavicon(). Uses the ids defined in CairoDefaultIcon. 138 // or GetDefaultFavicon(). Uses the ids defined in CairoDefaultIcon.
135 CairoCachedSurface* GetCairoIcon(int id, GtkWidget* widget_on_display); 139 gfx::CairoCachedSurface* GetCairoIcon(int id, GtkWidget* widget_on_display);
136 140
137 // Returns colors that we pass to webkit to match the system theme. 141 // Returns colors that we pass to webkit to match the system theme.
138 const SkColor& get_focus_ring_color() const { return focus_ring_color_; } 142 const SkColor& get_focus_ring_color() const { return focus_ring_color_; }
139 const SkColor& get_thumb_active_color() const { return thumb_active_color_; } 143 const SkColor& get_thumb_active_color() const { return thumb_active_color_; }
140 const SkColor& get_thumb_inactive_color() const { 144 const SkColor& get_thumb_inactive_color() const {
141 return thumb_inactive_color_; 145 return thumb_inactive_color_;
142 } 146 }
143 const SkColor& get_track_color() const { return track_color_; } 147 const SkColor& get_track_color() const { return track_color_; }
144 const SkColor& get_active_selection_bg_color() const { 148 const SkColor& get_active_selection_bg_color() const {
145 return active_selection_bg_color_; 149 return active_selection_bg_color_;
(...skipping 14 matching lines...) Expand all
160 static GdkPixbuf* GetDefaultFavicon(bool native); 164 static GdkPixbuf* GetDefaultFavicon(bool native);
161 165
162 // Whether we use the GTK theme by default in the current desktop 166 // Whether we use the GTK theme by default in the current desktop
163 // environment. Returns true when we GTK defaults to on. 167 // environment. Returns true when we GTK defaults to on.
164 static bool DefaultUsesSystemTheme(); 168 static bool DefaultUsesSystemTheme();
165 169
166 private: 170 private:
167 typedef std::map<int, SkColor> ColorMap; 171 typedef std::map<int, SkColor> ColorMap;
168 typedef std::map<int, color_utils::HSL> TintMap; 172 typedef std::map<int, color_utils::HSL> TintMap;
169 typedef std::map<int, SkBitmap*> ImageCache; 173 typedef std::map<int, SkBitmap*> ImageCache;
170 typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap; 174 typedef std::map<int, gfx::CairoCachedSurface*> CairoCachedSurfaceMap;
171 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap; 175 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap;
172 176
173 typedef GdkPixbuf*(GtkThemeService::*PixbufProvidingMethod)(int id) const; 177 typedef GdkPixbuf*(GtkThemeService::*PixbufProvidingMethod)(int id) const;
174 178
175 // Clears all the GTK color overrides. 179 // Clears all the GTK color overrides.
176 virtual void ClearAllThemeData() OVERRIDE; 180 virtual void ClearAllThemeData() OVERRIDE;
177 181
178 // Load theme data from preferences, possibly picking colors from GTK. 182 // Load theme data from preferences, possibly picking colors from GTK.
179 virtual void LoadThemePrefs() OVERRIDE; 183 virtual void LoadThemePrefs() OVERRIDE;
180 184
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void GetNormalButtonTintHSL(color_utils::HSL* tint) const; 248 void GetNormalButtonTintHSL(color_utils::HSL* tint) const;
245 249
246 // Returns a tint that's the color of the current normal text in an entry. 250 // Returns a tint that's the color of the current normal text in an entry.
247 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const; 251 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const;
248 252
249 // Returns a tint that's the color of the current highlighted text in an 253 // Returns a tint that's the color of the current highlighted text in an
250 // entry. 254 // entry.
251 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; 255 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const;
252 256
253 // Implements GetXXXSurfaceNamed(), given the appropriate pixbuf to use. 257 // Implements GetXXXSurfaceNamed(), given the appropriate pixbuf to use.
254 CairoCachedSurface* GetSurfaceNamedImpl( 258 gfx::CairoCachedSurface* GetSurfaceNamedImpl(
255 int id, 259 int id,
256 PerDisplaySurfaceMap* surface_map, 260 PerDisplaySurfaceMap* surface_map,
257 PixbufProvidingMethod provider, 261 PixbufProvidingMethod provider,
258 GtkWidget* widget_on_display); 262 GtkWidget* widget_on_display);
259 263
260 // PixbufProvidingMethods passed to GetSurfaceNamedImpl from GetSurface* 264 // PixbufProvidingMethods passed to GetSurfaceNamedImpl from GetSurface*
261 // methods. We don't want to always fetch the pixbuf and pass the pixbuf to 265 // methods. We don't want to always fetch the pixbuf and pass the pixbuf to
262 // GetSurfaceNamedImpl which will throw away the result most of the time. 266 // GetSurfaceNamedImpl which will throw away the result most of the time.
263 // 267 //
264 // Especially since GetUnthemedNativePixbuf always locks and 268 // Especially since GetUnthemedNativePixbuf always locks and
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 347
344 // The default folder icon and default bookmark icon for the GTK theme. 348 // The default folder icon and default bookmark icon for the GTK theme.
345 // These are static because the system can only have one theme at a time. 349 // These are static because the system can only have one theme at a time.
346 // They are cached when they are requested the first time, and cleared when 350 // They are cached when they are requested the first time, and cleared when
347 // the system theme changes. 351 // the system theme changes.
348 static GdkPixbuf* default_folder_icon_; 352 static GdkPixbuf* default_folder_icon_;
349 static GdkPixbuf* default_bookmark_icon_; 353 static GdkPixbuf* default_bookmark_icon_;
350 }; 354 };
351 355
352 #endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ 356 #endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | chrome/browser/ui/gtk/gtk_theme_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698