Ejemplo n.º 1
0
        public void TestBitMask()
        {
            mask.Set(0, true);
            mask.Set(1, true);
            mask.Set(2, false);
            mask.Set(3, true);

            Assert.AreEqual(true, mask.Get(0));
            Assert.AreEqual(true, mask.Get(1));
            Assert.AreEqual(false, mask.Get(2));
            Assert.AreEqual(true, mask.Get(3));

            BitMask mask2 = new BitMask();

            mask2.Set(0, true);
            mask2.Set(1, true);
            mask2.Set(2, false);
            mask2.Set(3, true);

            Assert.AreEqual(true, mask2 == mask);
            mask2.Set(3, false);
            Assert.AreEqual(false, mask2 == mask);
        }
Ejemplo n.º 2
0
		protected unsafe override void OnFillRegionComputed (Document document, BitMask stencil)
		{
			var surf = document.Layers.ToolLayer.Surface;

			using (var g = new Context (surf)) {
				g.Operator = Operator.Source;
				g.SetSource (document.Layers.CurrentUserLayer.Surface);
				g.Paint ();
			}

			var hist = new SimpleHistoryItem (Icon, Name);
			hist.TakeSnapshotOfLayer (document.Layers.CurrentUserLayer);

			var color = fill_color.ToColorBgra ().ToPremultipliedAlpha ();
			var dstPtr = (ColorBgra*) surf.DataPtr;
			var width = surf.Width;

			surf.Flush ();

			// Color in any pixel that the stencil says we need to fill
			Parallel.For (0, stencil.Height, y => {
				var stencil_width = stencil.Width;

				for (var x = 0; x < stencil_width; ++x) {
					if (stencil.Get (x, y))
						surf.SetColorBgraUnchecked (dstPtr, width, color, x, y);
				}
			});

			surf.MarkDirty ();

			// Transfer the temp layer to the real one,
			// respecting any selection area
			using (var g = document.CreateClippedContext ()) {
				g.Operator = Operator.Source;
				g.SetSource (surf);
				g.Paint ();
			}

			document.Layers.ToolLayer.Clear ();
			document.History.PushNewItem (hist);
			document.Workspace.Invalidate ();
		}
Ejemplo n.º 3
0
 public bool IsSet(EntityMemberInfo member)
 {
     return(Bits.Get(member.ValueIndex));
 }