Пример #1
0
        protected override void DrawBoxContent(DrawBoard canvas, Rectangle updateArea)
        {
            //TODO: review here,
            //
            if (_myHtmlCont == null)
            {
                return;
            }

            _myHtmlCont.CheckDocUpdate();

            DrawBoard cpuDrawBoard = null;

            if (PreferSoftwareRenderer &&
                canvas.IsGpuDrawBoard &&
                (cpuDrawBoard = canvas.GetCpuBlitDrawBoard()) != null)
            {
                //TODO: review this again ***
                //test built-in 'shared' software rendering surface

                cpuDrawBoard.Clear(Color.White);
                PaintVisitor painter = PaintVisitorStock.GetSharedPaintVisitor(_myHtmlCont, cpuDrawBoard);

                painter.SetViewportSize(this.Width, this.Height);

#if DEBUG
                painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height);
#endif


                _myHtmlCont.PerformPaint(painter);
                PaintVisitorStock.ReleaseSharedPaintVisitor(painter);

                //then copy from cpu to gpu
                canvas.BlitFrom(cpuDrawBoard, X, Y, this.Width, this.Height, 0, 0);
            }
            else
            {
                PaintVisitor painter = PaintVisitorStock.GetSharedPaintVisitor(_myHtmlCont, canvas);
                painter.SetViewportSize(this.Width, this.Height);
#if DEBUG
                painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height);
#endif

                _myHtmlCont.PerformPaint(painter);
                PaintVisitorStock.ReleaseSharedPaintVisitor(painter);
            }
        }
Пример #2
0
        protected override void RenderClientContent(DrawBoard d, UpdateArea updateArea)
        {
            //canvas here should be glcanvas

            //TODO:
            //1. if the content of glBmp is not changed
            //we should not render again
            //2. if we only update some part of texture
            //may can transfer only that part to the glBmp
            //-------------------------------------------------------------------------

            if (GlobalRootGraphic.CurrentRootGfx.HasRenderTreeInvalidateAccumRect)
            {
                //update cpu surface part***
                DrawBoard board = _glesUIElem.GetDrawBoard();
                if (board != null)
                {
                    board.SetClipRect(updateArea.CurrentRect);
                    board.Clear(Color.White); //clear background, clear with white solid


#if DEBUG
                    //_ui.dbugSaveAggBmp("a001.png");
#endif
                }

                if (_glesUIElem.HasCpuBlitUpdateSurfaceDel)
                {
                    _glesUIElem.UpdateCpuBlitSurface(updateArea.CurrentRect);
                }
            }

            _glBmp.UpdateTexture(updateArea.CurrentRect);

            //-------------------------------------------------------------------------
            d.DrawImage(_glBmp, 0, 0);


            //test print text from our GLTextPrinter
            //_glPainter.FillColor = PixelFarm.Drawing.Color.Black;
            //_glPainter.DrawString("Hello2", 0, 400);
            //-------------------------------------------------------------------------
        }
Пример #3
0
        protected override void DrawBoxContent(DrawBoard d, Rectangle updateArea)
        {
            //canvas here should be glcanvas

            //TODO:
            //1. if the content of glBmp is not changed
            //we should not render again
            //2. if we only update some part of texture
            //may can transfer only that part to the glBmp
            //-------------------------------------------------------------------------
            if (_rootgfx.HasRenderTreeInvalidateAccumRect)
            {
                //update cpu surface part***
                DrawBoard board = _ui.GetDrawBoard();
                if (board != null)
                {
                    board.SetClipRect(updateArea);
                    board.Clear(Color.White); //clear background
                    //board.SetClipRect(new Rectangle(0, 0, 1200, 1200));
                    DrawDefaultLayer(board, ref updateArea);
#if DEBUG
                    //_ui.dbugSaveAggBmp("c:\\WImageTest\\a001.png");
#endif
                }

                if (_ui.HasCpuBlitUpdateSurfaceDel)
                {
                    _ui.UpdateCpuBlitSurface(updateArea);
                }
            }

            _glBmp.UpdateTexture(updateArea);

            //-------------------------------------------------------------------------
            d.DrawImage(_glBmp, 0, 0);
            //_pcx.DrawImage(_glBmp, 0, 0);

            //test print text from our GLTextPrinter
            //_glPainter.FillColor = PixelFarm.Drawing.Color.Black;
            //_glPainter.DrawString("Hello2", 0, 400);
            //-------------------------------------------------------------------------
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
 //------
 public void Clear(Color c)
 {
     _drawBoard.Clear(c);
 }
Пример #6
0
        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);
            }
        }
Пример #7
0
        //----------
        //for test
#if DEBUG
        //void dbugTest01()
        //{
        //    //canvas.Orientation = CanvasOrientation.LeftTop;
        //    canvas.ClearSurface(Color.White);

        //    canvas.FillRectangle(Color.Red, 50, 50, 100, 100);

        //    dbugGLOffsetCanvasOrigin(50, 50);
        //    //simulate draw content
        //    canvas.FillRectangle(Color.Gray, 10, 10, 80, 80);
        //    dbugGLOffsetCanvasOrigin(-50, -50);
        //}
        //void dbugGLSetCanvasOrigin(int x, int y)
        //{
        //    canvas.SetCanvasOrigin(x, y);
        //    //int properW = Math.Min(canvas.Width, canvas.Height);
        //    ////int max = 600;
        //    ////init
        //    ////---------------------------------
        //    ////-1 temp fix split scanline in some screen
        //    ////OpenTK.Graphics.OpenGL.GL.Viewport(x, y, properW, properW - 1);
        //    //////---------------------------------
        //    //OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
        //    //OpenTK.Graphics.OpenGL.GL.LoadIdentity();
        //    //OpenTK.Graphics.OpenGL.GL.Ortho(0, properW, properW, 0, 0.0, 100);

        //    ////switch (this.orientation)
        //    ////{
        //    ////    case Drawing.CanvasOrientation.LeftTop:
        //    ////        {
        //    ////            OpenTK.Graphics.OpenGL.GL.Ortho(0, properW, properW, 0, 0.0, 100);
        //    ////        } break;
        //    ////    default:
        //    ////        {
        //    ////            OpenTK.Graphics.OpenGL.GL.Ortho(0, properW, 0, properW, 0.0, 100);
        //    ////        } break;
        //    ////}
        //    //OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);
        //    //OpenTK.Graphics.OpenGL.GL.LoadIdentity();
        //    //OpenTK.Graphics.OpenGL.GL.Translate(x, y, 0);
        //}
        //void dbugGLOffsetCanvasOrigin(int dx, int dy)
        //{
        //    dbugGLSetCanvasOrigin(canvas.CanvasOriginX + dx, canvas.CanvasOriginY + dy);
        //}
#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
            if (_canvas == null)
            {
                return;
            }
            _canvas.Clear(Color.White);
            ////test draw rect
            //canvas.StrokeColor = PixelFarm.Drawing.Color.Blue;
            //canvas.DrawRectangle(Color.Blue, 20, 20, 200, 200);
            ////------------------------



            if (this.IsClosed)
            {
                return;
            }
            //------------------------------------

            _rootGraphics.PrepareRender();
            //---------------
            _rootGraphics.IsInRenderPhase = true;
#if DEBUG
            _rootGraphics.dbug_rootDrawingMsg.Clear();
            _rootGraphics.dbug_drawLevel = 0;
#endif
            UpdateAllArea(_canvas, _topWindowBox);

            _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
        }
Пример #8
0
        //-------

        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
        }