protected abstract void RenderAntiAliased(ISurface <TPixel> dst, PointInt32 renderOffset);
protected abstract void RenderNormal(ISurface <TPixel> dst, PointInt32 renderOffset);
protected override void OnRender(ISurface <ColorBgra> dstContent, ISurface <ColorAlpha8> dstMask, PointInt32 renderOffset) { base.ThrowIfCancellationRequested(); this.RenderContent(dstContent, renderOffset); base.ThrowIfCancellationRequested(); this.RenderMask(dstMask, renderOffset); base.ThrowIfCancellationRequested(); }
private unsafe void RenderContent(ISurface <ColorBgra> dstContent, PointInt32 renderOffset) { int width = dstContent.Width; int height = dstContent.Height; int stride = dstContent.Stride; int num4 = stride - (width * 4); RectInt32 num5 = RectInt32.Intersect(this.srcCoverageBounds, new RectInt32(0, 0, this.contentWidth, this.contentHeight)); int left = num5.Left; int top = num5.Top; int right = num5.Right; int bottom = num5.Bottom; long num10 = (this.srcOffsetOriginXFp + (renderOffset.X * this.srcOffsetDxDxFp)) + (renderOffset.Y * this.srcOffsetDxDyFp); long num11 = (this.srcOffsetOriginYFp + (renderOffset.X * this.srcOffsetDyDxFp)) + (renderOffset.Y * this.srcOffsetDyDyFp); ColorBgra *bgraPtr = this.contentScan0; int contentStride = this.contentStride; ColorBgra *bgraPtr2 = (ColorBgra *)dstContent.Scan0; ColorBgra *bgraPtr3 = bgraPtr2 + width; for (int i = 0; i < height; i++) { uint num16; int num17; base.ThrowIfCancellationRequested(); long num14 = num10; long num15 = num11; ColorBgra *bgraPtr4 = bgraPtr3 - width; int num18 = (int)((long)((bgraPtr3 - bgraPtr4) / sizeof(ColorBgra))); int num19 = (int)(num14 >> 0x18); int num20 = (int)(num15 >> 0x18); int num21 = ((num19 >= left) && (num19 < right)) ? 1 : 0; int num22 = ((num20 >= top) && (num20 < bottom)) ? 1 : 0; int num23 = ((num19 >= (left - 1)) && (num19 < (right - 1))) ? 1 : 0; int num24 = ((num20 >= (top - 1)) && (num20 < (bottom - 1))) ? 1 : 0; long num25 = num14 + (this.srcOffsetDxDxFp * num18); long num26 = num15 + (this.srcOffsetDyDxFp * num18); int num27 = (int)(num25 >> 0x18); int num28 = (int)(num26 >> 0x18); int num29 = ((num27 >= left) && (num27 < right)) ? 1 : 0; int num30 = ((num28 >= top) && (num28 < bottom)) ? 1 : 0; int num31 = ((num27 >= (left - 1)) && (num27 < (right - 1))) ? 1 : 0; int num32 = ((num28 >= (top - 1)) && (num28 < (bottom - 1))) ? 1 : 0; if ((((((((num21 + num22) + num23) + num24) + num29) + num30) + num31) + num32) == 8) { num17 = num18; } else { num17 = 0; } while ((bgraPtr4 < bgraPtr3) && (num17 > 0)) { num16 = 0; int num33 = (int)(num14 >> 0x18); int num34 = (int)(num15 >> 0x18); int num35 = 0x100 - (((int)(num14 & 0xffffffL)) >> 0x10); int num36 = 0x100 - (((int)(num15 & 0xffffffL)) >> 0x10); int num37 = (num35 * num36) >> 8; int num38 = ((0x100 - num35) * num36) >> 8; int num39 = (num35 * (0x100 - num36)) >> 8; int num40 = ((0x100 - num35) * (0x100 - num36)) >> 8; int num41 = num37; int num42 = num38; int num43 = num39; int num44 = num40; ushort d = (ushort)(((num41 + num42) + num43) + num44); long num46 = (num34 * contentStride) + (num33 * 4); ColorBgra32 bgra = *((ColorBgra32 *)(bgraPtr + num46)); ColorBgra32 bgra2 = *((ColorBgra32 *)(bgraPtr + (num46 + 4L))); ColorBgra32 bgra3 = *((ColorBgra32 *)(bgraPtr + (num46 + contentStride))); ColorBgra32 bgra4 = *((ColorBgra32 *)(bgraPtr + ((num46 + contentStride) + 4L))); int num47 = bgra.A * num41; int num48 = bgra2.A * num42; int num49 = bgra3.A * num43; int num50 = bgra4.A * num44; ushort n = (ushort)(((num47 + num48) + num49) + num50); if (n != 0) { uint num52 = UInt32Util.FastDivideByUInt16(n, d); uint num53 = UInt32Util.FastDivideByUInt16((uint)((((num47 * bgra.B) + (num48 * bgra2.B)) + (num49 * bgra3.B)) + (num50 * bgra4.B)), n); uint num54 = UInt32Util.FastDivideByUInt16((uint)((((num47 * bgra.G) + (num48 * bgra2.G)) + (num49 * bgra3.G)) + (num50 * bgra4.G)), n); uint num55 = UInt32Util.FastDivideByUInt16((uint)((((num47 * bgra.R) + (num48 * bgra2.R)) + (num49 * bgra3.R)) + (num50 * bgra4.R)), n); num16 = ColorBgra.BgraToUInt32((byte)num53, (byte)num54, (byte)num55, (byte)num52); } bgraPtr4->Bgra = num16; num14 += this.srcOffsetDxDxFp; num15 += this.srcOffsetDyDxFp; bgraPtr4++; num17--; } while (bgraPtr4 < bgraPtr3) { num16 = 0; int num56 = (int)(num14 >> 0x18); int num57 = (int)(num15 >> 0x18); int num58 = ((num56 >= left) && (num56 < right)) ? 1 : 0; int num59 = ((num57 >= top) && (num57 < bottom)) ? 1 : 0; int num60 = ((num56 >= (left - 1)) && (num56 < (right - 1))) ? 1 : 0; int num61 = ((num57 >= (top - 1)) && (num57 < (bottom - 1))) ? 1 : 0; int num62 = num59 * num58; int num63 = num59 * num60; int num64 = num61 * num58; int num65 = num61 * num60; if ((((num62 + num63) + num64) + num65) != 0) { int num67 = 0x100 - (((int)(num14 & 0xffffffL)) >> 0x10); int num68 = 0x100 - (((int)(num15 & 0xffffffL)) >> 0x10); int num69 = (num67 * num68) >> 8; int num70 = ((0x100 - num67) * num68) >> 8; int num71 = (num67 * (0x100 - num68)) >> 8; int num72 = ((0x100 - num67) * (0x100 - num68)) >> 8; int num73 = num62 * num69; int num74 = num63 * num70; int num75 = num64 * num71; int num76 = num65 * num72; ushort num77 = (ushort)(((num73 + num74) + num75) + num76); long num78 = (num57 * contentStride) + (num56 * 4); ColorBgra32 bgra5 = *((ColorBgra32 *)(bgraPtr + (num78 * num62))); ColorBgra32 bgra6 = *((ColorBgra32 *)(bgraPtr + ((num78 + 4L) * num63))); ColorBgra32 bgra7 = *((ColorBgra32 *)(bgraPtr + ((num78 + contentStride) * num64))); ColorBgra32 bgra8 = *((ColorBgra32 *)(bgraPtr + (((num78 + contentStride) + 4L) * num65))); int num79 = bgra5.A * num73; int num80 = bgra6.A * num74; int num81 = bgra7.A * num75; int num82 = bgra8.A * num76; ushort num83 = (ushort)(((num79 + num80) + num81) + num82); if (num83 != 0) { uint num84 = UInt32Util.FastDivideByUInt16(num83, num77); uint num85 = UInt32Util.FastDivideByUInt16((uint)((((num79 * bgra5.B) + (num80 * bgra6.B)) + (num81 * bgra7.B)) + (num82 * bgra8.B)), num83); uint num86 = UInt32Util.FastDivideByUInt16((uint)((((num79 * bgra5.G) + (num80 * bgra6.G)) + (num81 * bgra7.G)) + (num82 * bgra8.G)), num83); uint num87 = UInt32Util.FastDivideByUInt16((uint)((((num79 * bgra5.R) + (num80 * bgra6.R)) + (num81 * bgra7.R)) + (num82 * bgra8.R)), num83); num16 = ColorBgra.BgraToUInt32((byte)num85, (byte)num86, (byte)num87, (byte)num84); } } bgraPtr4->Bgra = num16; num14 += this.srcOffsetDxDxFp; num15 += this.srcOffsetDyDxFp; bgraPtr4++; } num10 += this.srcOffsetDxDyFp; num11 += this.srcOffsetDyDyFp; bgraPtr3 += stride; } }
public static PointInt32 OffsetCopy(this PointInt32 pt, int dx, int dy) => new PointInt32(pt.X + dx, pt.Y + dy);
private void RenderMask(ISurface <ColorAlpha8> dstMask, PointInt32 renderOffset) { int width = dstMask.Width; int height = dstMask.Height; bool flag = false; SizeInt32 size = new SizeInt32(width, height); RectInt32 rectangle = new RectInt32(renderOffset, size); if (!flag && this.matrix.HasInverse) { Matrix3x2Double inverse = this.matrix.Inverse; PointDouble pt = inverse.Transform(rectangle.TopLeft); PointDouble num7 = inverse.Transform(rectangle.TopRight); PointDouble num8 = inverse.Transform(rectangle.BottomLeft); PointDouble num9 = inverse.Transform(rectangle.BottomRight); RectDouble srcCoverageBounds = this.srcCoverageBounds; if ((srcCoverageBounds.Contains(pt) && srcCoverageBounds.Contains(num7)) && (srcCoverageBounds.Contains(num8) && srcCoverageBounds.Contains(num9))) { dstMask.Clear(ColorAlpha8.Opaque); flag = true; } } if (!flag) { GeometryRelation relation; IDirect2DFactory perThread = Direct2DFactory.PerThread; using (IRectangleGeometry geometry = perThread.CreateRectangleGeometry(rectangle)) { base.ThrowIfCancellationRequested(); using (IRectangleGeometry geometry2 = perThread.CreateRectangleGeometry(this.srcCoverageBounds)) { base.ThrowIfCancellationRequested(); relation = geometry.CompareWithGeometry(geometry2, new Matrix3x2Float?((Matrix3x2Float)this.matrix), null); base.ThrowIfCancellationRequested(); } } switch (relation) { case GeometryRelation.IsContained: dstMask.Clear(ColorAlpha8.Opaque); flag = true; break; case GeometryRelation.Disjoint: dstMask.Clear(ColorAlpha8.Transparent); flag = true; break; } } if (!flag) { using (IDrawingContext context = DrawingContext.FromSurface(dstMask, FactorySource.PerThread)) { base.ThrowIfCancellationRequested(); context.Clear(null); context.AntialiasMode = AntialiasMode.PerPrimitive; using (context.UseTranslateTransform((float)-renderOffset.X, (float)-renderOffset.Y, MatrixMultiplyOrder.Prepend)) { using (context.UseTransformMultiply((Matrix3x2Float)this.matrix, MatrixMultiplyOrder.Prepend)) { context.FillRectangle(this.srcCoverageBounds, whiteBrush); } } } } }
public unsafe void Render(ISurfaceAllocator <ColorAlpha8> allocator, int dstWidth, int dstHeight, PointInt32 renderOffset, ref ISurface <ColorAlpha8> dst, out int?fill255Count) { int stride; if ((allocator == null) && (dst == null)) { throw new ArgumentException(); } if (dst != null) { dst.Clear(ColorAlpha8.Transparent); } int x = renderOffset.X; int y = renderOffset.Y; int right = renderOffset.X + dstWidth; int bottom = renderOffset.Y + dstHeight; RectInt32 a = RectInt32.FromEdges(x, y, right, bottom); int count = this.scans.Count; int scansStartIndex = this.GetScansStartIndex(y, bottom); Label_006C: stride = -1; byte *numPtr = null; if (dst != null) { stride = dst.Stride; numPtr = (byte *)dst.Scan0; } int num9 = 0; for (int i = scansStartIndex; i < count; i++) { RectInt32 scanAt = this.GetScanAt(i); if (scanAt.Y >= bottom) { break; } int left = Math.Max(x, scanAt.X); int top = Math.Max(y, scanAt.Y); int num14 = Math.Min(right, scanAt.X + scanAt.Width); int num15 = Math.Min(bottom, scanAt.Y + scanAt.Height); RectInt32 b = RectInt32.FromEdges(left, top, num14, num15); if (RectInt32.Intersect(a, b).HasPositiveArea) { uint num18 = (uint)(num14 - left); int num19 = left - renderOffset.X; int num20 = num14 - renderOffset.X; if (dst == null) { num9 += (int)((num15 - top) * num18); } else { byte *prgBuffer = numPtr + ((byte *)(((top - renderOffset.Y) * stride) + num19)); for (int j = top; j < num15; j++) { Memory.FillMemory(prgBuffer, 0xff, (ulong)num18); prgBuffer += stride; } } } } if (((dst != null) || (num9 == 0)) || (num9 == (dstWidth * dstHeight))) { if (dst == null) { fill255Count = new int?(num9); } else { fill255Count = 0; } } else { dst = allocator.Allocate(dstWidth, dstHeight, AllocationOptions.Default); goto Label_006C; } }
public OffsetRenderer(IRenderer <TPixel> source, PointInt32 offset) { Validate.IsNotNull <IRenderer <TPixel> >(source, "source"); this.source = source; this.offset = offset; }
public void Render(ISurface <ColorAlpha8> dst, PointInt32 renderOffset) { int?nullable; this.Render(null, dst.Width, dst.Height, renderOffset, ref dst, out nullable); }
internal MaskFromScansRenderer(TList sortedScans, RectInt32 bounds) { this.origin = bounds.Location; this.size = bounds.Size; this.scans = sortedScans; }
public static RectInt32 Offset(RectInt32 rect, PointInt32 offset) => Offset(rect, offset.x, offset.y);
public static RectInt32 FromCorners(PointInt32 corner1, PointInt32 corner2) => FromEdges(corner1.x, corner1.y, corner2.x, corner2.y);
protected override unsafe void OnRender(ISurface <ColorBgra> dstContent, ISurface <ColorAlpha8> dstMask, PointInt32 renderOffset) { base.ThrowIfCancellationRequested(); int width = dstContent.Width; int height = dstContent.Height; int stride = dstContent.Stride; int num4 = stride - (width * 4); int num6 = dstMask.Stride - (width * ColorAlpha8.SizeOf); long num7 = (this.srcOffsetOriginXFp + (renderOffset.X * this.srcOffsetDxDxFp)) + (renderOffset.Y * this.srcOffsetDxDyFp); long num8 = (this.srcOffsetOriginYFp + (renderOffset.X * this.srcOffsetDyDxFp)) + (renderOffset.Y * this.srcOffsetDyDyFp); uint *numPtr = (uint *)(((void *)dstContent.Scan0) + (width * 4)); byte *numPtr2 = (byte *)dstMask.Scan0; for (int i = 0; i < height; i++) { int num12; base.ThrowIfCancellationRequested(); long num10 = num7; long num11 = num8; uint *numPtr3 = numPtr - width; int num13 = (int)(num10 >> 0x18); int num14 = (int)(num11 >> 0x18); if (((num13 < 0) || (num14 < 0)) || ((num13 >= this.contentWidth) || (num14 >= this.contentHeight))) { num12 = 0; } else { int num15 = (int)((num10 + (this.srcOffsetDxDxFp * width)) >> 0x18); int num16 = (int)((num11 + (this.srcOffsetDyDxFp * width)) >> 0x18); if (((num15 < 0) || (num16 < 0)) || ((num15 >= this.contentWidth) || (num16 >= this.contentHeight))) { num12 = 0; } else { num12 = width; } } while ((numPtr3 < numPtr) && (num12 > 0)) { int num17 = (int)(num10 >> 0x18); int num18 = (int)(num11 >> 0x18); numPtr3[0] = *((uint *)((this.contentScan0 + (num18 * this.contentStride)) + (num17 * 4))); numPtr2[0] = 0xff; num10 += this.srcOffsetDxDxFp; num11 += this.srcOffsetDyDxFp; numPtr2++; numPtr3++; num12--; } while (numPtr3 < numPtr) { int num19 = (int)(num10 >> 0x18); int num20 = (int)(num11 >> 0x18); if (((num19 < 0) || (num20 < 0)) || ((num19 >= this.contentWidth) || (num20 >= this.contentHeight))) { numPtr3[0] = 0; numPtr2[0] = 0; } else { numPtr3[0] = *((uint *)((this.contentScan0 + (num20 * this.contentStride)) + (num19 * 4))); numPtr2[0] = 0xff; } num10 += this.srcOffsetDxDxFp; num11 += this.srcOffsetDyDxFp; numPtr2++; numPtr3++; } num7 += this.srcOffsetDxDyFp; num8 += this.srcOffsetDyDyFp; numPtr += stride; numPtr2 += num6; } }