public void PaintMe(Canvas mycanvas) { if (this.IsClosed) { return; } //------------------------------------ this.rootGraphics.PrepareRender(); //--------------- this.rootGraphics.IsInRenderPhase = true; #if DEBUG this.rootGraphics.dbug_rootDrawingMsg.Clear(); this.rootGraphics.dbug_drawLevel = 0; #endif mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top); Rectangle rect = mycanvas.Rect; this.rootGraphics.TopWindowRenderBox.DrawToThisCanvas(mycanvas, rect); #if DEBUG this.rootGraphics.TopWindowRenderBox.dbugShowRenderPart(mycanvas, rect); #endif mycanvas.IsContentReady = true; mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top); //if (this.FullMode) //{ // quadPages.RenderToOutputWindowFullMode(rootGraphics.TopWindowRenderBox, hdc, // this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight); //} //else //{ // //temp to full mode // //quadPages.RenderToOutputWindowFullMode(rootGraphics.TopWindowRenderBox, hdc, this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight); // quadPages.RenderToOutputWindowPartialMode(rootGraphics.TopWindowRenderBox, hdc, // this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight); //} this.rootGraphics.IsInRenderPhase = false; #if DEBUG RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot; if (visualroot.dbug_RecordDrawingChain) { List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs; outputMsgs.Clear(); outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]")); visualroot.dbug_DumpRootDrawingMsg(outputMsgs); dbugOutputWindow.dbug_InvokeVisualRootDrawMsg(); debug_render_to_output_count++; } if (dbugHelper01.dbugVE_HighlightMe != null) { dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect()); } #endif }
//------- public void PaintMe() { if (isClosed) { return; } //--------------------------------------------- canvas.Orientation = CanvasOrientation.LeftTop; //Test01(); //return; //Test01(); //return; //canvas.ClearSurface(Color.White); //canvas.FillRectangle(Color.Red, 20, 20, 200, 400); // return; //---------------------------------- //gl paint here canvas.ClearSurface(Color.White); ////test draw rect //canvas.StrokeColor = PixelFarm.Drawing.Color.Blue; //canvas.DrawRectangle(Color.Blue, 20, 20, 200, 200); ////------------------------ if (this.IsClosed) { return; } //------------------------------------ this.rootGraphics.PrepareRender(); //--------------- this.rootGraphics.IsInRenderPhase = true; #if DEBUG this.rootGraphics.dbug_rootDrawingMsg.Clear(); this.rootGraphics.dbug_drawLevel = 0; #endif UpdateAllArea(this.canvas, this.topWindowBox); this.rootGraphics.IsInRenderPhase = false; #if DEBUG RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot; if (visualroot.dbug_RecordDrawingChain) { List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs; outputMsgs.Clear(); outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]")); visualroot.dbug_DumpRootDrawingMsg(outputMsgs); dbugOutputWindow.dbug_InvokeVisualRootDrawMsg(); debug_render_to_output_count++; } if (dbugHelper01.dbugVE_HighlightMe != null) { dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect()); } #endif }
public void PaintMe(IntPtr hdc) { //paint the content to target hdc if (this.IsClosed) { return; } //------------------------------------ _rootGraphics.PrepareRender(); //--------------- _rootGraphics.IsInRenderPhase = true; #if DEBUG _rootGraphics.dbug_rootDrawingMsg.Clear(); _rootGraphics.dbug_drawLevel = 0; #endif if (this.FullMode) { RenderToOutputWindowFullMode( _rootGraphics.TopWindowRenderBox, hdc, this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight); } else { //temp to full mode //quadPages.RenderToOutputWindowFullMode(rootGraphics.TopWindowRenderBox, hdc, this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight); RenderToOutputWindowPartialMode( _rootGraphics.TopWindowRenderBox, hdc, this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight); } _rootGraphics.IsInRenderPhase = false; #if DEBUG RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot; if (visualroot.dbug_RecordDrawingChain) { List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs; outputMsgs.Clear(); outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]")); visualroot.dbug_DumpRootDrawingMsg(outputMsgs); dbugOutputWindow.dbug_InvokeVisualRootDrawMsg(); debug_render_to_output_count++; } if (dbugHelper01.dbugVE_HighlightMe != null) { dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect()); } #endif }
public void PaintMe(IntPtr hdc) { if (this.IsClosed) { return; } _rootGraphics.PrepareRender(); //--------------- _rootGraphics.IsInRenderPhase = true; #if DEBUG _rootGraphics.dbug_rootDrawingMsg.Clear(); _rootGraphics.dbug_drawLevel = 0; #endif //1. clear sk surface mySkCanvas.Clear(PixelFarm.Drawing.Color.White); //2. render to the surface UpdateAllArea(mySkCanvas, _rootGraphics.TopWindowRenderBox); //3. copy bitmap buffer from the surface and render to final hdc //----------------------------------------------- //TODO: review performance here //we should copy from unmanaged (skia bitmap) //and write to unmanaged (hdc'bitmap) SkiaSharp.SKBitmap backBmp = mySkCanvas.BackBmp; backBmp.LockPixels(); IntPtr h = backBmp.GetPixels(); int w1 = backBmp.Width; int h1 = backBmp.Height; int stride = backBmp.RowBytes; //PixelFarm.Agg.AggMemMx.memcpy() //System.Runtime.InteropServices.Marshal.Copy( // h, tmpBuffer, 0, tmpBuffer.Length // ); //copy skia pixels to our dc unsafe { //Win32.MyWin32.memcpy((byte*)memdc.PPVBits, (byte*)h, internalSizeW * 4 * internalSizwH); memdc.CopyPixelBitsToOutput((byte *)h); } backBmp.UnlockPixels(); //bitblt to target memdc.BitBltTo(hdc); //var bmpdata = tmpBmp.LockBits(new System.Drawing.Rectangle(0, 0, w1, h1), // System.Drawing.Imaging.ImageLockMode.ReadWrite, // System.Drawing.Imaging.PixelFormat.Format32bppArgb); //System.Runtime.InteropServices.Marshal.Copy(tmpBuffer, 0, bmpdata.Scan0, tmpBuffer.Length); //tmpBmp.UnlockBits(bmpdata); //using (System.Drawing.Graphics g2 = System.Drawing.Graphics.FromHdc(hdc)) //{ // g2.DrawImage(tmpBmp, 0, 0); //} //----------------------------------------------------------------------------- _rootGraphics.IsInRenderPhase = false; #if DEBUG RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot; if (visualroot.dbug_RecordDrawingChain) { List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs; outputMsgs.Clear(); outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]")); visualroot.dbug_DumpRootDrawingMsg(outputMsgs); dbugOutputWindow.dbug_InvokeVisualRootDrawMsg(); debug_render_to_output_count++; } if (dbugHelper01.dbugVE_HighlightMe != null) { dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect()); } #endif }
//------- public void PaintMe() { if (_isClosed || _drawboard == null) { return; } RootGraphic backup = GlobalRootGraphic.CurrentRootGfx; GlobalRootGraphic.CurrentRootGfx = _rootgfx; _rootgfx.PrepareRender(); //--------------- _rootgfx.BeginRenderPhase(); #if DEBUG _rootgfx.dbug_rootDrawingMsg.Clear(); _rootgfx.dbug_drawLevel = 0; #endif if (_rootgfx.HasAccumInvalidateRect) { //evaluate _gfxUpdatePlan.SetUpdatePlanForFlushAccum(); int j = _gfxUpdatePlan.UpdateListCount; if (j > 0) { //special mode UpdateArea u = GetFreeUpdateArea(); for (int i = 0; i < j; ++i) { _gfxUpdatePlan.SetCurrentUpdate(i); u.CurrentRect = _gfxUpdatePlan.AccumUpdateArea; _drawboard.SetClipRect(u.CurrentRect); //** UpdateInvalidateArea(_drawboard, _topWindowBox, u); _gfxUpdatePlan.ClearCurrentUpdate(); #if DEBUG if (RenderElement.WaitForStartRenderElement) { //should not occur throw new System.NotSupportedException(); } #endif } _gfxUpdatePlan.ResetUpdatePlan(); ReleaseUpdateArea(u); } else { //default mode _drawboard.SetClipRect(_rootgfx.AccumInvalidateRect); UpdateArea u = GetFreeUpdateArea(); //TODO: review clear bg again _drawboard.Clear(Color.White); u.CurrentRect = _rootgfx.AccumInvalidateRect; UpdateInvalidateArea(_drawboard, _topWindowBox, u); _gfxUpdatePlan.ResetUpdatePlan(); ReleaseUpdateArea(u); } //----------- } _rootgfx.EndRenderPhase(); GlobalRootGraphic.CurrentRootGfx = backup; #if DEBUG RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot; if (visualroot.dbug_RecordDrawingChain) { List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs; outputMsgs.Clear(); outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]")); visualroot.dbug_DumpRootDrawingMsg(outputMsgs); dbugOutputWindow.dbug_InvokeVisualRootDrawMsg(); debug_render_to_output_count++; } if (dbugHelper01.dbugVE_HighlightMe != null) { dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect()); } #endif }