Commit 74dbe24d authored by Boudewijn Rempt's avatar Boudewijn Rempt

fix warnings

svn path=/trunk/koffice/; revision=1040058
parent b4b8ad40
......@@ -32,7 +32,7 @@ public:
};
KisBaseNode::KisBaseNode()
: m_d(new Private())
: m_d(new Private())
{
setVisible(true);
setUserLocked(false);
......@@ -42,9 +42,9 @@ KisBaseNode::KisBaseNode()
KisBaseNode::KisBaseNode(const KisBaseNode & rhs)
: QObject()
, KisShared(rhs)
, m_d(new Private())
: QObject()
, KisShared(rhs)
, m_d(new Private())
{
QMapIterator<QString, QVariant> iter = rhs.m_d->properties.propertyIterator();
while (iter.hasNext()) {
......@@ -80,14 +80,12 @@ KoDocumentSectionModel::PropertyList KisBaseNode::sectionModelProperties() const
KoDocumentSectionModel::PropertyList l;
l << KoDocumentSectionModel::Property(i18n("Visible"), KIcon("visible"), KIcon("novisible"), visible());
l << KoDocumentSectionModel::Property(i18n("Locked"), KIcon("locked"), KIcon("unlocked"), userLocked());
// XXX: Add linked!
return l;
}
void KisBaseNode::setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties)
{
setVisible(properties.at(0).state.toBool());
dbgImage << "visible = " << properties.at(0).state.toBool() << " " << visible();
setUserLocked(properties.at(1).state.toBool());
}
......
......@@ -104,30 +104,37 @@ bool KisColorSpaceConvertVisitor::convertPaintDevice(KisLayer* layer)
if (layer->original()) {
QUndoCommand* cmd = layer->original()->convertTo(m_dstColorSpace, m_renderingIntent);
if (m_image->undoAdapter())
if (cmd)
if (m_image->undoAdapter()) {
if (cmd) {
m_image->undoAdapter()->addCommand(cmd);
else
delete cmd;
}
}
else {
delete cmd;
}
}
if (layer->paintDevice()) {
QUndoCommand* cmd = layer->paintDevice()->convertTo(m_dstColorSpace, m_renderingIntent);
if (m_image->undoAdapter())
if (cmd)
if (m_image->undoAdapter()) {
if (cmd) {
m_image->undoAdapter()->addCommand(cmd);
else
delete cmd;
}
}
}
else {
delete cmd;
} }
if (layer->projection()) {
QUndoCommand* cmd = layer->projection()->convertTo(m_dstColorSpace, m_renderingIntent);
if (m_image->undoAdapter())
if (cmd)
if (m_image->undoAdapter()) {
if (cmd) {
m_image->undoAdapter()->addCommand(cmd);
else
delete cmd;
}
}
}
else {
delete cmd;
} }
layer->setDirty();
......
......@@ -105,9 +105,6 @@ KoDocumentSectionModel::PropertyList KisLayer::sectionModelProperties() const
void KisLayer::setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties)
{
KisBaseNode::setSectionModelProperties(properties);
/// TODO no nope not at all, the state contains a use-visible string not the actual property
// setOpacity( properties.at( 2 ).state.toInt() );
// setCompositeOp( const_cast<KoCompositeOp*>( image()->colorSpace()->compositeOp( properties.at( 3 ).state.toString() ) ) );
}
void KisLayer::setChannelFlags(const QBitArray & channelFlags)
......
......@@ -37,7 +37,7 @@ class KisPaintLayer::Private
{
public:
KisPaintDeviceSP paintDevice;
//KisPaintDeviceSP driedPaintDevice;
bool alphaLocked;
};
KisPaintLayer::KisPaintLayer(KisImageWSP img, const QString& name, quint8 opacity, KisPaintDeviceSP dev)
......@@ -47,6 +47,7 @@ KisPaintLayer::KisPaintLayer(KisImageWSP img, const QString& name, quint8 opacit
Q_ASSERT(img);
Q_ASSERT(dev);
m_d->paintDevice = dev;
m_d->alphaLocked = false;
}
......@@ -57,6 +58,7 @@ KisPaintLayer::KisPaintLayer(KisImageWSP img, const QString& name, quint8 opacit
{
Q_ASSERT(img);
m_d->paintDevice = new KisPaintDevice(this, img->colorSpace());
m_d->alphaLocked = false;
}
KisPaintLayer::KisPaintLayer(KisImageWSP img, const QString& name, quint8 opacity, const KoColorSpace * colorSpace)
......@@ -69,6 +71,7 @@ KisPaintLayer::KisPaintLayer(KisImageWSP img, const QString& name, quint8 opacit
}
Q_ASSERT(colorSpace);
m_d->paintDevice = new KisPaintDevice(this, colorSpace);
m_d->alphaLocked = false;
}
KisPaintLayer::KisPaintLayer(const KisPaintLayer& rhs)
......@@ -76,6 +79,7 @@ KisPaintLayer::KisPaintLayer(const KisPaintLayer& rhs)
, KisIndirectPaintingSupport(rhs)
, m_d(new Private)
{
m_d->alphaLocked = rhs.m_d->alphaLocked;
m_d->paintDevice = new KisPaintDevice(*rhs.m_d->paintDevice.data());
m_d->paintDevice->setParentNode(this);
}
......@@ -135,12 +139,21 @@ QIcon KisPaintLayer::icon() const
KoDocumentSectionModel::PropertyList KisPaintLayer::sectionModelProperties() const
{
KoDocumentSectionModel::PropertyList l = KisLayer::sectionModelProperties();
l << KoDocumentSectionModel::Property(i18n("ColorSpace"), m_d->paintDevice->colorSpace()->name());
if (const KoColorProfile *profile = m_d->paintDevice->colorSpace()->profile())
l << KoDocumentSectionModel::Property(i18n("Profile"), profile->name());
// XXX: get right icons
l << KoDocumentSectionModel::Property(i18n("Alpha Locked"), KIcon("object-locked-unverified"), KIcon("object-locked-verified"), alphaLocked());
return l;
}
void KisPaintLayer::setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties)
{
foreach (KoDocumentSectionModel::Property property, properties) {
if (property.name == i18n("Alpha Locked")) {
setAlphaLocked(property.state.toBool());
}
}
KisLayer::setSectionModelProperties(properties);
}
const KoColorSpace * KisPaintLayer::colorSpace() const
{
return m_d->paintDevice->colorSpace();
......@@ -163,18 +176,15 @@ QRect KisPaintLayer::exactBounds() const
return rect | KisLayer::exactBounds();
}
/* unused *
KisPaintDeviceSP KisPaintLayer::driedPaintDevice()
bool KisPaintLayer::alphaLocked() const
{
return m_d->driedPaintDevice;
return m_d->alphaLocked;
}
void KisPaintLayer::removeDriedPaintDevice()
void KisPaintLayer::setAlphaLocked(bool l)
{
m_d->driedPaintDevice = 0;
m_d->alphaLocked = l;
}
*/
#include "kis_paint_layer.moc"
......@@ -63,9 +63,12 @@ public:
const QRect& rect) const;
QIcon icon() const;
KoDocumentSectionModel::PropertyList sectionModelProperties() const;
void setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties);
public:
QRect extent() const;
QRect exactBounds() const;
......@@ -83,17 +86,14 @@ public:
KisPaintDeviceSP original() const;
/**
* Return the dried pixels -- i.e., pixels that have been fixed
* through the physics process. This may be 0. The physics process
* will automatically set this paint device when it becomes needed.
* @returns true when painting should not affect the alpha channel
*/
//KisPaintDeviceSP driedPaintDevice();
bool alphaLocked() const;
/**
* Sets the dried paint device associated with this paint layer to
* 0.
* @param l if true, the alpha channel will be protected from modification
*/
//void removeDriedPaintDevice();
void setAlphaLocked(bool l);
public slots:
......
......@@ -103,6 +103,7 @@ struct KisPainter::Private {
KisFillPainter* fillPainter;
qint32 maskImageWidth;
qint32 maskImageHeight;
bool alphaLocked;
};
KisPainter::KisPainter()
......@@ -146,6 +147,7 @@ void KisPainter::init()
d->fillPainter = 0;
d->maskImageWidth = 255;
d->maskImageHeight = 255;
d->alphaLocked = false;
KConfigGroup cfg = KGlobal::config()->group("");
d->useBoundingDirtyRect = cfg.readEntry("aggregate_dirty_regions", true);
......@@ -320,6 +322,7 @@ void KisPainter::bitBlt(qint32 dx, qint32 dy,
d->colorSpace->bitBlt(dstIt.rawData(),
dstRowStride,
d->alphaLocked,
srcCs,
srcIt.rawData(),
srcRowStride,
......@@ -368,6 +371,7 @@ void KisPainter::bitBlt(qint32 dx, qint32 dy,
d->colorSpace->bitBlt(dstIt.rawData(),
dstRowStride,
d->alphaLocked,
srcCs,
srcIt.rawData(),
srcRowStride,
......@@ -439,6 +443,7 @@ void KisPainter::bltFixed(qint32 dx, qint32 dy,
d->colorSpace->bitBlt(dstBytes,
sw * d->device->pixelSize(),
d->alphaLocked,
srcCs,
srcDev->data() + sx,
srcDev->bounds().width() * srcDev->pixelSize(),
......@@ -454,6 +459,7 @@ void KisPainter::bltFixed(qint32 dx, qint32 dy,
} else {
d->colorSpace->bitBlt(dstBytes,
sw * d->device->pixelSize(),
d->alphaLocked,
srcCs,
srcDev->data() + sx,
srcDev->bounds().width() * srcDev->pixelSize(),
......@@ -1735,3 +1741,14 @@ void KisPainter::setMaskImageSize(qint32 width, qint32 height)
d->fillPainter = 0;
d->polygonMaskImage = QImage();
}
void KisPainter::setLockAlpha(bool protect)
{
d->alphaLocked = protect;
}
bool KisPainter::alphaLocked() const
{
return d->alphaLocked;
}
......@@ -273,6 +273,7 @@ public:
* specified end position.
*
* XXX: this method really should work with subpixel precision for start and end position
* XXX: this method does not use the composite op
*/
void drawLine(const QPointF & start, const QPointF & end);
......@@ -281,6 +282,7 @@ public:
* specified end position.
*
* XXX: this method really should work with subpixel precision for start and end position
* XXX: this method does not use the composite op
*/
void drawDDALine(const QPointF & start, const QPointF & end);
......@@ -289,12 +291,15 @@ public:
* end position.
*
* XXX: this method really should work with subpixel precision for start and end position
* XXX: this method does not use the composite op
*/
void drawWobblyLine(const QPointF & start, const QPointF & end);
/**
* Paint an unstroked, one-pixel wide line from the specified start to the specified
* end position using the Wu algorithm
*
* XXX: this method does not use the composite op
*/
void drawWuLine(const QPointF & start, const QPointF & end);
......@@ -305,6 +310,7 @@ public:
*
* XXX: the width should be set in doubles, not integers.
* XXX: this method really should work with subpixel precision for start and end position
* XXX: this method does not use the composite op
*/
void drawThickLine(const QPointF & start, const QPointF & end, int startWidth, int endWidth);
......@@ -460,6 +466,13 @@ public:
*/
void setMaskImageSize(qint32 width, qint32 height);
/**
* If the alpha channel is locked, the alpha values of the paint device we are painting on
* will not change.
*/
void setLockAlpha(bool protect);
bool alphaLocked() const;
protected:
/// Initialize, set everything to '0' or defaults
void init();
......
......@@ -93,12 +93,6 @@ void KisToolBrush::initPaint(KoPointerEvent *e)
return;
}
#if 0
// XXX: TOOL_REFACTOR: how to update all of the canvas? Or how to
// find out the cursor area around the cursor so we can remove the
// outline?
m_canvas->updateCanvas(); // remove the outline
#endif
m_painter->setPaintOpPreset(currentPaintOpPreset(), currentImage());
if (m_painter->paintOp()->incremental()) {
m_timer->start(m_rate);
......@@ -121,14 +115,6 @@ void KisToolBrush::mouseMoveEvent(KoPointerEvent *e)
}
}
#if 0
// XXX: TOOL_REFACTOR
void KisToolBrush::leave(QEvent */*e*/)
{
m_canvs->updateCanvas(); // remove the outline
}
#endif
void KisToolBrush::slotSetRate(qreal rate)
{
......
......@@ -80,10 +80,10 @@
// #define ENABLE_RECORDING
KisToolFreehand::KisToolFreehand(KoCanvasBase * canvas, const QCursor & cursor, const QString & transactionText)
: KisToolPaint(canvas, cursor)
, m_dragDist(0)
, m_transactionText(transactionText)
, m_mode(HOVER)
: KisToolPaint(canvas, cursor)
, m_dragDist(0)
, m_transactionText(transactionText)
, m_mode(HOVER)
{
m_painter = 0;
m_tempLayer = 0;
......@@ -114,9 +114,9 @@ KisToolFreehand::~KisToolFreehand()
void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
{
// dbgUI << "mousePressEvent" << m_mode;
// if (!currentImage())
// return;
// dbgUI << "mousePressEvent" << m_mode;
// if (!currentImage())
// return;
if (!currentNode())
return;
......@@ -136,9 +136,9 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
if (e->button() == Qt::LeftButton) {
initPaint(e);
m_previousPaintInformation = KisPaintInformation(convertToPixelCoord(adjustPosition(e->point)),
e->pressure(), e->xTilt(), e->yTilt(),
KisVector2D::Zero(),
e->rotation(), e->tangentialPressure());
e->pressure(), e->xTilt(), e->yTilt(),
KisVector2D::Zero(),
e->rotation(), e->tangentialPressure());
paintAt(m_previousPaintInformation);
if (!m_smooth) {
#ifdef ENABLE_RECORDING
......@@ -166,9 +166,9 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
QPointF dragVec = pos - m_previousPaintInformation.pos();
KisPaintInformation info = KisPaintInformation(pos,
e->pressure(), e->xTilt(), e->yTilt(),
toKisVector2D(dragVec),
e->rotation(), e->tangentialPressure());
e->pressure(), e->xTilt(), e->yTilt(),
toKisVector2D(dragVec),
e->rotation(), e->tangentialPressure());
if (m_smooth) {
QPointF newTangent;
......@@ -179,8 +179,8 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
double cosTangent = cos(angleTangent);
double sinTangent = sin(angleTangent);
newTangent = QPointF(
cosTangent * dragVec.x() - sinTangent * dragVec.y(),
sinTangent * dragVec.x() + cosTangent * dragVec.y());
cosTangent * dragVec.x() - sinTangent * dragVec.y(),
sinTangent * dragVec.x() + cosTangent * dragVec.y());
}
if (norm(newTangent) != 0) {
......@@ -251,7 +251,7 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
void KisToolFreehand::mouseReleaseEvent(KoPointerEvent* e)
{
// dbgUI << "mouseReleaseEvent" << m_mode << " " << e->button() << " " << e->button();
// dbgUI << "mouseReleaseEvent" << m_mode << " " << e->button() << " " << e->button();
if (e->button() == Qt::LeftButton && m_mode == PAINT) {
endPaint();
} else {
......@@ -261,7 +261,7 @@ void KisToolFreehand::mouseReleaseEvent(KoPointerEvent* e)
void KisToolFreehand::initPaint(KoPointerEvent *)
{
// dbgUI << "initPaint";
// dbgUI << "initPaint";
if (!currentNode() || !currentNode()->paintDevice())
return;
......@@ -294,8 +294,8 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
#if 0 //XXX: Warning, investigate what this was supposed to do!
if (l->parentLayer() && (l->parentLayer()->parentLayer() == 0)
&& (l->parentLayer()->childCount() == 1)
&& l->parentLayer()->paintLayerInducesProjectionOptimization(pl)) {
&& (l->parentLayer()->childCount() == 1)
&& l->parentLayer()->paintLayerInducesProjectionOptimization(pl)) {
// If there's a mask, device could've been the mask. The induce function
// should catch this, but better safe than sorry
......@@ -320,6 +320,13 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
setupPainter(m_painter);
if (KisPaintLayer* l = dynamic_cast<KisPaintLayer*>(currentNode().data())) {
m_painter->setChannelFlags(l->channelFlags());
if (l->alphaLocked()) {
m_painter->setLockAlpha(l->alphaLocked());
}
}
// if you're drawing on a temporary layer, the layer already sets this
if (m_paintIncremental) {
m_painter->setCompositeOp(m_compositeOp);
......@@ -364,7 +371,7 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
void KisToolFreehand::endPaint()
{
// dbgUI << "endPaint";
// dbgUI << "endPaint";
m_mode = HOVER;
if (m_painter) {
......@@ -377,7 +384,7 @@ void KisToolFreehand::endPaint()
if (layer && !m_paintIncremental) {
KisTransaction *incrementalTransaction =
dynamic_cast<KisTransaction*>(m_painter->endTransaction());
dynamic_cast<KisTransaction*>(m_painter->endTransaction());
KisPainter painter(m_source, currentSelection());
painter.setCompositeOp(m_compositeOp);
......@@ -401,7 +408,7 @@ void KisToolFreehand::endPaint()
++it;
}
KisIndirectPaintingSupport* indirect =
dynamic_cast<KisIndirectPaintingSupport*>(layer.data());
dynamic_cast<KisIndirectPaintingSupport*>(layer.data());
if (indirect)
indirect->setTemporaryTarget(0);
//m_source->setDirty(painter.dirtyRegion());
......@@ -464,7 +471,7 @@ void KisToolFreehand::paintBezierCurve(const KisPaintInformation &pi1,
void KisToolFreehand::queuePaintJob(FreehandPaintJob* job, FreehandPaintJob* /*previousJob*/)
{
m_paintJobs.append(job);
// dbgUI << "Queue length:" << m_executor->queueLength();
// dbgUI << "Queue length:" << m_executor->queueLength();
m_executor->start(job, -m_paintJobs.size());
}
......
/*
* Copyright (c) 2003 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2003-2009 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,7 +18,6 @@
#include "kis_tool_paint.h"
#include <QWidget>
#include <QRect>
#include <QLayout>
......@@ -84,6 +83,7 @@ KisToolPaint::~KisToolPaint()
{
}
void KisToolPaint::resourceChanged(int key, const QVariant & v)
{
KisTool::resourceChanged(key, v);
......@@ -119,11 +119,11 @@ void KisToolPaint::activate(bool temporary)
}
void KisToolPaint::paint(QPainter&, const KoViewConverter &)
{
}
void KisToolPaint::mouseReleaseEvent(KoPointerEvent *e)
{
if (e->button() == Qt::MidButton) {
......@@ -140,6 +140,7 @@ void KisToolPaint::mouseReleaseEvent(KoPointerEvent *e)
}
QWidget * KisToolPaint::createOptionWidget()
{
......@@ -197,6 +198,7 @@ void KisToolPaint::addOptionWidgetLayout(QLayout *layout)
m_optionWidgetLayout->addLayout(layout, rowCount, 0, 1, 2);
}
void KisToolPaint::addOptionWidgetOption(QWidget *control, QWidget *label)
{
Q_ASSERT(m_optionWidgetLayout != 0);
......@@ -207,12 +209,14 @@ void KisToolPaint::addOptionWidgetOption(QWidget *control, QWidget *label)
m_optionWidgetLayout->addWidget(control, m_optionWidgetLayout->rowCount(), 0, 1, 2);
}
void KisToolPaint::slotSetOpacity(qreal opacityPerCent, bool final)
{
Q_UNUSED(final);
m_opacity = (int)(opacityPerCent * OPACITY_OPAQUE / 100);
}
void KisToolPaint::slotSetCompositeMode(const QString& compositeOp)
{
m_compositeOp = currentNode()->paintDevice()->colorSpace()->compositeOp(compositeOp);
......
......@@ -250,10 +250,10 @@ KoColorConversionTransformation* KoColorSpace::createColorConverter(const KoColo
}
bool KoColorSpace::convertPixelsTo(const quint8 * src,
quint8 * dst,
const KoColorSpace * dstColorSpace,
quint32 numPixels,
KoColorConversionTransformation::Intent renderingIntent) const
quint8 * dst,
const KoColorSpace * dstColorSpace,
quint32 numPixels,
KoColorConversionTransformation::Intent renderingIntent) const
{
if( *this == *dstColorSpace)
{
......@@ -268,6 +268,7 @@ bool KoColorSpace::convertPixelsTo(const quint8 * src,
void KoColorSpace::bitBlt(quint8 *dst,
qint32 dststride,
bool dstAlphaLocked,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
......@@ -280,16 +281,17 @@ void KoColorSpace::bitBlt(quint8 *dst,
const QBitArray & channelFlags) const
{
if ( d->compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( op ), channelFlags);
bitBlt(dst, dststride, dstAlphaLocked, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( op ), channelFlags);
}
else {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( COMPOSITE_OVER ), channelFlags);
bitBlt(dst, dststride, dstAlphaLocked, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( COMPOSITE_OVER ), channelFlags);
}
}
void KoColorSpace::bitBlt(quint8 *dst,
qint32 dststride,
bool dstAlphaLocked,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
......@@ -301,15 +303,16 @@ void KoColorSpace::bitBlt(quint8 *dst,
const QString& op) const
{
if ( d->compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( op ));
bitBlt(dst, dststride, dstAlphaLocked, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( op ));
}
else {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( COMPOSITE_OVER ) );
bitBlt(dst, dststride, dstAlphaLocked, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( COMPOSITE_OVER ) );
}
}
void KoColorSpace::bitBlt(quint8 *dst,
qint32 dstRowStride,
bool dstAlphaLocked,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
......@@ -326,18 +329,23 @@ void KoColorSpace::bitBlt(quint8 *dst,
if (rows <= 0 || cols <= 0)
return;
quint8* alphaBytes = 0;
if (dstAlphaLocked) {
alphaBytes = getAlphaBytes(dst, dstRowStride, rows, cols);
}
if (!(*this == *srcSpace)) {
quint32 conversionBufferStride = cols * pixelSize();
quint32 conversionBufferStride = cols * pixelSize();
QVector<quint8> * conversionCache =
threadLocalConversionCache(rows * conversionBufferStride);
threadLocalConversionCache(rows * conversionBufferStride);
quint8* conversionData = conversionCache->data();
quint8* conversionData = conversionCache->data();