From: Jon A. Cruz Date: Fri, 17 Dec 2010 04:12:30 +0000 (-0800) Subject: Simple first pass for rough timing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b947b86feae33a7df233d6818a0b121611127cad;p=inkscape.git Simple first pass for rough timing --- diff --git a/src/verbs.cpp b/src/verbs.cpp index a218e85db..c1726ecd4 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2314,7 +2314,7 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_CLEAR_ALL, "EditClearAll", N_("Clea_r All"), N_("Delete all objects from document"), NULL), new EditVerb(SP_VERB_EDIT_SELECT_ALL, "EditSelectAll", N_("Select Al_l"), - N_("Select all objects or all nodes"), GTK_STOCK_SELECT_ALL), + N_("Select all objects or all nodes"), "fooble"),//GTK_STOCK_SELECT_ALL), new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"), N_("Select all objects in all visible and unlocked layers"), INKSCAPE_ICON_EDIT_SELECT_ALL_LAYERS), new EditVerb(SP_VERB_EDIT_INVERT, "EditInvert", N_("In_vert Selection"), diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 7a3e337de..57e58cd5e 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -121,6 +121,30 @@ static void sp_dtw_sticky_zoom_toggled (GtkMenuItem *item, gpointer data); SPViewWidgetClass *dtw_parent_class; +static GTimer *baseTimer = 0; +static bool timeReported = false; + +static void timeGoing(gchar const* id) +{ + if ( !baseTimer ) { + g_message("Starting time at point [%s]", id); + baseTimer = g_timer_new(); + } +} + +static void checkTime(gchar const* msg) +{ + if ( baseTimer && !timeReported ) { + timeReported = true; + g_timer_stop(baseTimer); + gulong msCount = 0; + gdouble secs = g_timer_elapsed( baseTimer, &msCount ); + g_message("Time ended at %2.3f with [%s]", secs, msg); + } +} + + + class CMSPrefWatcher { public: CMSPrefWatcher() : @@ -250,6 +274,7 @@ GType SPDesktopWidget::getType(void) { static GtkType type = 0; if (!type) { + timeGoing("SPDesktopWidget::getType"); GTypeInfo info = { sizeof(SPDesktopWidgetClass), 0, // base_init @@ -273,6 +298,7 @@ GType SPDesktopWidget::getType(void) static void sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) { + timeGoing("sp_desktop_widget_class_init"); dtw_parent_class = (SPViewWidgetClass*)gtk_type_class (SP_TYPE_VIEW_WIDGET); GtkObjectClass *object_class = (GtkObjectClass *) klass; @@ -289,6 +315,7 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) */ void SPDesktopWidget::init( SPDesktopWidget *dtw ) { + timeGoing("SPDesktopWidget::init"); GtkWidget *widget; GtkWidget *tbl; GtkWidget *canvas_tbl; @@ -564,6 +591,28 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_widget_show_all (dtw->vbox); gtk_widget_grab_focus (GTK_WIDGET(dtw->canvas)); + + { + g_message("FIRE UP"); + + gtk_widget_add_events( eventbox, GDK_STRUCTURE_MASK ); + + gboolean fooMap(GtkWidget *widget, GdkEvent *event, gpointer userData); + g_signal_connect( G_OBJECT(eventbox), "map-event", G_CALLBACK(fooMap), dtw ); + + void fooReal(GtkWidget *widget, gpointer userData); + g_signal_connect( G_OBJECT(eventbox), "map-event", G_CALLBACK(fooReal), dtw ); + } +} + +gboolean fooMap(GtkWidget *widget, GdkEvent *event, gpointer userData) { + checkTime( "MAP"); + return FALSE; +} + +void fooReal(GtkWidget *widget, gpointer userData) +{ + checkTime("REALIZE"); } /** diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 15900d340..d8d684614 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "path-prefix.h" #include "preferences.h" @@ -542,8 +543,7 @@ static void setupLegacyNaming() { legacyNames["zoom"] ="sticky_zoom"; } -static GtkWidget * -sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name ) +static GtkWidget *sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name ) { static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); @@ -1203,6 +1203,7 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize) { bool loadNeeded = false; static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); + static bool useCache = Inkscape::Preferences::get()->getBool("/debug/icons/useCache"); Glib::ustring key = icon_cache_key(name, psize); if ( !get_cached_pixbuf(key) ) { @@ -1211,28 +1212,62 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize) if (dump) { g_message("prerender_icon [%s] %d:%d", name, lsize, psize); } - guchar* px = load_svg_pixels(name, lsize, psize); - if ( !px ) { - // check for a fallback name - if ( legacyNames.find(name) != legacyNames.end() ) { - if ( dump ) { - g_message("load_svg_pixels([%s]=%s, %d, %d)", name, legacyNames[name].c_str(), lsize, psize); + // In file encoding: + std::string iconCacheDir = Glib::build_filename(Glib::build_filename(Glib::get_user_cache_dir(), "inkscape"), "icons"); + std::string potentialFile = Glib::build_filename( iconCacheDir, name ); + potentialFile += ".png"; + + bool dataLoaded = false; + if ( useCache && Glib::file_test(potentialFile, Glib::FILE_TEST_EXISTS) && Glib::file_test(potentialFile, Glib::FILE_TEST_IS_REGULAR) ) { + Glib::RefPtr pb = Gdk::Pixbuf::create_from_file(potentialFile); + if (pb) { + dataLoaded = true; + GdkPixbuf *obj = pb->gobj(); + g_object_ref(obj); + pb_cache[key] = obj; + addToIconSet(obj, name, lsize, psize); + loadNeeded = true; + if (internalNames.find(name) == internalNames.end()) { + internalNames.insert(name); } - px = load_svg_pixels(legacyNames[name].c_str(), lsize, psize); } } - if (px) { - GdkPixbuf* pb = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, TRUE, 8, - psize, psize, psize * 4, - reinterpret_cast(g_free), NULL ); - pb_cache[key] = pb; - addToIconSet(pb, name, lsize, psize); - loadNeeded = true; - if (internalNames.find(name) == internalNames.end()) { - internalNames.insert(name); + + if (!dataLoaded) { + guchar* px = load_svg_pixels(name, lsize, psize); + if ( !px ) { + // check for a fallback name + if ( legacyNames.find(name) != legacyNames.end() ) { + if ( dump ) { + g_message("load_svg_pixels([%s]=%s, %d, %d)", name, legacyNames[name].c_str(), lsize, psize); + } + px = load_svg_pixels(legacyNames[name].c_str(), lsize, psize); + } + } + if (px) { + GdkPixbuf* pb = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, TRUE, 8, + psize, psize, psize * 4, + reinterpret_cast(g_free), NULL ); + pb_cache[key] = pb; + addToIconSet(pb, name, lsize, psize); + loadNeeded = true; + if (internalNames.find(name) == internalNames.end()) { + internalNames.insert(name); + } + if (useCache) { + g_object_ref(pb); + Glib::RefPtr ppp = Glib::wrap(pb); + try { + ppp->save( potentialFile, "png" ); + } catch ( Glib::FileError &ex ) { + g_warning("FileError [%s]", ex.what().c_str()); + } catch ( Gdk::PixbufError &ex ) { + g_warning("PixbufError [%s]", ex.what().c_str()); + } + } + } else if (dump) { + g_message("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX error!!! pixels not found for '%s'", name); } - } else if (dump) { - g_message("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX error!!! pixels not found for '%s'", name); } } else if (dump) { @@ -1249,6 +1284,7 @@ static GdkPixbuf *sp_icon_image_load_svg(gchar const *name, GtkIconSize lsize, u // did we already load this icon at this scale/size? GdkPixbuf* pb = get_cached_pixbuf(key); if (!pb) { + g_message("YYYYYYYYYYYYY YYYYYYYYYYYYYYY two load_svg_pixels(%s, %d, %d)", name, lsize, psize); guchar *px = load_svg_pixels(name, lsize, psize); if (px) { pb = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB, TRUE, 8,