protected override void RenderClientContent(DrawBoard d, UpdateArea updateArea) { //TODO: review here, if (_myHtmlVisualRoot == null) { return; } bool useBackbuffer = d.IsGpuDrawBoard; //useBackbuffer = false; //... TODO: review here, check doc update here? _myHtmlVisualRoot.CheckDocUpdate(); if (useBackbuffer) { PaintVisitor painter = PaintVisitorStock.GetSharedPaintVisitor(_myHtmlVisualRoot, d); if (_builtInBackBuffer == null) { _builtInBackBuffer = painter.CreateOffscreenDrawBoard(this.Width, this.Height); } #if DEBUG painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height); #endif if (!_builtInBackBuffer.IsValid) { //painter.FillRectangle(Color.Red, 0, 0, 100, 100);//debug //painter.DrawText(i.ToString().ToCharArray(), 0, 1, new PointF(0, 0), new SizeF(100, 100)); //debug float backupViewportW = painter.ViewportWidth; //backup float backupViewportH = painter.ViewportHeight; //backup painter.EnterNewDrawboardBuffer(_builtInBackBuffer); //*** switch to builtInBackbuffer painter.SetViewportSize(this.Width, this.Height); if (!_hasAccumRect) { _invalidateRect = new Rectangle(0, 0, Width, Height); } #if DEBUG //System.Diagnostics.Debug.WriteLine("inv_rect:" + _invalidateRect + "," + painter.ToString()); #endif if (painter.PushLocalClipArea( _invalidateRect.Left, _invalidateRect.Top, _invalidateRect.Width, _invalidateRect.Height)) { #if DEBUG //for debug , test clear with random color //another useful technique to see latest clear area frame-by-frame => use random color //painter.Clear(ColorEx.dbugGetRandomColor()); painter.Clear(Color.White); #else painter.Clear(Color.White); #endif _myHtmlVisualRoot.PerformPaint(painter); painter.PopLocalClipArea(); } // _builtInBackBuffer.IsValid = true; _hasAccumRect = false; painter.ExitCurrentDrawboardBuffer(); //*** switch back painter.SetViewportSize(backupViewportW, backupViewportH); //restore viewport size } painter.DrawImage(_builtInBackBuffer.GetImage(), 0, 0, this.Width, this.Height); PaintVisitorStock.ReleaseSharedPaintVisitor(painter); } #if DEBUG else if (dbugPreferSoftwareRenderer && d.IsGpuDrawBoard) { //TODO: review this again *** //test built-in 'shared' software rendering surface DrawBoard cpuDrawBoard = null; if ((cpuDrawBoard = d.GetCpuBlitDrawBoard()) != null) { cpuDrawBoard.Clear(Color.White); PaintVisitor painter = PaintVisitorStock.GetSharedPaintVisitor(_myHtmlVisualRoot, cpuDrawBoard); painter.SetViewportSize(this.Width, this.Height); #if DEBUG painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height); #endif _myHtmlVisualRoot.PerformPaint(painter); PaintVisitorStock.ReleaseSharedPaintVisitor(painter); //then copy from cpu to gpu d.BlitFrom(cpuDrawBoard, X, Y, this.Width, this.Height, 0, 0); } } #endif else { PaintVisitor painter = PaintVisitorStock.GetSharedPaintVisitor(_myHtmlVisualRoot, d); painter.SetViewportSize(this.Width, this.Height); #if DEBUG //System.Diagnostics.Debug.WriteLine(">> 500x500"); painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height); //for debug , test clear with random color //another useful technique to see latest clear area frame-by-frame => use random color //painter.Clear(Color.FromArgb(255, dbugRandom.Next(0, 255), dbugRandom.Next(0, 255), dbugRandom.Next(0, 255))); #endif #if DEBUG //System.Diagnostics.Debug.WriteLine("inv_rect:" + _invalidateRect + "," + painter.ToString()); #endif //painter.SetClipRect(new Rectangle(0, 0, 200, 200)); _myHtmlVisualRoot.PerformPaint(painter); #if DEBUG //System.Diagnostics.Debug.WriteLine("<< 500x500"); //painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height); #endif PaintVisitorStock.ReleaseSharedPaintVisitor(painter); } }
protected override void RenderClientContent(DrawBoard d, UpdateArea updateArea) { if (ContentBox == null) { return; } // if (EnableDoubleBuffer) { var painter = new PixelFarm.Drawing.Internal.MicroPainter(d); if (_builtInBackBuffer == null) { _builtInBackBuffer = painter.CreateOffscreenDrawBoard(this.Width, this.Height); } if (!_builtInBackBuffer.IsValid) { #if DEBUG System.Diagnostics.Debug.WriteLine("double_buffer_update:" + this.dbug_obj_id + "," + _invalidateRect.ToString()); #endif float backupViewportW = painter.ViewportWidth; //backup float backupViewportH = painter.ViewportHeight; //backup painter.AttachTo(_builtInBackBuffer); //*** switch to builtInBackbuffer painter.SetViewportSize(this.Width, this.Height); if (!_hasAccumRect) { _invalidateRect = new Rectangle(0, 0, Width, Height); } #if DEBUG if (_invalidateRect.Width == 15) { } #endif // if (painter.PushLocalClipArea( // _invalidateRect.Left, _invalidateRect.Top, // _invalidateRect.Width, _invalidateRect.Height)) // { //#if DEBUG // //for debug , test clear with random color // //another useful technique to see latest clear area frame-by-frame => use random color // //painter.Clear(Color.FromArgb(255, dbugRandom.Next(0, 255), dbugRandom.Next(0, 255), dbugRandom.Next(0, 255))); // canvas.Clear(Color.White); //#else // canvas.Clear(Color.White); //#endif // base.RenderBoxContent(canvas, updateArea); // } //if (painter.PushLocalClipArea( // _invalidateRect.Left, _invalidateRect.Top, // _invalidateRect.Width, _invalidateRect.Height)) //{ #if DEBUG //for debug , test clear with random color //another useful technique to see latest clear area frame-by-frame => use random color //painter.Clear(Color.FromArgb(255, dbugRandom.Next(0, 255), dbugRandom.Next(0, 255), dbugRandom.Next(0, 255))); d.Clear(Color.White); #else d.Clear(Color.White); #endif //Rectangle updateArea2 = new Rectangle(0, 0, _builtInBackBuffer.Width, _builtInBackBuffer.Height); Rectangle backup2 = updateArea.CurrentRect; updateArea.CurrentRect = new Rectangle(0, 0, _builtInBackBuffer.Width, _builtInBackBuffer.Height); RenderElement.Render(ContentBox, d, updateArea); updateArea.CurrentRect = backup2; //} //painter.PopLocalClipArea(); // _builtInBackBuffer.IsValid = true; _hasAccumRect = false; painter.AttachToNormalBuffer(); //*** switch back painter.SetViewportSize(backupViewportW, backupViewportH); //restore viewport size } #if DEBUG else { System.Diagnostics.Debug.WriteLine("double_buffer_update:" + dbug_obj_id + " use cache"); } #endif painter.DrawImage(_builtInBackBuffer.GetImage(), 0, 0, this.Width, this.Height); } else { RenderElement.Render(ContentBox, d, updateArea); } }