[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-kimageshop
Subject: Re: Grayscale Selections
From: Sven Langkamp <sven.langkamp () gmail ! com>
Date: 2011-07-16 18:46:31
Message-ID: CAAmsBfnBVB_JT3zMvh-RLTB83Lk5R5Gw0=y+UAVLQuuKp5zBpQ () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On Sun, Jul 3, 2011 at 11:33 AM, Cyrille Berger Skott
<cberger@cberger.net>wrote:
> On Saturday 02 July 2011, Sven Langkamp wrote:
> > On Sat, Jul 2, 2011 at 5:28 PM, Cyrille Berger Skott
> <cberger@cberger.net>wrote:
> > > On Tuesday 28 June 2011, Cyrille Berger Skott wrote:
> > > > Alternatively, you need to refactor pigment, you have two paths:
> > > > * huge refactoring: the alpha channel is seperated from the color
> > > > space, and RGB and RGBA becomes the same class (or Gray and GrayA),
> in
> > > > the paint device, the channel is added seperately, and when bitblt,
> we
> > > > pass a seperate pointer to the alpha channel, that can be null or not
> > > > (ie like the mask)
> > > > * smaller solution: make it possible to create composite op that work
> > > > across color spaces
> > >
> > > There is a third solution
> > > * detect in KoColorSpace::bitBlt that the destination color space is
> the
> > > same
> > > as the source color space without alpha, and add an alpha channel to
> the
> > > data
> > > and then discard it, but that is not going to be performant.
> >
> > I thought about that too, but then you pratically need another paint
> device
> > in grayscale colorspace than is used for a tempory bitBlt.
> > Of course that means two bitBlt.
>
> Well no. you can do it directly in KoColorSpace::bitBlt.
>
Try that but I didn't get it to work, see attachment. Is that what you
suggested?
[Attachment #5 (text/html)]
<div class="gmail_quote">On Sun, Jul 3, 2011 at 11:33 AM, Cyrille Berger Skott <span \
dir="ltr"><<a href="mailto:cberger@cberger.net">cberger@cberger.net</a>></span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex;"> <div><div></div><div class="h5">On Saturday 02 July \
2011, Sven Langkamp wrote:<br> > On Sat, Jul 2, 2011 at 5:28 PM, Cyrille Berger \
Skott<br> <<a href="mailto:cberger@cberger.net">cberger@cberger.net</a>>wrote:<br>
> > On Tuesday 28 June 2011, Cyrille Berger Skott wrote:<br>
> > > Alternatively, you need to refactor pigment, you have two paths:<br>
> > > * huge refactoring: the alpha channel is seperated from the color<br>
> > > space, and RGB and RGBA becomes the same class (or Gray and GrayA), \
in<br> > > > the paint device, the channel is added seperately, and when \
bitblt, we<br> > > > pass a seperate pointer to the alpha channel, that can \
be null or not<br> > > > (ie like the mask)<br>
> > > * smaller solution: make it possible to create composite op that \
work<br> > > > across color spaces<br>
> ><br>
> > There is a third solution<br>
> > * detect in KoColorSpace::bitBlt that the destination color space is \
the<br> > > same<br>
> > as the source color space without alpha, and add an alpha channel to \
the<br> > > data<br>
> > and then discard it, but that is not going to be performant.<br>
><br>
> I thought about that too, but then you pratically need another paint device<br>
> in grayscale colorspace than is used for a tempory bitBlt.<br>
> Of course that means two bitBlt.<br>
<br>
</div></div>Well no. you can do it directly in \
KoColorSpace::bitBlt.<br></blockquote></div><br>Try that but I didn't get it to \
work, see attachment. Is that what you suggested?<br>
--0016364ee1be4a95a904a8342ffd--
["gray2.diff" (text/x-patch)]
diff --git a/krita/image/kis_painter.cc b/krita/image/kis_painter.cc
index 220a174..aaa55e1 100644
--- a/krita/image/kis_painter.cc
+++ b/krita/image/kis_painter.cc
@@ -850,7 +850,7 @@ void KisPainter::bltFixed(qint32 dstX, qint32 dstY,
if (d->device.isNull()) return;
// TODO: What purpose has checking if src and this have the same pixel size?
- Q_ASSERT(srcDev->pixelSize() == d->pixelSize);
+ //Q_ASSERT(srcDev->pixelSize() == d->pixelSize);
QRect srcRect = QRect(srcX, srcY, srcWidth, srcHeight);
diff --git a/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.cpp \
b/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.cpp \
index 5630b05..937bf62 100644
--- a/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.cpp
+++ b/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.cpp
@@ -66,3 +66,31 @@ quint8 KoGrayColorSpace::opacityU8(const quint8* U8_pixel) const
{
return *U8_pixel;
}
+
+void KoGrayColorSpace::bitBlt(const KoColorSpace* srcSpace, const \
KoCompositeOp::ParameterInfo& params, const KoCompositeOp* op) const +{
+ quint32 conversionBufferStride = params.dstRowStride * srcSpace->pixelSize();
+ QVector<quint8> * conversionCache = threadLocalConversionCache(params.rows * \
conversionBufferStride); + quint8* conversionData = conversionCache->data();
+
+ for (qint32 row = 0; row < params.rows; row++) {
+ this->convertPixelsTo(params.dstRowStart + row * params.dstRowStride,
+ conversionData + row * conversionBufferStride,
+ srcSpace, params.cols);
+ }
+
+ srcSpace->bitBlt(conversionData, conversionBufferStride, srcSpace, \
params.srcRowStart, params.srcRowStride, + params.maskRowStart, \
params.maskRowStride, params.opacity, params.rows, params.cols, op->id(), \
params.channelFlags); +
+ for (qint32 row = 0; row < params.rows; row++) {
+ srcSpace->convertPixelsTo(conversionData + row * conversionBufferStride,
+ params.dstRowStart + row * params.dstRowStride * \
pixelSize(), + this, params.cols);
+ }
+}
+
diff --git a/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.h \
b/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.h \
index ab6afee..9c40c23 100644
--- a/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.h
+++ b/plugins/colorengines/lcms/colorspaces/gray_u8_no_alpha/GrayU8NoAlphaColorSpace.h
@@ -43,6 +43,8 @@ public:
virtual quint8 opacityU8(const quint8* U8_pixel) const;
+ virtual void bitBlt(const KoColorSpace* srcSpace, const \
KoCompositeOp::ParameterInfo& params, const KoCompositeOp* op) const; +
virtual KoColorSpace* clone() const;
virtual void colorToXML(const quint8* pixel, QDomDocument& doc, QDomElement& \
colorElt) const;
virtual void colorFromXML(quint8* pixel, const QDomElement& elt) const;
_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic