protected void GenerateBuckets() { this.buckets = new LayerGridBucket[this._bucketCount]; for (int x = 0; x < this.size.x; x += Settings.BUCKET_SIZE) { for (int y = 0; y < this.size.y; y += Settings.BUCKET_SIZE) { RectI bucketRect = new RectI(new Vector2Int(x, y), Settings.BUCKET_SIZE, Settings.BUCKET_SIZE); bucketRect.Clip(this.rect); int bucketID = (int)(x/Settings.BUCKET_SIZE) + (int)(y/Settings.BUCKET_SIZE) * this._bucketSizeX; this.buckets[bucketID] = new LayerGridBucket(bucketID, bucketRect, this.layer, this.renderer); } } }
//-------------------------------------------------------------------- //public IPixelFormat ren() { return m_ren; } //-------------------------------------------------------------------- public bool SetClippingBox(int x1, int y1, int x2, int y2) { RectI cb = new RectI(x1, y1, x2, y2); cb.Normalize(); if (cb.Clip(new RectI(0, 0, (int)Width - 1, (int)Height - 1))) { m_clip_box = cb; return(true); } m_clip_box.x1 = 1; m_clip_box.y1 = 1; m_clip_box.x2 = 0; m_clip_box.y2 = 0; return(false); }
///<summary> ///</summary> ///<param name="pixf"></param> ///<param name="x1"></param> ///<param name="y1"></param> ///<param name="x2"></param> ///<param name="y2"></param> ///<returns></returns> public bool Attach(IPixelFormat pixf, int x1, int y1, int x2, int y2) { RectI r = new RectI(x1, y1, x2, y2); if (r.Clip(new RectI(0, 0, (int)pixf.Width - 1, (int)pixf.Height - 1))) { int stride = pixf.Stride; unsafe { _rasterBuffer.Attach(pixf.PixelPointer(r.x1, stride < 0 ? r.y2 : r.y1), (uint)(r.x2 - r.x1) + 1, (uint)(r.y2 - r.y1) + 1, stride, 3); } return(true); } return(false); }
//-------------------------------------------------------------------- //public IPixelFormat ren() { return m_ren; } //-------------------------------------------------------------------- public bool SetClippingBox(int x1, int y1, int x2, int y2) { RectI cb = new RectI(x1, y1, x2, y2); cb.Normalize(); if (cb.Clip(new RectI(0, 0, (int)Width - 1, (int)Height - 1))) { m_clip_box = cb; return true; } m_clip_box.x1 = 1; m_clip_box.y1 = 1; m_clip_box.x2 = 0; m_clip_box.y2 = 0; return false; }
///<summary> ///</summary> ///<param name="pixf"></param> ///<param name="x1"></param> ///<param name="y1"></param> ///<param name="x2"></param> ///<param name="y2"></param> ///<returns></returns> public bool Attach(IPixelFormat pixf, int x1, int y1, int x2, int y2) { RectI r = new RectI(x1, y1, x2, y2); if (r.Clip(new RectI(0, 0, (int)pixf.Width - 1, (int)pixf.Height - 1))) { int stride = pixf.Stride; unsafe { _rasterBuffer.Attach(pixf.PixelPointer(r.x1, stride < 0 ? r.y2 : r.y1), (uint)(r.x2 - r.x1) + 1, (uint)(r.y2 - r.y1) + 1, stride, 3); } return true; } return false; }