yes! ich habs kaputt gemacht! (doesn't compile anymore, doesn't work anymore,
[enigma2.git] / lib / gdi / region.h
diff --git a/lib/gdi/region.h b/lib/gdi/region.h
new file mode 100644 (file)
index 0000000..a1dbe91
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef __lib_gdi_region_h
+#define __lib_gdi_region_h
+
+#include <lib/base/object.h>
+#include <vector>
+
+class gRegion: public virtual iObject
+{
+DECLARE_REF;
+private:
+       inline void FindBand(
+                       std::vector<eRect>::const_iterator r,
+                       std::vector<eRect>::const_iterator &rBandEnd,
+                       std::vector<eRect>::const_iterator rEnd,
+                       int &ry1)
+       {
+               ry1 = r->y1;
+               rBandEnd = r+1;
+               while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1))
+                       rBandEnd++;
+       }
+       
+       inline void AppendRegions(
+               std::vector<eRect>::const_iterator r,
+               std::vector<eRect>::const_iterator rEnd)
+       {
+               rects.insert(rects.end(), r, rEnd);
+       }
+
+       int do_coalesce(int prevStart, unsigned int curStart);
+       inline void coalesce(int &prevBand, unsigned int curBand)
+       {
+               if (curBand - prevBand == rects.size() - curBand) {
+                       prevBand = do_coalesce(prevBand, curBand);
+               } else {
+                       prevBand = curBand;
+               }
+       };
+       void appendNonO(std::vector<eRect>::const_iterator r, 
+                       std::vector<eRect>::const_iterator rEnd, int y1, int y2);
+
+       void intersectO(
+                       std::vector<eRect>::const_iterator r1,
+                       std::vector<eRect>::const_iterator r1End,
+                       std::vector<eRect>::const_iterator r2,
+                       std::vector<eRect>::const_iterator r2End,
+                       int y1, int y2,
+                       int &overlap);
+       void subtractO(
+                       std::vector<eRect>::const_iterator r1,
+                       std::vector<eRect>::const_iterator r1End,
+                       std::vector<eRect>::const_iterator r2,
+                       std::vector<eRect>::const_iterator r2End,
+                       int y1, int y2,
+                       int &overlap);
+       void mergeO(
+                       std::vector<eRect>::const_iterator r1,
+                       std::vector<eRect>::const_iterator r1End,
+                       std::vector<eRect>::const_iterator r2,
+                       std::vector<eRect>::const_iterator r2End,
+                       int y1, int y2,
+                       int &overlap);
+       void regionOp(const gRegion &reg1, const gRegion &reg2, int opcode, int &overlap);
+public:
+       std::vector<eRect> rects;
+       eRect extends;
+       
+       enum
+       {
+                       // note: bit 0 and bit 1 have special meanings
+               OP_INTERSECT = 0,
+               OP_SUBTRACT  = 1,
+               OP_UNION     = 3
+       };
+       
+       gRegion(const eRect &rect);
+       gRegion();
+       virtual ~gRegion();
+
+       void intersect(const gRegion &r1, const gRegion &r2);
+       void subtract(const gRegion &r1, const gRegion &r2);
+       void merge(const gRegion &r1, const gRegion &r2);
+};
+
+#endif