Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a413b595 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fixed two bugs when working with color selectors in HDR mode

1) QVariants are evil. One should use KisNodeWSP with
   KisCanvasResourceProvider::CurrentKritaNode signal, not usual
   shared pointers.

2) Ring color selector should update itself on every setDirty() call,
   not only when the color space changes.

CCBUG:343531
parent be913e74
......@@ -66,7 +66,7 @@ bool KisColorSelectorRing::containsPointInComponentCoords(int x, int y) const
void KisColorSelectorRing::paint(QPainter* painter)
{
if(colorSpace()!=m_cachedColorSpace) {
if(isDirty()) {
m_cachedColorSpace = colorSpace();
m_cachedSize=qMin(width(), height());
colorCache();
......
......@@ -83,7 +83,7 @@ class KisCanvas2::KisCanvas2Private
public:
KisCanvas2Private(KoCanvasBase *parent, KisCoordinatesConverter* coordConverter, QPointer<KisView> view)
KisCanvas2Private(KoCanvasBase *parent, KisCoordinatesConverter* coordConverter, QPointer<KisView> view, KoCanvasResourceManager* resourceManager)
: coordinatesConverter(coordConverter)
, view(view)
, canvasWidget(0)
......@@ -92,7 +92,7 @@ public:
, toolProxy(new KisToolProxy(parent))
, vastScrolling(true)
, popupPalette(0)
, displayColorConverter(new KisDisplayColorConverter(static_cast<KisCanvas2*>(parent)))
, displayColorConverter(new KisDisplayColorConverter(resourceManager, view))
{
}
......@@ -129,7 +129,7 @@ public:
KisCanvas2::KisCanvas2(KisCoordinatesConverter *coordConverter, KoCanvasResourceManager *resourceManager, QPointer<KisView>view, KoShapeBasedDocumentBase *sc)
: KoCanvasBase(sc, resourceManager)
, m_d(new KisCanvas2Private(this, coordConverter, view))
, m_d(new KisCanvas2Private(this, coordConverter, view, resourceManager))
{
// a bit of duplication from slotConfigChanged()
KisConfig cfg;
......
......@@ -43,9 +43,9 @@
struct KisDisplayColorConverter::Private
{
Private(KisDisplayColorConverter *_q, KisCanvas2 *_parentCanvas)
Private(KisDisplayColorConverter *_q, KoCanvasResourceManager *_resourceManager)
: q(_q),
parentCanvas(_parentCanvas),
resourceManager(_resourceManager),
nodeColorSpace(0),
paintingColorSpace(0),
monitorColorSpace(0),
......@@ -54,13 +54,13 @@ struct KisDisplayColorConverter::Private
conversionFlags(KoColorConversionTransformation::InternalConversionFlags),
displayFilter(0),
intermediateColorSpace(0),
displayRenderer(new DisplayRenderer(_q, _parentCanvas))
displayRenderer(new DisplayRenderer(_q, _resourceManager))
{
}
KisDisplayColorConverter * const q;
KisCanvas2 *parentCanvas;
KoCanvasResourceManager *resourceManager;
const KoColorSpace *nodeColorSpace;
const KoColorSpace *paintingColorSpace;
......@@ -98,9 +98,9 @@ struct KisDisplayColorConverter::Private
class DisplayRenderer : public KoColorDisplayRendererInterface {
public:
DisplayRenderer(KisDisplayColorConverter *parent, KisCanvas2 *parentCanvas)
DisplayRenderer(KisDisplayColorConverter *parent, KoCanvasResourceManager *resourceManager)
: m_parent(parent),
m_parentCanvas(parentCanvas)
m_resourceManager(resourceManager)
{
parent->connect(parent, SIGNAL(displayConfigurationChanged()),
this, SIGNAL(displayConfigurationChanged()));
......@@ -129,8 +129,8 @@ struct KisDisplayColorConverter::Private
qreal maxVisibleFloatValue() const {
qreal maxValue = 1.0;
if (m_parentCanvas) {
qreal exposure = m_parentCanvas->resourceManager()->resource(KisCanvasResourceProvider::HdrExposure).value<qreal>();
if (m_resourceManager) {
qreal exposure = m_resourceManager->resource(KisCanvasResourceProvider::HdrExposure).value<qreal>();
maxValue = std::pow(2.0, -exposure);
}
......@@ -139,18 +139,18 @@ struct KisDisplayColorConverter::Private
private:
KisDisplayColorConverter *m_parent;
KisCanvas2 *m_parentCanvas;
KoCanvasResourceManager *m_resourceManager;
};
QScopedPointer<KoColorDisplayRendererInterface> displayRenderer;
};
KisDisplayColorConverter::KisDisplayColorConverter(KisCanvas2 *parentCanvas)
: QObject(parentCanvas),
m_d(new Private(this, parentCanvas))
KisDisplayColorConverter::KisDisplayColorConverter(KoCanvasResourceManager *resourceManager, QObject *parent)
: QObject(parent),
m_d(new Private(this, resourceManager))
{
connect(m_d->parentCanvas->resourceManager(), SIGNAL(canvasResourceChanged(int, const QVariant&)),
connect(m_d->resourceManager, SIGNAL(canvasResourceChanged(int, const QVariant&)),
SLOT(slotCanvasResourceChanged(int, const QVariant&)));
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()),
SLOT(selectPaintingColorSpace()));
......@@ -207,7 +207,7 @@ void KisDisplayColorConverter::Private::updateIntermediateFgColor(const KoColor
void KisDisplayColorConverter::Private::slotCanvasResourceChanged(int key, const QVariant &v)
{
if (key == KisCanvasResourceProvider::CurrentKritaNode) {
KisNodeSP currentNode = v.value<KisNodeSP>();
KisNodeSP currentNode = v.value<KisNodeWSP>();
setCurrentNode(currentNode);
} else if (useOcio() && key == KoCanvasResourceManager::ForegroundColor) {
updateIntermediateFgColor(v.value<KoColor>());
......@@ -297,7 +297,7 @@ void KisDisplayColorConverter::setDisplayFilter(KisDisplayFilter *displayFilter)
KoColor color(m_d->intermediateFgColor);
displayFilter->approximateInverseTransformation(color.data(), 1);
color.convertTo(m_d->paintingColorSpace);
m_d->parentCanvas->resourceManager()->setForegroundColor(color);
m_d->resourceManager->setForegroundColor(color);
}
m_d->displayFilter = displayFilter;
......@@ -315,7 +315,7 @@ void KisDisplayColorConverter::setDisplayFilter(KisDisplayFilter *displayFilter)
}
m_d->updateIntermediateFgColor(
m_d->parentCanvas->resourceManager()->foregroundColor());
m_d->resourceManager->foregroundColor());
}
......
......@@ -29,7 +29,7 @@
class KoColor;
class KoColorProfile;
class KisCanvas2;
class KoCanvasResourceManager;
/**
......@@ -49,7 +49,7 @@ class KRITAUI_EXPORT KisDisplayColorConverter : public QObject
Q_OBJECT
public:
KisDisplayColorConverter(KisCanvas2 *parentCanvas);
KisDisplayColorConverter(KoCanvasResourceManager *resourceManager, QObject *parent);
virtual ~KisDisplayColorConverter();
static KisDisplayColorConverter* dumbConverterInstance();
......
......@@ -323,8 +323,9 @@ QString KoColor::toQString(const KoColor &color)
{
QStringList ls;
foreach(KoChannelInfo *channel, KoChannelInfo::displayOrderSorted(color.colorSpace()->channels())) {
int realIndex = KoChannelInfo::displayPositionToChannelIndex(channel->displayPosition(), color.colorSpace()->channels());
ls << channel->name();
ls << color.colorSpace()->channelValueText(color.data(), channel->pos());
ls << color.colorSpace()->channelValueText(color.data(), realIndex);
}
return ls.join(" ");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment