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

Unified Diff: gfx/gtk_native_view_id_manager.h

Issue 5275009: Defer window destruction until GPU finished drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now with reference counting. Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/gpu/gpu_command_buffer_stub.cc ('k') | gfx/gtk_native_view_id_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/gtk_native_view_id_manager.h
diff --git a/gfx/gtk_native_view_id_manager.h b/gfx/gtk_native_view_id_manager.h
index 513537a7eced09dc11f997583af42a15cb92ad2b..05cf0d779a3bc0c551e7345888d6f6a4817d436e 100644
--- a/gfx/gtk_native_view_id_manager.h
+++ b/gfx/gtk_native_view_id_manager.h
@@ -12,6 +12,7 @@
#include "gfx/native_widget_types.h"
typedef unsigned long XID;
+struct _GtkPreserveWindow;
// NativeViewIds are the opaque values which the renderer holds as a reference
// to a window. These ids are often used in sync calls from the renderer and
@@ -70,6 +71,14 @@ class GtkNativeViewManager {
// returns: true if |id| is a valid id, false otherwise.
bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id);
+ // Must be called from the UI thread because we may need to access a
+ // GtkWidget or destroy a GdkWindow.
+ //
+ // If the widget associated with the XID is still alive, allow the widget
+ // to destroy the associated XID when it wants. Otherwise, destroy the
+ // GdkWindow associated with the XID.
+ void ReleasePermanentXID(XID xid);
+
// These are actually private functions, but need to be called from statics.
void OnRealize(gfx::NativeView widget);
void OnUnrealize(gfx::NativeView widget);
@@ -105,6 +114,26 @@ class GtkNativeViewManager {
std::map<gfx::NativeView, gfx::NativeViewId> native_view_to_id_;
std::map<gfx::NativeViewId, NativeViewInfo> id_to_info_;
+ struct PermanentXIDInfo {
+ PermanentXIDInfo() : widget(NULL), ref_count(0) {
+ }
+ _GtkPreserveWindow* widget;
+ int ref_count;
+ };
+
+ // Used to maintain the reference count for permanent XIDs
+ // (referenced by GetPermanentXIDForId and dereferenced by
+ // ReleasePermanentXID). Only those XIDs with a positive reference count
+ // will be in the table.
+ //
+ // In general, several GTK widgets may share the same X window. We assume
+ // that is not true of the widgets stored in this registry.
+ //
+ // An XID will map to NULL, if there is an outstanding reference but the
+ // widget was destroyed. In this case, the destruction of the X window
+ // is deferred to the dropping of all references.
+ std::map<XID, PermanentXIDInfo> perm_xid_to_info_;
+
DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager);
};
« no previous file with comments | « chrome/gpu/gpu_command_buffer_stub.cc ('k') | gfx/gtk_native_view_id_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698