public override void CopyOutputPixelBuffer(int x, int y, int w, int h, IntPtr outputBuffer)
        {
            //1. This version support on Win32 only
            //2. this is an example, to draw directly into the memDC, not need to create control
            //3. x and y set to 0
            //4. w and h must be the width and height of the viewport


            unsafe
            {
                //create new memdc
                Win32.NativeWin32MemoryDc memDc = new Win32.NativeWin32MemoryDc(w, h);
                memDc.PatBlt(Win32.NativeWin32MemoryDc.PatBltColor.White);
                //TODO: check if we need to set init font/brush/pen for the new DC or not
                gdiPlusViewport.FullMode = true;
                //pain to the destination dc
                this.gdiPlusViewport.PaintMe(memDc.DC);
                IntPtr outputBits = memDc.PPVBits;
                //Win32.MyWin32.memcpy((byte*)outputBuffer, (byte*)memDc.PPVBits, w * 4 * h);
                memDc.CopyPixelBitsToOutput((byte *)outputBuffer);
                memDc.Dispose();
            }
        }
        public void PaintMe(IntPtr hdc)
        {
            if (this.IsClosed)
            {
                return;
            }
            this.rootGraphics.PrepareRender();
            //---------------
            this.rootGraphics.IsInRenderPhase = true;
#if DEBUG
            this.rootGraphics.dbug_rootDrawingMsg.Clear();
            this.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);
            //}
            //-----------------------------------------------------------------------------
            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
        }