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

Side by Side Diff: chrome/browser/gtk/gtk_theme_provider.h

Issue 199077: Reapplies the GdkPixbuf -> cairo surface patch. (Closed)
Patch Set: Created 11 years, 3 months 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/gtk/go_button_gtk.cc ('k') | chrome/browser/gtk/gtk_theme_provider.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_GTK_GTK_THEME_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_
6 #define CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ 6 #define CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "chrome/browser/browser_theme_provider.h" 12 #include "chrome/browser/browser_theme_provider.h"
12 #include "chrome/common/notification_observer.h" 13 #include "chrome/common/notification_observer.h"
13 #include "chrome/common/owned_widget_gtk.h" 14 #include "chrome/common/owned_widget_gtk.h"
14 15
15 #include "skia/ext/skia_utils.h" 16 #include "skia/ext/skia_utils.h"
16 17
18 class CairoCachedSurface;
17 class Profile; 19 class Profile;
18 20
21 typedef struct _GdkDisplay GdkDisplay;
19 typedef struct _GtkStyle GtkStyle; 22 typedef struct _GtkStyle GtkStyle;
20 typedef struct _GtkWidget GtkWidget; 23 typedef struct _GtkWidget GtkWidget;
21 24
22 // Specialization of BrowserThemeProvider which supplies system colors. 25 // Specialization of BrowserThemeProvider which supplies system colors.
23 class GtkThemeProvider : public BrowserThemeProvider, 26 class GtkThemeProvider : public BrowserThemeProvider,
24 public NotificationObserver { 27 public NotificationObserver {
25 public: 28 public:
26 // Returns GtkThemeProvider, casted from our superclass. 29 // Returns GtkThemeProvider, casted from our superclass.
27 static GtkThemeProvider* GetFrom(Profile* profile); 30 static GtkThemeProvider* GetFrom(Profile* profile);
28 31
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 GdkColor GetGdkColor(int id); 63 GdkColor GetGdkColor(int id);
61 64
62 // A weighted average between the text color and the background color of a 65 // A weighted average between the text color and the background color of a
63 // label. Used for borders between GTK stuff and the webcontent. 66 // label. Used for borders between GTK stuff and the webcontent.
64 GdkColor GetBorderColor(); 67 GdkColor GetBorderColor();
65 68
66 // Expose the inner widgets. Only used for testing. 69 // Expose the inner widgets. Only used for testing.
67 GtkWidget* fake_window() { return fake_window_; } 70 GtkWidget* fake_window() { return fake_window_; }
68 GtkWidget* fake_label() { return fake_label_.get(); } 71 GtkWidget* fake_label() { return fake_label_.get(); }
69 72
73 // Returns a CairoCachedSurface for a particular Display. CairoCachedSurfaces
74 // (hopefully) live on the X server, instead of the client so we don't have
75 // to send the image to the server on each expose.
76 CairoCachedSurface* GetSurfaceNamed(int id, GtkWidget* widget_on_display);
77
70 protected: 78 protected:
71 // Possibly creates a theme specific version of theme_toolbar_default. 79 // Possibly creates a theme specific version of theme_toolbar_default.
72 // (minimally acceptable version right now, which is just a fill of the bg 80 // (minimally acceptable version right now, which is just a fill of the bg
73 // color; this should instead invoke gtk_draw_box(...) for complex theme 81 // color; this should instead invoke gtk_draw_box(...) for complex theme
74 // engines.) 82 // engines.)
75 virtual SkBitmap* LoadThemeBitmap(int id); 83 virtual SkBitmap* LoadThemeBitmap(int id);
76 84
77 private: 85 private:
78 // Load theme data from preferences, possibly picking colors from GTK. 86 // Load theme data from preferences, possibly picking colors from GTK.
79 virtual void LoadThemePrefs(); 87 virtual void LoadThemePrefs();
80 88
81 // Let all the browser views know that themes have changed. 89 // Let all the browser views know that themes have changed.
82 virtual void NotifyThemeChanged(); 90 virtual void NotifyThemeChanged();
83 91
84 // If use_gtk_ is true, completely ignores this call. Otherwise passes it to 92 // If use_gtk_ is true, completely ignores this call. Otherwise passes it to
85 // the superclass. 93 // the superclass.
86 virtual void SaveThemeBitmap(const std::string resource_name, int id); 94 virtual void SaveThemeBitmap(const std::string resource_name, int id);
87 95
96 // Additionally frees the CairoCachedSurfaces.
97 virtual void FreePlatformCaches();
98
88 // Handles signal from GTK that our theme has been changed. 99 // Handles signal from GTK that our theme has been changed.
89 static void OnStyleSet(GtkWidget* widget, 100 static void OnStyleSet(GtkWidget* widget,
90 GtkStyle* previous_style, 101 GtkStyle* previous_style,
91 GtkThemeProvider* provider); 102 GtkThemeProvider* provider);
92 103
93 void LoadGtkValues(); 104 void LoadGtkValues();
94 105
95 // Sets the underlying theme colors/tints from a GTK color. 106 // Sets the underlying theme colors/tints from a GTK color.
96 void SetThemeColorFromGtk(const char* id, GdkColor* color); 107 void SetThemeColorFromGtk(const char* id, GdkColor* color);
97 void SetThemeTintFromGtk(const char* id, GdkColor* color, 108 void SetThemeTintFromGtk(const char* id, GdkColor* color,
98 const skia::HSL& default_tint); 109 const skia::HSL& default_tint);
99 110
111 // Split out from FreePlatformCaches so it can be called in our destructor;
112 // FreePlatformCaches() is called from the BrowserThemeProvider's destructor,
113 // but by the time ~BrowserThemeProvider() is run, the vtable no longer
114 // points to GtkThemeProvider's version.
115 void FreePerDisplaySurfaces();
116
100 // A notification from the GtkChromeButton GObject destructor that we should 117 // A notification from the GtkChromeButton GObject destructor that we should
101 // remove it from our internal list. 118 // remove it from our internal list.
102 static void OnDestroyChromeButton(GtkWidget* button, 119 static void OnDestroyChromeButton(GtkWidget* button,
103 GtkThemeProvider* provider); 120 GtkThemeProvider* provider);
104 121
105 // Whether we should be using gtk rendering. 122 // Whether we should be using gtk rendering.
106 bool use_gtk_; 123 bool use_gtk_;
107 124
108 // GtkWidgets that exist only so we can look at their properties (and take 125 // GtkWidgets that exist only so we can look at their properties (and take
109 // their colors). 126 // their colors).
110 GtkWidget* fake_window_; 127 GtkWidget* fake_window_;
111 OwnedWidgetGtk fake_label_; 128 OwnedWidgetGtk fake_label_;
112 129
113 // A list of all GtkChromeButton instances. We hold on to these to notify 130 // A list of all GtkChromeButton instances. We hold on to these to notify
114 // them of theme changes. 131 // them of theme changes.
115 std::vector<GtkWidget*> chrome_buttons_; 132 std::vector<GtkWidget*> chrome_buttons_;
133
134 // Cairo surfaces for each GdkDisplay.
135 typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap;
136 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap;
137 PerDisplaySurfaceMap per_display_surfaces_;
116 }; 138 };
117 139
118 #endif // CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ 140 #endif // CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/go_button_gtk.cc ('k') | chrome/browser/gtk/gtk_theme_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698