[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Calligra/krita-fixsmudgebrush-silvioheinrich] 7f4cb8e: Revert
From: Silvio Heinrich <plassy () web ! de>
Date: 2011-01-19 17:42:19
Message-ID: 20110119174219.4AAABA60C2 () git ! kde ! org
[Download RAW message or body]
commit 7f4cb8e012a39d8f1f6da19589339e0d13149155
branch krita-fixsmudgebrush-silvioheinrich
Author: Silvio Heinrich <plassy@web.de>
Date: Wed Jan 19 18:22:35 2011 +0100
Revert "Committing the changes included in Silvio Henrich's SmudgeBrush.patch \
submitted to the mailing list in January 3 2011"
This reverts commit d2a1c76a9c00bdfdea8630f1f33f5d63efd40be9.
Done to push the individual commits tho the repo.
diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp \
b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp index \
e03121f..ee7927f 100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
@@ -6,7 +6,6 @@
* Copyright (c) 2004,2010 Cyrille Berger <cberger@cberger.net>
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
* Copyright (c) 2010 José Luis Vergara Toloza <pentalis@gmail.com>
- * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* 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
@@ -41,114 +40,143 @@
#include <kis_selection.h>
#include <kis_brush_based_paintop_settings.h>
+
+// Both limits defined to be 15 units away from the min (0) or max (255) to allow \
actual mixing of colors +const quint8 MIXABLE_UPPER_LIMIT = 240;
+const quint8 MIXABLE_LOWER_LIMIT = 15;
+
+// All pieces of color extracted from the canvas will be centered around \
ANCHOR_POINT +const QPoint ANCHOR_POINT = QPoint(0, 0);
+
+
KisSmudgeOp::KisSmudgeOp(const KisBrushBasedPaintOpSettings *settings, KisPainter \
*painter, KisImageWSP image)
- : KisBrushBasedPaintOp(settings, painter), m_tempDev(0)
+ : KisBrushBasedPaintOp(settings, painter)
+ , m_firstRun(true)
+ , m_tempDev(0)
{
Q_UNUSED(image);
Q_ASSERT(settings);
Q_ASSERT(painter);
m_sizeOption.readOptionSetting(settings);
+ m_opacityOption.readOptionSetting(settings);
m_rateOption.readOptionSetting(settings);
- m_compositeOption.readOptionSetting(settings);
m_sizeOption.sensor()->reset();
+ m_opacityOption.sensor()->reset();
m_rateOption.sensor()->reset();
- m_compositeOption.sensor()->reset();
- m_tempDev = new KisPaintDevice(painter->device()->colorSpace());
- m_firstRun = true;
+ m_tempDev = new KisPaintDevice(painter->device()->colorSpace());
+
+ // Initializing to a valid value to avoid weird errors during modifications
+ m_wholeTempData = QRect(0, 0, 0, 0);
+
+ m_color = painter->paintColor();
}
KisSmudgeOp::~KisSmudgeOp()
{
}
+/* To smudge, one does the following:
-
+ 1.- First step: initialize a temporary paint device (m_tempDev) with a copy of the \
colors below the mouse pointer. + All other times:
+ 2.- Vanishing step: Reduce the transparency of the temporary paint device so as to \
let it mix gradually. + 3.- Combine: Combine the temporary device with the piece the \
brush currently is 'painting', according to a ratio: + in this case, opacity. (This \
is what in the first step does the copying of the data). + 4.- Blit to screen: This \
combination is then composited upon the actual image. + 5.- Special case: If the size \
of the dab (brush mask) changes during the stroke (for example, when + using a stylus \
sensitive to pressure), align the colors extracted to the center of the previously \
absorbed colors, + and in the vanishing step, ensure that all the colors have their \
opacity slowly reduced, not just the ones below + the current brush mask.
+
+ For the sake of speed optimization, the extent of the largest area of color \
contained in the + temporary device is cached such that only the colored areas are \
considered. + TODO: Make this cached value dump colors that have faded nearly \
completely and lie outside of the rectangle (dab) + of the current iteration.
+*/
+
qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
{
- // Simple error catching
- if (!painter()->device())
- return 1.0;
-
KisBrushSP brush = m_brush;
- if(!brush || !brush->canPaintFor(info))
- return 1.0;
-
- // get the scaling factor calculated by the size option
+ // Simple error catching
+ if (!painter()->device()) return 1.0;
+ if (!brush) return 1.0;
+ if (!brush->canPaintFor(info)) return 1.0;
+
+ // Grow the brush (this includes the mask) according to pressure or other \
parameters double scale = m_sizeOption.apply(info);
-
- // don't paint anything if the brush is too samll
- if((scale*brush->width()) <= 0.01 || (scale*brush->height()) <= 0.01)
- return 1.0;
-
+ if ((scale * brush->width()) <= 0.01 || (scale * brush->height()) <= 0.01) \
return 1.0; setCurrentScale(scale);
- QPointF point = info.pos() - brush->hotSpot(scale, scale);
-
+ /* Align a point that represents the top-left corner of the \
brush-stroke-rendering + with the mouse pointer and take into account the brush \
mask size */ + QPointF hotSpot = brush->hotSpot(scale, scale);
+ QPointF pt = info.pos() - hotSpot;
+
+ /* Split the coordinates into integer plus fractional parts. The integer
+ is where the dab will be positioned and the fractional part determines
+ the sub-pixel positioning. */
qint32 x, y;
- qreal xFraction, yFraction; // will not be used
- splitCoordinate(point.x(), &x, &xFraction);
- splitCoordinate(point.y(), &y, &yFraction);
-
+ qreal xFraction, yFraction;
+
+ splitCoordinate(pt.x(), &x, &xFraction);
+ splitCoordinate(pt.y(), &y, &yFraction);
+
KisFixedPaintDeviceSP maskDab = 0;
-
- // Extract the brush mask (maskDab) from brush with the correct scaled size
- if(brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
+
+ // Extract the brush mask (maskDab) from brush, and turn it into a transparency \
mask (alpha8). + if (brush->brushType() == IMAGE || brush->brushType() == \
PIPE_IMAGE) { // This is for bitmap brushes
- maskDab = brush->paintDevice(painter()->device()->colorSpace(), scale, 0.0, \
info, 0.0, 0.0); + maskDab = \
brush->paintDevice(painter()->device()->colorSpace(), scale, 0.0, info, xFraction, \
yFraction); + maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
} else {
// This is for parametric brushes, those created in the Autobrush popup \
config dialogue maskDab = cachedDab();
- brush->mask(maskDab, painter()->paintColor(), scale, scale, 0.0, info, 0.0, \
0.0); + brush->mask(maskDab, m_color, scale, scale, 0.0, info, xFraction, \
yFraction); + maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
}
-
- // transforms the fixed paint device with the current brush to alpha color space \
(to use it as alpha/transparency mask)
- maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
-
- // GET the opacy calculated by the rate option (apply is misleading because the \
opacy will not be applied)
- quint8 newOpacity = m_rateOption.apply(OPACITY_OPAQUE_U8, info);
-
- if(!m_firstRun) {
- // set opacity calculated by the rate option
- // then blit the temporary painting device on the canvas at the current \
brush position
- // the alpha mask (maskDab) will be used here to only blit the pixels that \
are in the area (shape) of the brush
- painter()->setOpacity(newOpacity);
- painter()->setCompositeOp(COMPOSITE_OVER);
- painter()->bitBltWithFixedSelection(x, y, m_tempDev, maskDab, \
maskDab->bounds().width(), maskDab->bounds().height());
- painter()->setOpacity(newOpacity);
- painter()->setCompositeOp(COMPOSITE_COPY_OPACITY);
- painter()->bitBltWithFixedSelection(x, y, m_tempDev, maskDab, \
maskDab->bounds().width(), maskDab->bounds().height()); +
+ // Convenient renaming for the limits of the maskDab
+ qint32 sw = maskDab->bounds().width();
+ qint32 sh = maskDab->bounds().height();
+
+ /* Prepare the top left corner of the temporary paint device where the extracted \
color will be drawn */ + QPoint extractionTopLeft = QPoint(ANCHOR_POINT.x() - sw / \
2, + ANCHOR_POINT.y() - sh / 2);
+
+ /* In the block below, the opacity of the colors stored in m_tempDev
+ is reduced in opacity. Nothing of the color present inside it is left out */
+ quint8 opacity = OPACITY_OPAQUE_U8;
+ if (!m_firstRun) {
+ opacity = m_rateOption.apply(opacity, info);
+ /* Without those limits, the smudge brush doesn't smudge anymore, it either \
makes a single + dropplet of color, or drags a frame indefinitely over the \
canvas. */ + opacity = qBound(MIXABLE_LOWER_LIMIT, opacity, \
MIXABLE_UPPER_LIMIT); +
+ // Invert the opacity value for color absorption in the next lines \
(copyPainter) + opacity = OPACITY_OPAQUE_U8 - opacity;
+ m_wholeTempData |= QRect(extractionTopLeft, maskDab->bounds().size());
}
- else m_firstRun = false;
-
- // IMPORTANT: clear the temporary painting device to color black with zero \
opacity
- // it will only clear the extents of the brush
- m_tempDev->clear(QRect(0, 0, brush->width(), brush->height()));
-
+ else {
+ m_firstRun = false;
+ m_wholeTempData = QRect(extractionTopLeft, maskDab->bounds().size());
+ }
+ /* copyPainter will extract the piece of color (image) to be duplicated to \
generate the smudge effect, + it extracts a simple unmasked rectangle and adds it \
to what was extracted before in this same block of code, + this sometimes shows \
artifacts when the brush is used with stylus and high spacing */ KisPainter \
copyPainter(m_tempDev); + copyPainter.setCompositeOp(COMPOSITE_COPY);
+ copyPainter.setOpacity(opacity);
+ copyPainter.bitBlt(m_wholeTempData.x(), m_wholeTempData.y(), \
painter()->device(), + x - m_wholeTempData.x() + \
extractionTopLeft.x(), + y - m_wholeTempData.y() + \
extractionTopLeft.y(), + m_wholeTempData.width(), \
m_wholeTempData.height()); + copyPainter.end();
- // reset composite mode and opacity
- // then cut out the area from the canvas under the brush
- // and blit it to the temporary painting device
- copyPainter.setCompositeOp(COMPOSITE_OVER);
- copyPainter.setOpacity(OPACITY_OPAQUE_U8);
- copyPainter.bitBlt(0, 0, painter()->device(), x, y, brush->width(), \
brush->width());
-
- // if the user selected the color smudge option
- // we will mix some color into the temorary painting device (m_tempDev)
- if(m_compositeOption.isChecked()) {
- // this will apply the composite mode and the opacy (selected by the user)
- // to copyPainter
- m_compositeOption.apply(©Painter, OPACITY_OPAQUE_U8, info);
-
- // paint a rectangle with the current color (foreground color)
- // into the temporary painting device
- copyPainter.setFillStyle(KisPainter::FillStyleForegroundColor);
- copyPainter.setPaintColor(painter()->paintColor());
- copyPainter.paintRect(maskDab->bounds());
- }
+ // This is the line that renders the extracted colors to the screen, with \
maskDab giving it the brush shape + painter()->bitBltWithFixedSelection(x, y, \
m_tempDev, maskDab, 0, 0, extractionTopLeft.x(), extractionTopLeft.y(), sw, sh); + \
renderMirrorMask(QRect(QPoint(x,y),QSize(sw,sh)),m_tempDev,extractionTopLeft.x(), \
extractionTopLeft.y(),maskDab);
- copyPainter.end();
return spacing(scale);
}
diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h \
b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h index 333df09..6e3e63f \
100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
@@ -5,7 +5,6 @@
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
* Copyright (c) 2010 José Luis Vergara Toloza <pentalis@gmail.com>
- * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* 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
@@ -32,7 +31,6 @@
#include <kis_pressure_opacity_option.h>
#include <kis_pressure_size_option.h>
#include <kis_pressure_rate_option.h>
-#include <kis_pressure_composite_option.h>
class KisBrushBasedPaintOpSettings;
@@ -50,11 +48,16 @@ public:
qreal paintAt(const KisPaintInformation& info);
private:
- bool m_firstRun;
- KisPaintDeviceSP m_tempDev; // The temporary paint device
+ bool m_firstRun;
+ // The "temporary paint device"
+ KisPaintDeviceSP m_tempDev;
+ // The size of the rectangle encompassing the whole data in the temporary device \
needs to be cached for speed + QRect m_wholeTempData;
+ KoColor m_color;
+
KisPressureSizeOption m_sizeOption;
+ KisPressureOpacityOption m_opacityOption;
KisPressureRateOption m_rateOption;
- KisPressureCompositeOption m_compositeOption;
};
#endif // KIS_SMUDGEOP_H_
diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp \
b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp \
index a07d7f4..07a70ca 100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp
@@ -4,7 +4,6 @@
* Copyright (c) 2004 Clarence Dang <dang@kde.org>
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
- * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* 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
@@ -25,13 +24,12 @@
#include "kis_brush_based_paintop_settings.h"
#include <kis_properties_configuration.h>
#include <kis_paintop_options_widget.h>
+#include <kis_pressure_darken_option.h>
+#include <kis_pressure_opacity_option.h>
#include <kis_pressure_size_option.h>
-#include <kis_pressure_composite_option.h>
#include <kis_pressure_rate_option.h>
#include <kis_curve_option_widget.h>
#include <kis_pressure_rate_option_widget.h>
-#include <kis_pressure_composite_option_widget.h>
-
KisSmudgeOpSettingsWidget::KisSmudgeOpSettingsWidget(QWidget* parent)
: KisBrushBasedPaintopOptionWidget(parent)
@@ -39,8 +37,9 @@ KisSmudgeOpSettingsWidget::KisSmudgeOpSettingsWidget(QWidget* \
parent) setObjectName("brush option widget");
addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption()));
+ addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption()));
+ addPaintOpOption(new KisCurveOptionWidget(new KisPressureDarkenOption));
addPaintOpOption(new KisPressureRateOptionWidget());
- addPaintOpOption(new KisPressureCompositeOptionWidget());
}
@@ -52,7 +51,7 @@ KisPropertiesConfiguration* \
KisSmudgeOpSettingsWidget::configuration() const {
KisBrushBasedPaintOpSettings *config = new KisBrushBasedPaintOpSettings();
config->setOptionsWidget(const_cast<KisSmudgeOpSettingsWidget*>(this));
- config->setProperty("paintop", "smudge"); // TODO: make this a const id string
+ config->setProperty("paintop", "smudge"); // XXX: make this a const id string
writeConfiguration(config);
return config;
}
diff --git a/krita/plugins/paintops/libpaintop/CMakeLists.txt \
b/krita/plugins/paintops/libpaintop/CMakeLists.txt index 8465a21..d2cbf4d 100644
--- a/krita/plugins/paintops/libpaintop/CMakeLists.txt
+++ b/krita/plugins/paintops/libpaintop/CMakeLists.txt
@@ -40,8 +40,6 @@ set(kritalibpaintop_LIB_SRCS
kis_pressure_size_option.cpp
kis_pressure_softness_option.cpp
kis_pressure_mix_option.cpp
- kis_pressure_composite_option.cpp
- kis_pressure_composite_option_widget.cpp
kis_sensor_selector.cc
kis_text_brush_chooser.cpp
kis_brush_based_paintop_options_widget.cpp
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp \
b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp deleted file \
mode 100644 index 6d82865..0000000
--- a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) Silvio Heinrich <plassy@web.de>, (C) 2011
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "kis_pressure_composite_option.h"
-
-
-#include <klocale.h>
-
-#include <kis_painter.h>
-#include <widgets/kis_curve_widget.h>
-
-#include <KoColor.h>
-#include <KoColorSpace.h>
-#include <KoCompositeOp.h>
-
-KisPressureCompositeOption::KisPressureCompositeOption()
- : KisCurveOption(i18n("Color"), "Color", KisPaintOpOption::brushCategory(), \
false)
-{
- setMinimumLabel(i18n("No Color"));
- setMaximumLabel(i18n("Full Color"));
-}
-
-void KisPressureCompositeOption::writeOptionSetting(KisPropertiesConfiguration* \
setting) const
-{
- KisCurveOption::writeOptionSetting(setting);
- setting->setProperty("CompositeOp", m_compositeOp);
- setting->setProperty("CompositeRateValue", m_rate);
-}
-
-void KisPressureCompositeOption::readOptionSetting(const KisPropertiesConfiguration* \
setting)
-{
- KisCurveOption::readOptionSetting(setting);
- m_compositeOp = setting->getString("CompositeOp");
- m_rate = setting->getInt("CompositeRateValue");
-
- if(m_compositeOp == "") //TODO: test if compositeOp is valid instead of just \
testing for an empty string
- m_compositeOp = COMPOSITE_OVER;
-}
-
-void KisPressureCompositeOption::apply(KisPainter* painter, qint8 opacity, const \
KisPaintInformation& info) const
-{
- if(!isChecked())
- return;
-
- QString oldCompositeOp = painter->compositeOp()->id();
-
- opacity = (m_rate * 255) / 100;
- opacity = qBound((qint32)OPACITY_TRANSPARENT_U8,
- (qint32)(double(opacity) * computeValue(info) / \
PRESSURE_DEFAULT),
- (qint32)OPACITY_OPAQUE_U8);
-
- painter->setCompositeOp(m_compositeOp);
- painter->setOpacity(opacity);
-}
-
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h \
b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h deleted file mode \
100644 index 1ed6ff7..0000000
--- a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) Silvio Heinrich <plassy@web.de>, (C) 2011
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef KIS_PRESSURE_COMPOSITE_OPTION_H
-#define KIS_PRESSURE_COMPOSITE_OPTION_H
-
-#include "kis_curve_option.h"
-#include <kis_paint_information.h>
-#include <krita_export.h>
-#include <kis_types.h>
-
-class QSlider;
-class KisPropertiesConfiguration;
-class KisPainter;
-
-class PAINTOP_EXPORT KisPressureCompositeOption : public KisCurveOption
-{
-public:
- KisPressureCompositeOption();
-
- /**
- * Set the composite mode and opacity of the painter based on the user selection
- * and the pressure curve (if checked)
- */
- void apply(KisPainter* painter, qint8 opacity, const KisPaintInformation& info) \
const;
-
- void writeOptionSetting(KisPropertiesConfiguration* setting) const;
- void readOptionSetting(const KisPropertiesConfiguration* setting);
-
- void setCompositeOp(const QString& compositeOp) { m_compositeOp = compositeOp; }
- QString getCompositeOp() { return m_compositeOp; }
-
- void setRate(int rate) { m_rate = rate; }
- int getRate() { return m_rate; }
-
-private:
- QString m_compositeOp;
- int m_rate;
-};
-
-#endif // KIS_PRESSURE_COMPOSITE_OPTION_H
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp \
b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp deleted \
file mode 100644 index f075a3c..0000000
--- a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) Silvio Heinrich <plassy@web.de>, (C) 2011
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "kis_pressure_composite_option_widget.h"
-#include "kis_pressure_composite_option.h"
-
-#include <KoCompositeOp.h>
-
-#include <QWidget>
-#include <QCheckBox>
-#include <QLabel>
-#include <QComboBox>
-#include <QSlider>
-#include <QVBoxLayout>
-#include <QGridLayout>
-
-#include <klocale.h>
-
-KisPressureCompositeOptionWidget::KisPressureCompositeOptionWidget()
- : KisCurveOptionWidget(new KisPressureCompositeOption())
-{
- QWidget* widget = new QWidget;
- QLabel* modeLabel = new QLabel(i18n("Mode: "));
- QLabel* rateLabel = new QLabel(i18n("Rate: "));
-
- m_compositeOpBox = new QComboBox();
- m_compositeOpBox->addItem(COMPOSITE_OVER);
- m_compositeOpBox->addItem(COMPOSITE_OVERLAY);
- m_compositeOpBox->addItem(COMPOSITE_SCREEN);
- m_compositeOpBox->addItem(COMPOSITE_ADD);
- m_compositeOpBox->addItem(COMPOSITE_SUBTRACT);
- m_compositeOpBox->addItem(COMPOSITE_DIVIDE);
- m_compositeOpBox->addItem(COMPOSITE_BURN);
- m_compositeOpBox->addItem(COMPOSITE_DODGE);
- m_compositeOpBox->addItem(COMPOSITE_COLOR);
- m_compositeOpBox->addItem(COMPOSITE_HARD_LIGHT);
- m_compositeOpBox->addItem(COMPOSITE_SOFT_LIGHT);
-
- m_rateSlider = new QSlider();
- m_rateSlider->setMinimum(0);
- m_rateSlider->setMaximum(100);
- m_rateSlider->setPageStep(1);
- m_rateSlider->setValue(90);
- m_rateSlider->setOrientation(Qt::Horizontal);
-
- connect(m_compositeOpBox, SIGNAL(activated(QString)), this, \
SLOT(compositeOpChanged(QString)));
- connect(m_rateSlider, SIGNAL(valueChanged(int)), this, SLOT(rateChanged(int)));
-
- QGridLayout* gridLayout = new QGridLayout();
- gridLayout->addWidget(modeLabel, 0, 0);
- gridLayout->addWidget(m_compositeOpBox, 0, 1);
- gridLayout->addWidget(rateLabel, 1, 0);
- gridLayout->addWidget(m_rateSlider, 1, 1);
-
- QVBoxLayout* vBoxLayout = new QVBoxLayout;
- vBoxLayout->addLayout(gridLayout);
- vBoxLayout->addWidget(curveWidget());
-
- widget->setLayout(vBoxLayout);
-
- setConfigurationPage(widget);
-
- compositeOpChanged(COMPOSITE_OVER);
- rateChanged(m_rateSlider->value());
-}
-
-void KisPressureCompositeOptionWidget::readOptionSetting(const \
KisPropertiesConfiguration* setting)
-{
- KisCurveOptionWidget::readOptionSetting(setting);
-
- QString compositeOp = \
static_cast<KisPressureCompositeOption*>(curveOption())->getCompositeOp();
-
- for(int i=0; i<m_compositeOpBox->count(); ++i) {
- if(m_compositeOpBox->itemText(i) == compositeOp) {
- m_compositeOpBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_rateSlider->setValue(static_cast<KisPressureCompositeOption*>(curveOption())->getRate());
-}
-
-void KisPressureCompositeOptionWidget::compositeOpChanged(const QString& \
compositeOp)
-{
- static_cast<KisPressureCompositeOption*>(curveOption())->setCompositeOp(compositeOp);
- emit sigSettingChanged();
-}
-
-void KisPressureCompositeOptionWidget::rateChanged(int rate)
-{
- static_cast<KisPressureCompositeOption*>(curveOption())->setRate(rate);
- emit sigSettingChanged();
-}
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h \
b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h deleted \
file mode 100644 index 30c09ce..0000000
--- a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) Silvio Heinrich <plassy@web.de>, (C) 2011
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef KIS_PRESSURE_COMPOSITE_OPTION_WIDGET_H
-#define KIS_PRESSURE_COMPOSITE_OPTION_WIDGET_H
-
-#include "kis_curve_option_widget.h"
-
-class QComboBox;
-class QSlider;
-
-class PAINTOP_EXPORT KisPressureCompositeOptionWidget : public KisCurveOptionWidget
-{
- Q_OBJECT
-
-public:
- KisPressureCompositeOptionWidget();
-
- void readOptionSetting(const KisPropertiesConfiguration* setting);
-
-private slots:
- void compositeOpChanged(const QString& compositeOp);
- void rateChanged(int rate);
-
-private:
- QComboBox* m_compositeOpBox;
- QSlider* m_rateSlider;
-};
-
-#endif // KIS_PRESSURE_COMPOSITE_OPTION_WIDGET_H
diff --git a/libs/pigment/compositeops/KoCompositeOpCopyOpacy.h \
b/libs/pigment/compositeops/KoCompositeOpCopyOpacy.h deleted file mode 100644
index 03a43d2..0000000
--- a/libs/pigment/compositeops/KoCompositeOpCopyOpacy.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KOCOMPOSITEOPCOPYOPACY_H_
-#define KOCOMPOSITEOPCOPYOPACY_H_
-
-#include <KoColorSpaceMaths.h>
-#include <KoCompositeOp.h>
-#include <KoColorSpaceConstants.h>
-
-/**
- * A template version of the copy opacy composite operation to use in colorspaces.
- */
-template<class _CSTraits>
-class KoCompositeOpCopyOpacy : public KoCompositeOp
-{
- typedef typename _CSTraits::channels_type channels_type;
- static const qint32 channels_nb = _CSTraits::channels_nb;
- static const qint32 alpha_pos = _CSTraits::alpha_pos;
- static const qint32 pixelSize = _CSTraits::pixelSize;
-
-public:
- KoCompositeOpCopyOpacy(const KoColorSpace * cs)
- : KoCompositeOp(cs, COMPOSITE_COPY_OPACITY, i18n("Copy Opacy"), \
KoCompositeOp::categoryArithmetic(), true) {
- }
-
-public:
- inline static channels_type selectAlpha(channels_type srcAlpha, channels_type \
dstAlpha) {
- return qMin(srcAlpha, dstAlpha);
- }
-
- void composite(quint8 *dstRowStart,
- qint32 dstRowStride,
- const quint8 *srcRowStart,
- qint32 srcRowStride,
- const quint8 *maskRowStart,
- qint32 maskRowStride,
- qint32 rows,
- qint32 cols,
- quint8 U8_opacity,
- const QBitArray & channelFlags) const
- {
- bool useMask = maskRowStart != 0;
- channels_type opacity = \
KoColorSpaceMaths<quint8,channels_type>::scaleToA(U8_opacity);
-
- if(srcRowStride != 0) {
- for(; rows>0; --rows) {
- const quint8* mskRowItr = maskRowStart;
- const channels_type* srcRowItr = reinterpret_cast<const \
channels_type*>(srcRowStart) + alpha_pos;
- channels_type* dstRowItr = \
reinterpret_cast<channels_type*>(dstRowStart) + alpha_pos;
-
- for(qint32 c=cols; c>0; --c) {
- channels_type value = 0;
-
- switch(U8_opacity)
- {
- case OPACITY_TRANSPARENT_U8: { value = *dstRowItr; } break;
- case OPACITY_OPAQUE_U8: { value = *srcRowItr; } break;
- default: { value = \
KoColorSpaceMaths<channels_type>::blend(*srcRowItr, *dstRowItr, \
opacity); } break;
- }
-
- if(useMask) {
- channels_type blend = \
KoColorSpaceMaths<quint8,channels_type>::scaleToA(*mskRowItr);
- value = KoColorSpaceMaths<channels_type>::blend(value, \
*dstRowItr, blend);
- ++mskRowItr;
- }
-
- value = (value > *dstRowItr) ? (value-1) : value;
- *dstRowItr = value;
- srcRowItr += channels_nb;
- dstRowItr += channels_nb;
- }
-
- srcRowStart += srcRowStride;
- dstRowStart += dstRowStride;
- maskRowStart += maskRowStride;
- }
- }
- else {
- channels_type srcValue = *(reinterpret_cast<const \
channels_type*>(srcRowStart) + alpha_pos);
-
- for(; rows>0; --rows) {
- const quint8* mskRowItr = maskRowStart;
- channels_type* dstRowItr = \
reinterpret_cast<channels_type*>(dstRowStart) + alpha_pos;
-
- for(qint32 c=cols; c>0; --c) {
- channels_type value = 0;
-
- switch(U8_opacity)
- {
- case OPACITY_TRANSPARENT_U8: { value = *dstRowItr; } break;
- case OPACITY_OPAQUE_U8: { value = srcValue; } break;
- default: { value = \
KoColorSpaceMaths<channels_type>::blend(srcValue, *dstRowItr, \
opacity); } break;
- }
-
- if(useMask) {
- channels_type blend = \
KoColorSpaceMaths<quint8,channels_type>::scaleToA(*mskRowItr);
- value = KoColorSpaceMaths<channels_type>::blend(value, \
*dstRowItr, blend);
- ++mskRowItr;
- }
-
- value = (value > *dstRowItr) ? (value-1) : value;
- *dstRowItr = value;
- dstRowItr += channels_nb;
- }
-
- srcRowStart += srcRowStride;
- dstRowStart += dstRowStride;
- maskRowStart += maskRowStride;
- }
- }
- }
-
-};
-
-#endif // KOCOMPOSITEOPCOPYOPACY_H_
diff --git a/libs/pigment/compositeops/KoCompositeOps.h \
b/libs/pigment/compositeops/KoCompositeOps.h index b222f32..d278234 100644
--- a/libs/pigment/compositeops/KoCompositeOps.h
+++ b/libs/pigment/compositeops/KoCompositeOps.h
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
- * Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
+ * Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -38,7 +37,6 @@
#include "compositeops/KoCompositeOpSoftlight.h"
#include "compositeops/KoCompositeOpHardlight.h"
#include "compositeops/KoCompositeOpCopy2.h"
-#include "compositeops/KoCompositeOpCopyOpacy.h"
/**
* This function add to the colorspace all the composite ops defined by
@@ -61,7 +59,6 @@ void addStandardCompositeOps(KoColorSpace* cs)
cs->addCompositeOp(new KoCompositeOpSubtract<_Traits_>(cs));
cs->addCompositeOp(new KoCompositeOpSoftlight<_Traits_>(cs));
cs->addCompositeOp(new KoCompositeOpHardlight<_Traits_>(cs));
- cs->addCompositeOp(new KoCompositeOpCopyOpacy<_Traits_>(cs));
}
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic