From: joncruz Date: Mon, 29 Oct 2007 06:57:47 +0000 (+0000) Subject: Moving functionality into X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d985b4274377399600a1cb4b6a89c0827ba83966;p=inkscape.git Moving functionality into --- diff --git a/src/color-profile.cpp b/src/color-profile.cpp index b094b650d..f676ceacf 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -25,14 +25,6 @@ using Inkscape::ColorProfileClass; namespace Inkscape { -static void colorprofile_class_init( ColorProfileClass *klass ); -static void colorprofile_init( ColorProfile *cprof ); - -static void colorprofile_release( SPObject *object ); -static void colorprofile_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ); -static void colorprofile_set( SPObject *object, unsigned key, gchar const *value ); -static Inkscape::XML::Node *colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags ); - #if ENABLE_LCMS static cmsHPROFILE colorprofile_get_system_profile_handle(); static cmsHPROFILE colorprofile_get_proof_profile_handle(); @@ -68,23 +60,41 @@ extern guint update_in_progress; } #endif // DEBUG_LCMS -static SPObject *cprof_parent_class; +static SPObjectClass *cprof_parent_class; + +#if ENABLE_LCMS + +cmsHPROFILE ColorProfile::_sRGBProf = 0; + +cmsHPROFILE ColorProfile::getSRGBProfile() { + if ( !_sRGBProf ) { + _sRGBProf = cmsCreate_sRGBProfile(); + } + return _sRGBProf; +} + +#endif // ENABLE_LCMS /** * Register ColorProfile class and return its type. */ GType Inkscape::colorprofile_get_type() +{ + return ColorProfile::getType(); +} + +GType ColorProfile::getType() { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(ColorProfileClass), NULL, NULL, - (GClassInitFunc) colorprofile_class_init, + (GClassInitFunc) ColorProfile::classInit, NULL, NULL, sizeof(ColorProfile), 16, - (GInstanceInitFunc) colorprofile_init, + (GInstanceInitFunc) ColorProfile::init, NULL, /* value_table */ }; type = g_type_register_static( SP_TYPE_OBJECT, "ColorProfile", &info, static_cast(0) ); @@ -95,22 +105,22 @@ GType Inkscape::colorprofile_get_type() /** * ColorProfile vtable initialization. */ -static void Inkscape::colorprofile_class_init( ColorProfileClass *klass ) +void ColorProfile::classInit( ColorProfileClass *klass ) { SPObjectClass *sp_object_class = reinterpret_cast(klass); - cprof_parent_class = static_cast(g_type_class_ref(SP_TYPE_OBJECT)); + cprof_parent_class = static_cast(g_type_class_ref(SP_TYPE_OBJECT)); - sp_object_class->release = colorprofile_release; - sp_object_class->build = colorprofile_build; - sp_object_class->set = colorprofile_set; - sp_object_class->write = colorprofile_write; + sp_object_class->release = ColorProfile::release; + sp_object_class->build = ColorProfile::build; + sp_object_class->set = ColorProfile::set; + sp_object_class->write = ColorProfile::write; } /** * Callback for ColorProfile object initialization. */ -static void Inkscape::colorprofile_init( ColorProfile *cprof ) +void ColorProfile::init( ColorProfile *cprof ) { cprof->href = 0; cprof->local = 0; @@ -119,13 +129,17 @@ static void Inkscape::colorprofile_init( ColorProfile *cprof ) cprof->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; #if ENABLE_LCMS cprof->profHandle = 0; + cprof->_profileClass = icSigInputClass; + cprof->_profileSpace = icSigRgbData; + cprof->_transf = 0; + cprof->_revTransf = 0; #endif // ENABLE_LCMS } /** * Callback: free object */ -static void Inkscape::colorprofile_release( SPObject *object ) +void ColorProfile::release( SPObject *object ) { // Unregister ourselves SPDocument* document = SP_OBJECT_DOCUMENT(object); @@ -155,17 +169,34 @@ static void Inkscape::colorprofile_release( SPObject *object ) } #if ENABLE_LCMS - if ( cprof->profHandle ) { - cmsCloseProfile( cprof->profHandle ); - cprof->profHandle = 0; - } + cprof->_clearProfile(); #endif // ENABLE_LCMS } +#if ENABLE_LCMS +void ColorProfile::_clearProfile() +{ + _profileSpace = icSigRgbData; + + if ( _transf ) { + cmsDeleteTransform( _transf ); + _transf = 0; + } + if ( _revTransf ) { + cmsDeleteTransform( _revTransf ); + _revTransf = 0; + } + if ( profHandle ) { + cmsCloseProfile( profHandle ); + profHandle = 0; + } +} +#endif // ENABLE_LCMS + /** * Callback: set attributes from associated repr. */ -static void Inkscape::colorprofile_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ) +void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ) { ColorProfile *cprof = COLORPROFILE(object); g_assert(cprof->href == 0); @@ -173,8 +204,8 @@ static void Inkscape::colorprofile_build( SPObject *object, SPDocument *document g_assert(cprof->name == 0); g_assert(cprof->intentStr == 0); - if (((SPObjectClass *) cprof_parent_class)->build) { - (* ((SPObjectClass *) cprof_parent_class)->build)(object, document, repr); + if (cprof_parent_class->build) { + (* cprof_parent_class->build)(object, document, repr); } sp_object_read_attr( object, "xlink:href" ); sp_object_read_attr( object, "local" ); @@ -190,7 +221,7 @@ static void Inkscape::colorprofile_build( SPObject *object, SPDocument *document /** * Callback: set attribute. */ -static void Inkscape::colorprofile_set( SPObject *object, unsigned key, gchar const *value ) +void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) { ColorProfile *cprof = COLORPROFILE(object); @@ -231,7 +262,12 @@ static void Inkscape::colorprofile_set( SPObject *object, unsigned key, gchar co // the w3c specs. All absolute and relative issues are considered org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri); gchar* fullname = (gchar *)cprofUri.getNativePath().c_str(); + cprof->_clearProfile(); cprof->profHandle = cmsOpenProfileFromFile( fullname, "r" ); + if ( cprof->profHandle ) { + cprof->_profileSpace = cmsGetColorSpace( cprof->profHandle ); + cprof->_profileClass = cmsGetDeviceClass( cprof->profHandle ); + } #ifdef DEBUG_LCMS DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->profHandle ); #endif // DEBUG_LCMS @@ -292,8 +328,8 @@ static void Inkscape::colorprofile_set( SPObject *object, unsigned key, gchar co break; default: - if (((SPObjectClass *) cprof_parent_class)->set) { - (* ((SPObjectClass *) cprof_parent_class)->set)(object, key, value); + if (cprof_parent_class->set) { + (* cprof_parent_class->set)(object, key, value); } break; } @@ -303,7 +339,7 @@ static void Inkscape::colorprofile_set( SPObject *object, unsigned key, gchar co /** * Callback: write attributes to associated repr. */ -static Inkscape::XML::Node* Inkscape::colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags ) +Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Node *repr, guint flags ) { ColorProfile *cprof = COLORPROFILE(object); @@ -328,8 +364,8 @@ static Inkscape::XML::Node* Inkscape::colorprofile_write( SPObject *object, Inks repr->setAttribute( "rendering-intent", cprof->intentStr ); } - if (((SPObjectClass *) cprof_parent_class)->write) { - (* ((SPObjectClass *) cprof_parent_class)->write)(object, repr, flags); + if (cprof_parent_class->write) { + (* cprof_parent_class->write)(object, repr, flags); } return repr; @@ -338,6 +374,59 @@ static Inkscape::XML::Node* Inkscape::colorprofile_write( SPObject *object, Inks #if ENABLE_LCMS +struct MapMap { + icColorSpaceSignature space; + DWORD inForm; +}; + +DWORD ColorProfile::_getInputFormat( icColorSpaceSignature space ) +{ + MapMap possible[] = { + {icSigXYZData, TYPE_XYZ_16}, + {icSigLabData, TYPE_Lab_16}, + //icSigLuvData + {icSigYCbCrData, TYPE_YCbCr_16}, + {icSigYxyData, TYPE_Yxy_16}, + {icSigRgbData, TYPE_RGB_16}, + {icSigGrayData, TYPE_GRAY_16}, + {icSigHsvData, TYPE_HSV_16}, + {icSigHlsData, TYPE_HLS_16}, + {icSigCmykData, TYPE_CMYK_16}, + {icSigCmyData, TYPE_CMY_16}, + }; + + int index = 0; + for ( guint i = 0; i < G_N_ELEMENTS(possible); i++ ) { + if ( possible[i].space == space ) { + index = i; + break; + } + } + + return possible[index].inForm; +} + +static int getLcmsIntent( guint svgIntent ) +{ + int intent = INTENT_PERCEPTUAL; + switch ( svgIntent ) { + case Inkscape::RENDERING_INTENT_RELATIVE_COLORIMETRIC: + intent = INTENT_RELATIVE_COLORIMETRIC; + break; + case Inkscape::RENDERING_INTENT_SATURATION: + intent = INTENT_SATURATION; + break; + case Inkscape::RENDERING_INTENT_ABSOLUTE_COLORIMETRIC: + intent = INTENT_ABSOLUTE_COLORIMETRIC; + break; + case Inkscape::RENDERING_INTENT_PERCEPTUAL: + case Inkscape::RENDERING_INTENT_UNKNOWN: + case Inkscape::RENDERING_INTENT_AUTO: + default: + intent = INTENT_PERCEPTUAL; + } + return intent; +} static SPObject* bruteFind( SPDocument* document, gchar const* name ) { @@ -379,6 +468,24 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte return prof; } +cmsHTRANSFORM ColorProfile::getTransfToSRGB8() +{ + if ( !_transf ) { + int intent = getLcmsIntent(rendering_intent); + _transf = cmsCreateTransform( profHandle, _getInputFormat(_profileSpace), getSRGBProfile(), TYPE_RGBA_8, intent, 0 ); + } + return _transf; +} + +cmsHTRANSFORM ColorProfile::getTransfFromSRGB8() +{ + if ( !_revTransf ) { + int intent = getLcmsIntent(rendering_intent); + _revTransf = cmsCreateTransform( getSRGBProfile(), TYPE_RGBA_8, profHandle, _getInputFormat(_profileSpace), intent, 0 ); + } + return _revTransf; +} + #include @@ -559,7 +666,6 @@ static bool lastPreserveBlack = false; static int lastIntent = INTENT_PERCEPTUAL; static int lastProofIntent = INTENT_PERCEPTUAL; static cmsHTRANSFORM transf = 0; -static cmsHPROFILE srcprof = 0; cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle() { @@ -724,9 +830,6 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_transform() cmsHPROFILE proofProf = hprof ? Inkscape::colorprofile_get_proof_profile_handle() : 0; if ( !transf ) { - if ( !srcprof ) { - srcprof = cmsCreate_sRGBProfile(); - } if ( hprof && proofProf ) { DWORD dwFlags = cmsFLAGS_SOFTPROOFING; if ( gamutWarn ) { @@ -741,9 +844,9 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_transform() dwFlags |= cmsFLAGS_PRESERVEBLACK; } #endif // defined(cmsFLAGS_PRESERVEBLACK) - transf = cmsCreateProofingTransform( srcprof, TYPE_RGB_8, hprof, TYPE_RGB_8, proofProf, intent, proofIntent, dwFlags ); + transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGB_8, hprof, TYPE_RGB_8, proofProf, intent, proofIntent, dwFlags ); } else if ( hprof ) { - transf = cmsCreateTransform( srcprof, TYPE_RGB_8, hprof, TYPE_RGB_8, intent, 0 ); + transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGB_8, hprof, TYPE_RGB_8, intent, 0 ); } } diff --git a/src/color-profile.h b/src/color-profile.h index 76e25d065..03b7e072b 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -22,8 +22,25 @@ enum { RENDERING_INTENT_ABSOLUTE_COLORIMETRIC = 5 }; +/// The SPColorProfile vtable. +struct ColorProfileClass { + SPObjectClass parent_class; +}; + /** Color Profile. */ struct ColorProfile : public SPObject { + static GType getType(); + static void classInit( ColorProfileClass *klass ); + +#if ENABLE_LCMS + static cmsHPROFILE getSRGBProfile(); + + icColorSpaceSignature getColorSpace() const {return _profileSpace;} + icProfileClassSignature getProfileClass() const {return _profileClass;} + cmsHTRANSFORM getTransfToSRGB8(); + cmsHTRANSFORM getTransfFromSRGB8(); +#endif // ENABLE_LCMS + gchar* href; gchar* local; gchar* name; @@ -32,11 +49,25 @@ struct ColorProfile : public SPObject { #if ENABLE_LCMS cmsHPROFILE profHandle; #endif // ENABLE_LCMS -}; -/// The SPColorProfile vtable. -struct ColorProfileClass { - SPObjectClass parent_class; +private: + static void init( ColorProfile *cprof ); + + static void release( SPObject *object ); + static void build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ); + static void set( SPObject *object, unsigned key, gchar const *value ); + static Inkscape::XML::Node *write( SPObject *object, Inkscape::XML::Node *repr, guint flags ); +#if ENABLE_LCMS + static DWORD _getInputFormat( icColorSpaceSignature space ); + void _clearProfile(); + + static cmsHPROFILE _sRGBProf; + + icProfileClassSignature _profileClass; + icColorSpaceSignature _profileSpace; + cmsHTRANSFORM _transf; + cmsHTRANSFORM _revTransf; +#endif // ENABLE_LCMS }; } // namespace Inkscape diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 984a1e296..fc4e4bbdc 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -15,6 +15,7 @@ #include "svg/svg-icc-color.h" #include "document.h" #include "inkscape.h" +#include "profile-manager.h" #define noDEBUG_LCMS @@ -126,6 +127,7 @@ sp_color_icc_selector_class_init (SPColorICCSelectorClass *klass) widget_class->hide_all = sp_color_icc_selector_hide_all; } + ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) : ColorSelector( csel ), _updating( FALSE ), @@ -145,13 +147,9 @@ ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) #if ENABLE_LCMS , _profileName(""), - _profIntent(Inkscape::RENDERING_INTENT_UNKNOWN), - _profileSpace(icSigRgbData), - _profileClass(icSigInputClass), - _prof(0), - _destProf(0), - _transf(0), - _profChannelCount(0) + _prof(), + _profChannelCount(0), + _profChangedID(0) #endif // ENABLE_LCMS { } @@ -197,7 +195,7 @@ struct MapMap { DWORD inForm; }; -void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies, DWORD& inputFormat ) { +void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) { MapMap possible[] = { {icSigXYZData, TYPE_XYZ_16}, {icSigLabData, TYPE_Lab_16}, @@ -262,7 +260,6 @@ void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guin } } - inputFormat = possible[index].inForm; namers = names[index]; tippies = tips[index]; scalies = scales[index]; @@ -285,11 +282,10 @@ void ColorICCSelector::init() gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 0); #if ENABLE_LCMS - DWORD inputFormat = TYPE_RGB_16; //guint partCount = _cmsChannelsOf( icSigRgbData ); gchar const** names = 0; gchar const** tips = 0; - getThings( icSigRgbData, names, tips, _fooScales, inputFormat ); + getThings( icSigRgbData, names, tips, _fooScales ); #endif // ENABLE_LCMS /* Create components */ @@ -311,7 +307,13 @@ void ColorICCSelector::init() gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 ); gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); +#if ENABLE_LCMS + _profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this ); + gtk_widget_set_sensitive( _profileSel, false ); // temporary +#else gtk_widget_set_sensitive( _profileSel, false ); +#endif // ENABLE_LCMS + row++; @@ -453,9 +455,62 @@ void ColorICCSelector::_fixupHit( GtkWidget* src, gpointer data ) self->_adjustmentChanged( self->_fooAdj[0], SP_COLOR_ICC_SELECTOR(self->_csel) ); } +#if ENABLE_LCMS +void ColorICCSelector::_profileSelected( GtkWidget* src, gpointer data ) +{ + (void)src; + ColorICCSelector* self = reinterpret_cast(data); + gint activeIndex = gtk_combo_box_get_active( GTK_COMBO_BOX(self->_profileSel) ); + gchar* name = (activeIndex != 0) ? gtk_combo_box_get_active_text( GTK_COMBO_BOX(self->_profileSel) ) : 0; + //self->_switchToProfile( name ); + if ( name ) { + g_free( name ); + } +} +#endif // ENABLE_LCMS + +void ColorICCSelector::_switchToProfile( gchar const* name ) +{ + bool dirty = false; + SPColor tmp( _color ); + + if ( name ) { + if ( tmp.icc && tmp.icc->colorProfile == name ) { + g_message("Already at name [%s]", name ); + } else { + g_message("Need to switch to profile [%s]", name ); + if ( tmp.icc ) { + tmp.icc->colors.clear(); + } else { + tmp.icc = new SVGICCColor(); + } + tmp.icc->colorProfile = name; + dirty = true; + } + } else { + g_message("NUKE THE ICC"); + if ( tmp.icc ) { + delete tmp.icc; + tmp.icc = 0; + dirty = true; + } else { + g_message("No icc to nuke"); + } + } + + if ( dirty ) { + _setProfile( tmp.icc ); + // Set the color now. + + } +} + void ColorICCSelector::_profilesChanged( std::string const & name ) { GtkComboBox* combo = GTK_COMBO_BOX(_profileSel); + + g_signal_handler_block( G_OBJECT(_profileSel), _profChangedID ); + GtkTreeModel* model = gtk_combo_box_get_model( combo ); GtkTreeIter iter; while ( gtk_tree_model_get_iter_first( model, &iter ) ) { @@ -464,7 +519,6 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) gtk_combo_box_append_text( combo, ""); - // TODO supress signal emit gtk_combo_box_set_active( combo, 0 ); int index = 1; @@ -481,6 +535,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) current = g_slist_next(current); } + g_signal_handler_unblock( G_OBJECT(_profileSel), _profChangedID ); } /* Helpers for setting color value */ @@ -508,7 +563,7 @@ void ColorICCSelector::_colorChanged( const SPColor& color, gfloat alpha ) _fixupNeeded = 0; gtk_widget_set_sensitive( _fixupBtn, FALSE ); - if ( _transf ) { + if ( _prof && _prof->getTransfToSRGB8() ) { icUInt16Number tmp[4]; for ( guint i = 0; i < _profChannelCount; i++ ) { gdouble val = 0.0; @@ -522,7 +577,7 @@ void ColorICCSelector::_colorChanged( const SPColor& color, gfloat alpha ) tmp[i] = val * 0x0ffff; } guchar post[4] = {0,0,0,0}; - cmsDoTransform( _transf, tmp, post, 1 ); + cmsDoTransform( _prof->getTransfToSRGB8(), tmp, post, 1 ); guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); if ( other != color.toRGBA32(255) ) { _fixupNeeded = other; @@ -555,18 +610,7 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) // Need to clear out the prior one profChanged = true; _profileName.clear(); - _profIntent = Inkscape::RENDERING_INTENT_UNKNOWN; - _profileSpace = icSigRgbData; - _profileClass = icSigInputClass; _prof = 0; - if ( _transf ) { - cmsDeleteTransform( _transf ); - _transf = 0; - } - if ( _destProf ) { - cmsCloseProfile( _destProf ); - _destProf = 0; - } _profChannelCount = 0; } else if ( profile && !_prof ) { profChanged = true; @@ -576,80 +620,51 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) gtk_widget_hide( _fooLabel[i] ); gtk_widget_hide( _fooSlider[i] ); gtk_widget_hide( _fooBtn[i] ); - gtk_adjustment_set_value( _fooAdj[i], 0.0 ); } if ( profile ) { - _prof = Inkscape::colorprofile_get_handle( inkscape_active_document(),//SP_OBJECT_DOCUMENT( object ), - &_profIntent, - profile->colorProfile.c_str() ); - if ( _prof ) { - _profileSpace = cmsGetColorSpace( _prof ); - _profileClass = cmsGetDeviceClass( _prof ); - if ( _profileClass != icSigNamedColorClass ) { - int intent = INTENT_PERCEPTUAL; - switch ( _profIntent ) { - case Inkscape::RENDERING_INTENT_RELATIVE_COLORIMETRIC: - intent = INTENT_RELATIVE_COLORIMETRIC; - break; - case Inkscape::RENDERING_INTENT_SATURATION: - intent = INTENT_SATURATION; - break; - case Inkscape::RENDERING_INTENT_ABSOLUTE_COLORIMETRIC: - intent = INTENT_ABSOLUTE_COLORIMETRIC; - break; - case Inkscape::RENDERING_INTENT_PERCEPTUAL: - case Inkscape::RENDERING_INTENT_UNKNOWN: - case Inkscape::RENDERING_INTENT_AUTO: - default: - intent = INTENT_PERCEPTUAL; - } - _destProf = cmsCreate_sRGBProfile(); - - _profChannelCount = _cmsChannelsOf( _profileSpace ); + _prof = SP_ACTIVE_DOCUMENT->profileManager->find(profile->colorProfile.c_str()); + if ( _prof && _prof->getProfileClass() != icSigNamedColorClass ) { + _profChannelCount = _cmsChannelsOf( _prof->getColorSpace() ); - DWORD inputFormat = TYPE_RGB_16; - gchar const** names = 0; - gchar const** tips = 0; - getThings( _profileSpace, names, tips, _fooScales, inputFormat ); + gchar const** names = 0; + gchar const** tips = 0; + getThings( _prof->getColorSpace(), names, tips, _fooScales ); - _transf = cmsCreateTransform( _prof, inputFormat, _destProf, TYPE_RGBA_8, intent, 0 ); - if ( profChanged ) { - for ( guint i = 0; i < _profChannelCount; i++ ) { - gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), names[i]); + if ( profChanged ) { + for ( guint i = 0; i < _profChannelCount; i++ ) { + gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), names[i]); - gtk_tooltips_set_tip( _tt, _fooSlider[i], tips[i], NULL ); - gtk_tooltips_set_tip( _tt, _fooBtn[i], tips[i], NULL ); + gtk_tooltips_set_tip( _tt, _fooSlider[i], tips[i], NULL ); + gtk_tooltips_set_tip( _tt, _fooBtn[i], tips[i], NULL ); - sp_color_slider_set_colors( SP_COLOR_SLIDER(_fooSlider[i]), - SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), - SPColor(0.5, 0.5, 0.5).toRGBA32(0xff), - SPColor(1.0, 1.0, 1.0).toRGBA32(0xff) ); + sp_color_slider_set_colors( SP_COLOR_SLIDER(_fooSlider[i]), + SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), + SPColor(0.5, 0.5, 0.5).toRGBA32(0xff), + SPColor(1.0, 1.0, 1.0).toRGBA32(0xff) ); /* - _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); - gtk_signal_connect( GTK_OBJECT( _fooAdj[i] ), "value_changed", GTK_SIGNAL_FUNC( _adjustmentChanged ), _csel ); + _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); + gtk_signal_connect( GTK_OBJECT( _fooAdj[i] ), "value_changed", GTK_SIGNAL_FUNC( _adjustmentChanged ), _csel ); - sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_fooSlider[i]), _fooAdj[i] ); - gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_fooBtn[i]), _fooAdj[i] ); - gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_fooBtn[i]), digits ); + sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_fooSlider[i]), _fooAdj[i] ); + gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_fooBtn[i]), _fooAdj[i] ); + gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_fooBtn[i]), digits ); */ - gtk_widget_show( _fooLabel[i] ); - gtk_widget_show( _fooSlider[i] ); - gtk_widget_show( _fooBtn[i] ); - gtk_adjustment_set_value( _fooAdj[i], 0.0 ); - //gtk_adjustment_set_value( _fooAdj[i], val ); - } - for ( guint i = _profChannelCount; i < _fooCount; i++ ) { - gtk_widget_hide( _fooLabel[i] ); - gtk_widget_hide( _fooSlider[i] ); - gtk_widget_hide( _fooBtn[i] ); - gtk_adjustment_set_value( _fooAdj[i], 0.0 ); - } + gtk_widget_show( _fooLabel[i] ); + gtk_widget_show( _fooSlider[i] ); + gtk_widget_show( _fooBtn[i] ); + //gtk_adjustment_set_value( _fooAdj[i], 0.0 ); + //gtk_adjustment_set_value( _fooAdj[i], val ); + } + for ( guint i = _profChannelCount; i < _fooCount; i++ ) { + gtk_widget_hide( _fooLabel[i] ); + gtk_widget_hide( _fooSlider[i] ); + gtk_widget_hide( _fooBtn[i] ); } - } else { - // Give up for now on named colors - _prof = 0; } + } else { + // Give up for now on named colors + _prof = 0; } } @@ -676,7 +691,7 @@ void ColorICCSelector::_updateSliders( gint ignore ) gtk_adjustment_set_value( _fooAdj[i], val ); } - if ( _transf ) { + if ( _prof->getTransfToSRGB8() ) { for ( guint i = 0; i < _profChannelCount; i++ ) { if ( static_cast(i) != ignore ) { icUInt16Number* scratch = getScratch(); @@ -696,7 +711,7 @@ void ColorICCSelector::_updateSliders( gint ignore ) } } - cmsDoTransform( _transf, scratch, _fooMap[i], 1024 ); + cmsDoTransform( _prof->getTransfToSRGB8(), scratch, _fooMap[i], 1024 ); sp_color_slider_set_map( SP_COLOR_SLIDER(_fooSlider[i]), _fooMap[i] ); } } @@ -763,7 +778,7 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC } guchar post[4] = {0,0,0,0}; - cmsDoTransform( iccSelector->_transf, tmp, post, 1 ); + cmsDoTransform( iccSelector->_prof->getTransfToSRGB8(), tmp, post, 1 ); SPColor other( SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255) ); other.icc = new SVGICCColor(); diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index 766bc9741..b5e23c62c 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -37,10 +37,12 @@ protected: static void _sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ); static void _fixupHit( GtkWidget* src, gpointer data ); + static void _profileSelected( GtkWidget* src, gpointer data ); void _recalcColor( gboolean changing ); #if ENABLE_LCMS void _setProfile( SVGICCColor* profile ); + void _switchToProfile( gchar const* name ); #endif // ENABLE_LCMS void _updateSliders( gint ignore ); void _profilesChanged( std::string const & name ); @@ -69,13 +71,9 @@ protected: #if ENABLE_LCMS std::string _profileName; - guint _profIntent; - icColorSpaceSignature _profileSpace; - icProfileClassSignature _profileClass; - cmsHPROFILE _prof; - cmsHPROFILE _destProf; - cmsHTRANSFORM _transf; + Inkscape::ColorProfile* _prof; guint _profChannelCount; + gulong _profChangedID; #endif // ENABLE_LCMS private: