summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2012-09-13 17:56:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 06:07:15 +0200
commitae0ddb8c729c105a5b4f32a4f6765af8fe546333 (patch)
tree90ce3d69dde5a6efc03eba9eaaf47234905d5853 /src/gui/painting
parent12e5464fa322735560613a43aa9b589fb69b79c8 (diff)
Implement the missing raster operations that were in Qt 3
Although not widely used, the raster operations from Qt 3 were useful and some of them were already implemented, this brings the rest of them back for those who need them. Change-Id: Id538611eaaba9be3d39bf2dd33b6c532f5d4aba8 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qdrawhelper.cpp117
-rw-r--r--src/gui/painting/qdrawhelper_iwmmxt.cpp14
-rw-r--r--src/gui/painting/qdrawhelper_p.h11
-rw-r--r--src/gui/painting/qdrawhelper_sse2.cpp14
-rw-r--r--src/gui/painting/qdrawhelper_x86_p.h2
-rw-r--r--src/gui/painting/qpainter.cpp17
-rw-r--r--src/gui/painting/qpainter.h7
7 files changed, 173 insertions, 9 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index ce1567953c..0f8fde1d9c 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -3653,6 +3653,107 @@ void QT_FASTCALL rasterop_SourceAndNotDestination(uint *Q_DECL_RESTRICT dest,
}
}
+void QT_FASTCALL rasterop_NotSourceOrDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (~(*src) | *dest) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_NotSourceOrDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ color = ~color | 0xff000000;
+ while (length--)
+ *dest++ |= color;
+}
+
+void QT_FASTCALL rasterop_SourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (*src | ~(*dest)) | 0xff000000;
+ ++dest; ++src;
+ }
+}
+
+void QT_FASTCALL rasterop_solid_SourceOrNotDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(const_alpha);
+ while (length--) {
+ *dest = (color | ~(*dest)) | 0xff000000;
+ ++dest;
+ }
+}
+
+void QT_FASTCALL rasterop_ClearDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(src);
+ comp_func_solid_SourceOver (dest, length, 0xff000000, const_alpha);
+}
+
+void QT_FASTCALL rasterop_solid_ClearDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(color);
+ comp_func_solid_SourceOver (dest, length, 0xff000000, const_alpha);
+}
+
+void QT_FASTCALL rasterop_SetDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(src);
+ comp_func_solid_SourceOver (dest, length, 0xffffffff, const_alpha);
+}
+
+void QT_FASTCALL rasterop_solid_SetDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(color);
+ comp_func_solid_SourceOver (dest, length, 0xffffffff, const_alpha);
+}
+
+void QT_FASTCALL rasterop_NotDestination(uint *Q_DECL_RESTRICT dest,
+ const uint *Q_DECL_RESTRICT src,
+ int length,
+ uint const_alpha)
+{
+ Q_UNUSED(src);
+ rasterop_solid_SourceXorDestination (dest, length, 0x00ffffff, const_alpha);
+}
+
+void QT_FASTCALL rasterop_solid_NotDestination(uint *Q_DECL_RESTRICT dest,
+ int length,
+ uint color,
+ uint const_alpha)
+{
+ Q_UNUSED(color);
+ rasterop_solid_SourceXorDestination (dest, length, 0x00ffffff, const_alpha);
+}
+
static CompositionFunctionSolid functionForModeSolid_C[] = {
comp_func_solid_SourceOver,
comp_func_solid_DestinationOver,
@@ -3686,7 +3787,13 @@ static CompositionFunctionSolid functionForModeSolid_C[] = {
rasterop_solid_NotSourceXorDestination,
rasterop_solid_NotSource,
rasterop_solid_NotSourceAndDestination,
- rasterop_solid_SourceAndNotDestination
+ rasterop_solid_SourceAndNotDestination,
+ rasterop_solid_SourceAndNotDestination,
+ rasterop_solid_NotSourceOrDestination,
+ rasterop_solid_SourceOrNotDestination,
+ rasterop_solid_ClearDestination,
+ rasterop_solid_SetDestination,
+ rasterop_solid_NotDestination
};
static const CompositionFunctionSolid *functionForModeSolid = functionForModeSolid_C;
@@ -3724,7 +3831,13 @@ static CompositionFunction functionForMode_C[] = {
rasterop_NotSourceXorDestination,
rasterop_NotSource,
rasterop_NotSourceAndDestination,
- rasterop_SourceAndNotDestination
+ rasterop_SourceAndNotDestination,
+ rasterop_SourceAndNotDestination,
+ rasterop_NotSourceOrDestination,
+ rasterop_SourceOrNotDestination,
+ rasterop_ClearDestination,
+ rasterop_SetDestination,
+ rasterop_NotDestination
};
static const CompositionFunction *functionForMode = functionForMode_C;
diff --git a/src/gui/painting/qdrawhelper_iwmmxt.cpp b/src/gui/painting/qdrawhelper_iwmmxt.cpp
index c9590103a3..b3f7a45ecd 100644
--- a/src/gui/painting/qdrawhelper_iwmmxt.cpp
+++ b/src/gui/painting/qdrawhelper_iwmmxt.cpp
@@ -98,7 +98,12 @@ CompositionFunctionSolid qt_functionForModeSolid_IWMMXT[numCompositionFunctions]
rasterop_solid_NotSourceXorDestination<QIWMMXTIntrinsics>,
rasterop_solid_NotSource<QIWMMXTIntrinsics>,
rasterop_solid_NotSourceAndDestination<QIWMMXTIntrinsics>,
- rasterop_solid_SourceAndNotDestination<QIWMMXTIntrinsics>
+ rasterop_solid_SourceAndNotDestination<QIWMMXTIntrinsics>,
+ rasterop_solid_NotSourceOrDestination<QIWMMXTIntrinsics>,
+ rasterop_solid_SourceOrNotDestination<QIWMMXTIntrinsics>,
+ rasterop_solid_ClearDestination<QIWMMXTIntrinsics>,
+ rasterop_solid_SetDestination<QIWMMXTIntrinsics>,
+ rasterop_solid_NotDestination<QIWMMXTIntrinsics>
};
CompositionFunction qt_functionForMode_IWMMXT[] = {
@@ -134,7 +139,12 @@ CompositionFunction qt_functionForMode_IWMMXT[] = {
rasterop_NotSourceXorDestination,
rasterop_NotSource,
rasterop_NotSourceAndDestination,
- rasterop_SourceAndNotDestination
+ rasterop_SourceAndNotDestination,
+ rasterop_NotSourceOrDestination,
+ rasterop_SourceOrNotDestination,
+ rasterop_ClearDestination,
+ rasterop_SetDestination,
+ rasterop_NotDestination
};
void qt_blend_color_argb_iwmmxt(int count, const QSpan *spans, void *userData)
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 3ff75a32cc..439882a3cf 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -926,7 +926,11 @@ void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, const uint *src, i
void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, int length, uint const_alpha);
void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
-
+void QT_FASTCALL rasterop_NotSourceOrDestination(uint *dest, const uint *src, int length, uint const_alpha);
+void QT_FASTCALL rasterop_SourceOrNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
+void QT_FASTCALL rasterop_ClearDestination(uint *dest, const uint *src, int length, uint const_alpha);
+void QT_FASTCALL rasterop_SetDestination(uint *dest, const uint *src, int length, uint const_alpha);
+void QT_FASTCALL rasterop_NotDestination(uint *dest, const uint *src, int length, uint const_alpha);
// prototypes of all the solid composition functions
void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha);
void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha);
@@ -961,6 +965,11 @@ void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, int length,
void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, uint color, uint const_alpha);
void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
+void QT_FASTCALL rasterop_solid_NotSourceOrDestination(uint *dest, int length, uint color, uint const_alpha);
+void QT_FASTCALL rasterop_solid_SourceOrNotDestination(uint *dest, int length, uint color, uint const_alpha);
+void QT_FASTCALL rasterop_solid_ClearDestination(uint *dest, int length, uint color, uint const_alpha);
+void QT_FASTCALL rasterop_solid_SetDestination(uint *dest, int length, uint color, uint const_alpha);
+void QT_FASTCALL rasterop_solid_NotDestination(uint *dest, int length, uint color, uint const_alpha);
struct QPixelLayout;
diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp
index e7672644da..e72b9ba968 100644
--- a/src/gui/painting/qdrawhelper_sse2.cpp
+++ b/src/gui/painting/qdrawhelper_sse2.cpp
@@ -347,7 +347,12 @@ CompositionFunctionSolid qt_functionForModeSolid_SSE2[numCompositionFunctions] =
rasterop_solid_NotSourceXorDestination,
rasterop_solid_NotSource,
rasterop_solid_NotSourceAndDestination,
- rasterop_solid_SourceAndNotDestination
+ rasterop_solid_SourceAndNotDestination,
+ rasterop_solid_NotSourceOrDestination,
+ rasterop_solid_SourceOrNotDestination,
+ rasterop_solid_ClearDestination,
+ rasterop_solid_SetDestination,
+ rasterop_solid_NotDestination
};
CompositionFunction qt_functionForMode_SSE2[numCompositionFunctions] = {
@@ -383,7 +388,12 @@ CompositionFunction qt_functionForMode_SSE2[numCompositionFunctions] = {
rasterop_NotSourceXorDestination,
rasterop_NotSource,
rasterop_NotSourceAndDestination,
- rasterop_SourceAndNotDestination
+ rasterop_SourceAndNotDestination,
+ rasterop_NotSourceOrDestination,
+ rasterop_SourceOrNotDestination,
+ rasterop_ClearDestination,
+ rasterop_SetDestination,
+ rasterop_NotDestination
};
#endif
diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h
index d31f87b46d..ee47c41076 100644
--- a/src/gui/painting/qdrawhelper_x86_p.h
+++ b/src/gui/painting/qdrawhelper_x86_p.h
@@ -105,7 +105,7 @@ extern CompositionFunction qt_functionForMode_IWMMXT[];
extern CompositionFunctionSolid qt_functionForModeSolid_IWMMXT[];
#endif
-static const int numCompositionFunctions = 33;
+static const int numCompositionFunctions = 38;
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 380a697ac3..02555b6fb6 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2320,6 +2320,23 @@ void QPainter::setBrushOrigin(const QPointF &p)
where the source is AND'ed with the inverted destination pixels
(src AND (NOT dst)).
+ \value RasterOp_NotSourceOrDestination Does a bitwise operation
+ where the source is inverted and then OR'ed with the destination
+ ((NOT src) OR dst).
+
+ \value RasterOp_ClearDestination The pixels in the destination are
+ cleared (set to 0) independent of the source.
+
+ \value RasterOp_SetDestination The pixels in the destination are
+ set (set to 1) independent of the source.
+
+ \value RasterOp_NotDestination Does a bitwise operation
+ where the destination pixels are inverted (NOT dst).
+
+ \value RasterOp_SourceOrNotDestination Does a bitwise operation
+ where the source is OR'ed with the inverted destination pixels
+ (src OR (NOT dst)).
+
\sa compositionMode(), setCompositionMode(), {QPainter#Composition
Modes}{Composition Modes}, {Image Composition Example}
*/
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 47ffc8d778..c6c0e39ba0 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -171,7 +171,12 @@ public:
RasterOp_NotSourceXorDestination,
RasterOp_NotSource,
RasterOp_NotSourceAndDestination,
- RasterOp_SourceAndNotDestination
+ RasterOp_SourceAndNotDestination,
+ RasterOp_NotSourceOrDestination,
+ RasterOp_SourceOrNotDestination,
+ RasterOp_ClearDestination,
+ RasterOp_SetDestination,
+ RasterOp_NotDestination
};
void setCompositionMode(CompositionMode mode);
CompositionMode compositionMode() const;