color-profile.cpp revision daadb3cf82c4d95f2918dd18ab7842ee434a6309
#define DEBUG_LCMS
#ifdef DEBUG_LCMS
#include <gtk/gtkmessagedialog.h>
#endif // DEBUG_LCMS
#include <cstring>
#include <string>
#include "color.h"
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
#include "inkscape.h"
#include "document.h"
#include "preferences.h"
using Inkscape::ColorProfile;
using Inkscape::ColorProfileClass;
namespace Inkscape
{
#if ENABLE_LCMS
#endif // ENABLE_LCMS
}
#ifdef DEBUG_LCMS
extern guint update_in_progress;
#define DEBUG_MESSAGE_SCISLAC(key, ...) \
{\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
\
}\
if ( dumpD )\
{\
);\
dialog); \
}\
}
#define DEBUG_MESSAGE(key, ...)\
{\
g_message( __VA_ARGS__ );\
}
#endif // DEBUG_LCMS
static SPObjectClass *cprof_parent_class;
#if ENABLE_LCMS
if ( !_sRGBProf ) {
}
return _sRGBProf;
}
if ( !_NullProf ) {
}
return _NullProf;
}
#endif // ENABLE_LCMS
/**
* Register ColorProfile class and return its type.
*/
{
return ColorProfile::getType();
}
{
if (!type) {
sizeof(ColorProfileClass),
sizeof(ColorProfile),
16,
NULL, /* value_table */
};
}
return type;
}
/**
* ColorProfile vtable initialization.
*/
{
}
/**
* Callback for ColorProfile object initialization.
*/
{
#if ENABLE_LCMS
cprof->profHandle = 0;
cprof->_revTransf = 0;
cprof->_gamutTransf = 0;
#endif // ENABLE_LCMS
}
/**
* Callback: free object
*/
{
// Unregister ourselves
if ( document ) {
}
}
}
}
}
#if ENABLE_LCMS
cprof->_clearProfile();
#endif // ENABLE_LCMS
}
#if ENABLE_LCMS
void ColorProfile::_clearProfile()
{
if ( _transf ) {
_transf = 0;
}
if ( _revTransf ) {
_revTransf = 0;
}
if ( _gamutTransf ) {
_gamutTransf = 0;
}
if ( profHandle ) {
profHandle = 0;
}
}
#endif // ENABLE_LCMS
/**
* Callback: set attributes from associated repr.
*/
{
if (cprof_parent_class->build) {
}
// Register
if ( document ) {
}
}
/**
* Callback: set attribute.
*/
{
switch (key) {
case SP_ATTR_XLINK_HREF:
}
if ( value ) {
#if ENABLE_LCMS
// TODO open filename and URIs properly
//FILE* fp = fopen_utf8name( filename, "r" );
//LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize);
// Try to open relative
if (!doc) {
g_warning("object has no document. using active");
}
//# 1. Get complete URI of document
if (!docbase)
{
// Normal for files that have not yet been saved.
docbase = "";
}
//g_message("docbase:%s\n", docbase);
//# 2. Get href of icc file. we don't care if it's rel or abs
//# 3. Resolve the href according the docBase. This follows
// the w3c specs. All absolute and relative issues are considered
cprof->_clearProfile();
if ( cprof->profHandle ) {
}
#ifdef DEBUG_LCMS
DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->profHandle );
#endif // DEBUG_LCMS
#endif // ENABLE_LCMS
}
}
break;
case SP_ATTR_LOCAL:
}
break;
case SP_ATTR_NAME:
}
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
break;
case SP_ATTR_RENDERING_INTENT:
}
if ( value ) {
} else {
}
} else {
}
break;
default:
if (cprof_parent_class->set) {
}
break;
}
}
/**
* Callback: write attributes to associated repr.
*/
Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags )
{
}
}
}
}
}
if (cprof_parent_class->write) {
}
return repr;
}
#if ENABLE_LCMS
struct MapMap {
};
{
//icSigLuvData
};
int index = 0;
index = i;
break;
}
}
}
{
int intent = INTENT_PERCEPTUAL;
switch ( svgIntent ) {
break;
break;
break;
case Inkscape::RENDERING_INTENT_UNKNOWN:
case Inkscape::RENDERING_INTENT_AUTO:
default:
}
return intent;
}
{
if ( prof ) {
break;
}
}
}
}
return result;
}
cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* intent, gchar const* name )
{
cmsHPROFILE prof = 0;
if ( thing ) {
}
if ( intent ) {
}
#ifdef DEBUG_LCMS
DEBUG_MESSAGE( lcmsThree, "<color-profile> queried for profile of '%s'. Returning %p with intent of %d", name, prof, (intent? *intent:0) );
#endif // DEBUG_LCMS
return prof;
}
{
if ( !_transf ) {
_transf = cmsCreateTransform( profHandle, _getInputFormat(_profileSpace), getSRGBProfile(), TYPE_RGBA_8, intent, 0 );
}
return _transf;
}
{
if ( !_revTransf ) {
_revTransf = cmsCreateTransform( getSRGBProfile(), TYPE_RGBA_8, profHandle, _getInputFormat(_profileSpace), intent, 0 );
}
return _revTransf;
}
{
if ( !_gamutTransf ) {
_gamutTransf = cmsCreateProofingTransform(getSRGBProfile(), TYPE_RGBA_8, getNULLProfile(), TYPE_GRAY_8, profHandle, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING));
}
return _gamutTransf;
}
BYTE outofgamut = 0;
255};
return (outofgamut == 255);
}
class ProfileInfo
{
public:
private:
};
{
}
{
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
}
}
return result;
}
{
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
}
}
return result;
}
{
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
break;
}
}
return result;
}
#endif // ENABLE_LCMS
{
}
// first try user's local dir
sources.push_back( g_build_filename(base, ".color", "icc", NULL) ); // OpenICC recommends to deprecate this
for ( int i = 0; dataDirs[i]; i++ ) {
}
return sources;
}
#if ENABLE_LCMS
static void findThings() {
if ( g_file_test( it->c_str(), G_FILE_TEST_EXISTS ) && g_file_test( it->c_str(), G_FILE_TEST_IS_DIR ) ) {
if (dir) {
} else {
bool isIccFile = false;
//0-3 == size
//36-39 == 'acsp' 0x61637370
if ( fd != -1 ) {
//size_t left = 40;
if ( got != -1 ) {
isIccFile = (scratch[36] == 'a') && (scratch[37] == 'c') && (scratch[38] == 's') && (scratch[39] == 'p');
}
}
}
}
if ( isIccFile ) {
if ( prof ) {
cmsCloseProfile( prof );
bool sameName = false;
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
sameName = true;
break;
}
}
if ( !sameName ) {
}
}
}
}
}
}
}
}
}
{
return 1;
}
static bool gamutWarn = false;
static bool lastBPC = false;
#if defined(cmsFLAGS_PRESERVEBLACK)
static bool lastPreserveBlack = false;
#endif // defined(cmsFLAGS_PRESERVEBLACK)
static int lastIntent = INTENT_PERCEPTUAL;
static int lastProofIntent = INTENT_PERCEPTUAL;
static cmsHTRANSFORM transf = 0;
{
static cmsHPROFILE theOne = 0;
static bool init = false;
if ( !init ) {
findThings();
init = true;
}
if ( theOne ) {
}
if ( transf ) {
transf = 0;
}
if ( theOne ) {
// a display profile must have the proper stuff
if ( profClass != icSigDisplayClass ) {
g_warning("Not a display profile");
theOne = 0;
} else if ( space != icSigRgbData ) {
g_warning("Not an RGB profile");
theOne = 0;
} else {
}
}
}
} else if ( theOne ) {
theOne = 0;
if ( transf ) {
transf = 0;
}
}
return theOne;
}
{
static cmsHPROFILE theOne = 0;
static bool init = false;
if ( !init ) {
findThings();
init = true;
}
if ( theOne ) {
}
if ( transf ) {
transf = 0;
}
if ( theOne ) {
// a display profile must have the proper stuff
(void)space;
(void)profClass;
/*
if ( profClass != icSigDisplayClass ) {
g_warning("Not a display profile");
cmsCloseProfile( theOne );
theOne = 0;
} else if ( space != icSigRgbData ) {
g_warning("Not an RGB profile");
cmsCloseProfile( theOne );
theOne = 0;
} else {
*/
/*
}
*/
}
}
} else if ( theOne ) {
theOne = 0;
if ( transf ) {
transf = 0;
}
}
return theOne;
}
static void free_transforms();
{
if ( fromDisplay ) {
if ( transf ) {
transf = 0;
}
return 0;
}
#if defined(cmsFLAGS_PRESERVEBLACK)
#endif //defined(cmsFLAGS_PRESERVEBLACK)
|| (lastIntent != intent)
|| (lastProofIntent != proofIntent)
#if defined(cmsFLAGS_PRESERVEBLACK)
|| (preserveBlack != lastPreserveBlack)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
|| (gamutColor != lastGamutColor)
) {
lastIntent = intent;
#if defined(cmsFLAGS_PRESERVEBLACK)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
}
// Fetch these now, as they might clear the transform as a side effect.
if ( !transf ) {
if ( gamutWarn ) {
cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8);
}
if ( bpc ) {
}
#if defined(cmsFLAGS_PRESERVEBLACK)
if ( preserveBlack ) {
}
#endif // defined(cmsFLAGS_PRESERVEBLACK)
transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, hprof, TYPE_RGBA_8, proofProf, intent, proofIntent, dwFlags );
} else if ( hprof ) {
transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, hprof, TYPE_RGBA_8, intent, 0 );
}
}
return transf;
}
class MemProfile {
public:
MemProfile();
~MemProfile();
};
MemProfile::MemProfile() :
id(),
hprof(0),
transf(0)
{
}
MemProfile::~MemProfile()
{
}
void free_transforms()
{
if ( transf ) {
transf = 0;
}
for ( std::vector< std::vector<MemProfile> >::iterator it = perMonitorProfiles.begin(); it != perMonitorProfiles.end(); ++it ) {
}
}
}
}
{
}
}
return id;
}
Glib::ustring Inkscape::colorprofile_set_display_per( gpointer buf, guint bufLen, int screen, int monitor )
{
}
}
}
// Note: if this is not a valid profile, item.hprof will be set to null.
}
return id;
}
{
cmsHTRANSFORM result = 0;
return 0;
}
bool found = false;
for ( std::vector< std::vector<MemProfile> >::iterator it = perMonitorProfiles.begin(); it != perMonitorProfiles.end() && !found; ++it ) {
#if defined(cmsFLAGS_PRESERVEBLACK)
#endif //defined(cmsFLAGS_PRESERVEBLACK)
|| (lastIntent != intent)
|| (lastProofIntent != proofIntent)
#if defined(cmsFLAGS_PRESERVEBLACK)
|| (preserveBlack != lastPreserveBlack)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
|| (gamutColor != lastGamutColor)
) {
lastIntent = intent;
#if defined(cmsFLAGS_PRESERVEBLACK)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
}
// Fetch these now, as they might clear the transform as a side effect.
if ( gamutWarn ) {
cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8);
}
if ( bpc ) {
}
#if defined(cmsFLAGS_PRESERVEBLACK)
if ( preserveBlack ) {
}
#endif // defined(cmsFLAGS_PRESERVEBLACK)
item.transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, item.hprof, TYPE_RGBA_8, proofProf, intent, proofIntent, dwFlags );
item.transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, item.hprof, TYPE_RGBA_8, intent, 0 );
}
}
found = true;
}
}
}
return result;
}
#endif // ENABLE_LCMS
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :