diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-03-29 23:52:42 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-03-29 23:52:42 +0000 |
| commit | a168040d5a452544328a1e6ad35aaac351f94d44 (patch) | |
| tree | fae1ba829f543a473da281bd5fa6e4deabbf6912 /src/color-profile.cpp | |
| parent | Removed function pointers from SPObject and subclasses. (diff) | |
| parent | Dutch translation update (diff) | |
| download | inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.tar.gz inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.zip | |
merged from trunk
(bzr r11608.1.56)
Diffstat (limited to 'src/color-profile.cpp')
| -rw-r--r-- | src/color-profile.cpp | 245 |
1 files changed, 11 insertions, 234 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 9be2ea335..ca44ad49f 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -4,9 +4,9 @@ #define noDEBUG_LCMS -#include <glib/gstdio.h> -#include <sys/fcntl.h> #include <gdkmm/color.h> +#include <glib/gstdio.h> +#include <fcntl.h> #include <glib/gi18n.h> #ifdef DEBUG_LCMS @@ -47,6 +47,8 @@ #include <icm.h> #endif // WIN32 +#include <glibmm/convert.h> + using Inkscape::ColorProfile; using Inkscape::ColorProfileClass; using Inkscape::ColorProfileImpl; @@ -105,6 +107,8 @@ extern guint update_in_progress; static SPObjectClass *cprof_parent_class; +namespace Inkscape { + class ColorProfileImpl { public: #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -131,10 +135,6 @@ public: #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) }; - - -namespace Inkscape { - #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) cmsColorSpaceSignature asICColorSpaceSig(ColorSpaceSig const & sig) { @@ -219,11 +219,6 @@ void ColorProfile::classInit( ColorProfileClass *klass ) SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); cprof_parent_class = static_cast<SPObjectClass*>(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; } CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) { @@ -239,6 +234,8 @@ CColorProfile::~CColorProfile() { void ColorProfile::init( ColorProfile *cprof ) { cprof->ccolorprofile = new CColorProfile(cprof); + + delete cprof->cobject; cprof->cobject = cprof->ccolorprofile; cprof->impl = new ColorProfileImpl(); @@ -253,43 +250,6 @@ void ColorProfile::init( ColorProfile *cprof ) /** * Callback: free object */ -void ColorProfile::release( SPObject *object ) -{ -// // Unregister ourselves -// if ( object->document ) { -// object->document->removeResource("iccprofile", object); -// } -// -// ColorProfile *cprof = COLORPROFILE(object); -// if ( cprof->href ) { -// g_free( cprof->href ); -// cprof->href = 0; -// } -// -// if ( cprof->local ) { -// g_free( cprof->local ); -// cprof->local = 0; -// } -// -// if ( cprof->name ) { -// g_free( cprof->name ); -// cprof->name = 0; -// } -// -// if ( cprof->intentStr ) { -// g_free( cprof->intentStr ); -// cprof->intentStr = 0; -// } -// -//#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -// cprof->impl->_clearProfile(); -//#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -// -// delete cprof->impl; -// cprof->impl = 0; - ((ColorProfile*)object)->ccolorprofile->onRelease(); -} - void CColorProfile::onRelease() { ColorProfile* object = this->colorprofile; @@ -354,30 +314,6 @@ void ColorProfileImpl::_clearProfile() /** * Callback: set attributes from associated repr. */ -void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ) -{ -// ColorProfile *cprof = COLORPROFILE(object); -// g_assert(cprof->href == 0); -// g_assert(cprof->local == 0); -// g_assert(cprof->name == 0); -// g_assert(cprof->intentStr == 0); -// -//// if (cprof_parent_class->build) { -//// (* cprof_parent_class->build)(object, document, repr); -//// } -// -// object->readAttr( "xlink:href" ); -// object->readAttr( "local" ); -// object->readAttr( "name" ); -// object->readAttr( "rendering-intent" ); -// -// // Register -// if ( document ) { -// document->addResource( "iccprofile", object ); -// } - ((ColorProfile*)object)->ccolorprofile->onBuild(document, repr); -} - void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { ColorProfile* object = this->colorprofile; @@ -387,9 +323,6 @@ void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { g_assert(cprof->name == 0); g_assert(cprof->intentStr == 0); -// if (cprof_parent_class->build) { -// (* cprof_parent_class->build)(object, document, repr); -// } CObject::onBuild(document, repr); object->readAttr( "xlink:href" ); @@ -407,124 +340,6 @@ void CColorProfile::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { /** * Callback: set attribute. */ -void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) -{ -// ColorProfile *cprof = COLORPROFILE(object); -// -// switch (key) { -// case SP_ATTR_XLINK_HREF: -// if ( cprof->href ) { -// g_free( cprof->href ); -// cprof->href = 0; -// } -// if ( value ) { -// cprof->href = g_strdup( value ); -// if ( *cprof->href ) { -//#if HAVE_LIBLCMS1 -// cmsErrorAction( LCMS_ERROR_SHOW ); -//#endif -//#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -// -// // TODO open filename and URIs properly -// //FILE* fp = fopen_utf8name( filename, "r" ); -// //LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, cmsUInt32Number dwSize); -// -// // Try to open relative -// SPDocument *doc = object->document; -// if (!doc) { -// doc = SP_ACTIVE_DOCUMENT; -// g_warning("object has no document. using active"); -// } -// //# 1. Get complete URI of document -// gchar const *docbase = doc->getURI(); -// if (!docbase) -// { -// // Normal for files that have not yet been saved. -// docbase = ""; -// } -// -// gchar* escaped = g_uri_escape_string(cprof->href, "!*'();:@=+$,/?#[]", TRUE); -// -// //g_message("docbase:%s\n", docbase); -// org::w3c::dom::URI docUri(docbase); -// //# 2. Get href of icc file. we don't care if it's rel or abs -// org::w3c::dom::URI hrefUri(escaped); -// //# 3. Resolve the href according the docBase. This follows -// // the w3c specs. All absolute and relative issues are considered -// org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri); -// gchar* fullname = g_uri_unescape_string(cprofUri.getNativePath().c_str(), ""); -// cprof->impl->_clearProfile(); -// cprof->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); -// if ( cprof->impl->_profHandle ) { -// cprof->impl->_profileSpace = cmsGetColorSpace( cprof->impl->_profHandle ); -// cprof->impl->_profileClass = cmsGetDeviceClass( cprof->impl->_profHandle ); -// } -// DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->impl->_profHandle ); -// g_free(escaped); -// escaped = 0; -// g_free(fullname); -//#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -// } -// } -// object->requestModified(SP_OBJECT_MODIFIED_FLAG); -// break; -// -// case SP_ATTR_LOCAL: -// if ( cprof->local ) { -// g_free( cprof->local ); -// cprof->local = 0; -// } -// cprof->local = g_strdup( value ); -// object->requestModified(SP_OBJECT_MODIFIED_FLAG); -// break; -// -// case SP_ATTR_NAME: -// if ( cprof->name ) { -// g_free( cprof->name ); -// cprof->name = 0; -// } -// cprof->name = g_strdup( value ); -// DEBUG_MESSAGE( lcmsTwo, "<color-profile> name set to '%s'", cprof->name ); -// object->requestModified(SP_OBJECT_MODIFIED_FLAG); -// break; -// -// case SP_ATTR_RENDERING_INTENT: -// if ( cprof->intentStr ) { -// g_free( cprof->intentStr ); -// cprof->intentStr = 0; -// } -// cprof->intentStr = g_strdup( value ); -// -// if ( value ) { -// if ( strcmp( value, "auto" ) == 0 ) { -// cprof->rendering_intent = RENDERING_INTENT_AUTO; -// } else if ( strcmp( value, "perceptual" ) == 0 ) { -// cprof->rendering_intent = RENDERING_INTENT_PERCEPTUAL; -// } else if ( strcmp( value, "relative-colorimetric" ) == 0 ) { -// cprof->rendering_intent = RENDERING_INTENT_RELATIVE_COLORIMETRIC; -// } else if ( strcmp( value, "saturation" ) == 0 ) { -// cprof->rendering_intent = RENDERING_INTENT_SATURATION; -// } else if ( strcmp( value, "absolute-colorimetric" ) == 0 ) { -// cprof->rendering_intent = RENDERING_INTENT_ABSOLUTE_COLORIMETRIC; -// } else { -// cprof->rendering_intent = RENDERING_INTENT_UNKNOWN; -// } -// } else { -// cprof->rendering_intent = RENDERING_INTENT_UNKNOWN; -// } -// -// object->requestModified(SP_OBJECT_MODIFIED_FLAG); -// break; -// -// default: -// if (cprof_parent_class->set) { -// (* cprof_parent_class->set)(object, key, value); -// } -// break; -// } - ((ColorProfile*)object)->ccolorprofile->onSet(key, value); -} - void CColorProfile::onSet(unsigned key, gchar const *value) { ColorProfile* object = this->colorprofile; @@ -636,9 +451,6 @@ void CColorProfile::onSet(unsigned key, gchar const *value) { break; default: -// if (cprof_parent_class->set) { -// (* cprof_parent_class->set)(object, key, value); -// } CObject::onSet(key, value); break; } @@ -647,38 +459,6 @@ void CColorProfile::onSet(unsigned key, gchar const *value) { /** * Callback: write attributes to associated repr. */ -Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags ) -{ -// ColorProfile *cprof = COLORPROFILE(object); -// -// if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { -// repr = xml_doc->createElement("svg:color-profile"); -// } -// -// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) { -// repr->setAttribute( "xlink:href", cprof->href ); -// } -// -// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->local ) { -// repr->setAttribute( "local", cprof->local ); -// } -// -// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->name ) { -// repr->setAttribute( "name", cprof->name ); -// } -// -// if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->intentStr ) { -// repr->setAttribute( "rendering-intent", cprof->intentStr ); -// } -// -// if (cprof_parent_class->write) { -// (* cprof_parent_class->write)(object, xml_doc, repr, flags); -// } -// -// return repr; - return ((ColorProfile*)object)->ccolorprofile->onWrite(xml_doc, repr, flags); -} - Inkscape::XML::Node* CColorProfile::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { ColorProfile* object = this->colorprofile; @@ -704,9 +484,6 @@ Inkscape::XML::Node* CColorProfile::onWrite(Inkscape::XML::Document *xml_doc, In repr->setAttribute( "rendering-intent", cprof->intentStr ); } -// if (cprof_parent_class->write) { -// (* cprof_parent_class->write)(object, xml_doc, repr, flags); -// } CObject::onWrite(xml_doc, repr, flags); return repr; @@ -870,9 +647,9 @@ bool ColorProfile::GamutCheck(SPColor color) cmsUInt8Number outofgamut = 0; guchar check_color[4] = { - SP_RGBA32_R_U(val), - SP_RGBA32_G_U(val), - SP_RGBA32_B_U(val), + static_cast<guchar>(SP_RGBA32_R_U(val)), + static_cast<guchar>(SP_RGBA32_G_U(val)), + static_cast<guchar>(SP_RGBA32_B_U(val)), 255}; cmsDoTransform(ColorProfile::getTransfGamutCheck(), &check_color, &outofgamut, 1); |
