public DrawImage ( Image img, |
||
img | Image | |
r | ||
return | void |
void DrawWithTempTransitionImage(PaintVisitor p, RectangleF r) { Image img; if ((img = (Image)_tmpTransitionImgBinder.LocalImage) != null) //assign and test { if (this.VisualWidth != 0) { //TODO: review here if (_imgRun.ImageRectangle == Rectangle.Empty) { p.DrawImage(img, r.Left, r.Top, this.VisualWidth, this.VisualHeight); } else { p.DrawImage(img, _imgRun.ImageRectangle); } } else { if (_imgRun.ImageRectangle == Rectangle.Empty) { p.DrawImage(img, r.Left, r.Top, img.Width, img.Height); } else { p.DrawImage(img, _imgRun.ImageRectangle); } } } }
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); } }
public override void Paint(PaintVisitor p, RectangleF rect) { PaintBackground(p, rect, true, true); if (this.HasSomeVisibleBorder) { p.PaintBorders(this, rect, true, true); } //--------------------------------------------------------- RectangleF r = _imgRun.Rectangle; r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; r.Y += ActualBorderTopWidth + ActualPaddingTop; r.X = (float)Math.Floor(r.X); r.Y = (float)Math.Floor(r.Y); bool tryLoadOnce = false; EVAL_STATE: switch (_imgRun.ImageBinder.State) { case ImageBinderState.Unload: { //async request image if (!tryLoadOnce) { p.RequestImageAsync(_imgRun.ImageBinder, this._imgRun, this); //retry again tryLoadOnce = true; goto EVAL_STATE; } } break; case ImageBinderState.Loading: { //RenderUtils.DrawImageLoadingIcon(g, r); } break; case ImageBinderState.Loaded: { Image img; if ((img = (Image)_imgRun.ImageBinder.Image) != null) { if (_imgRun.ImageRectangle == Rectangle.Empty) { p.DrawImage(img, r.Left, r.Top, img.Width, img.Height); } else { p.DrawImage(img, _imgRun.ImageRectangle); } } else { RenderUtils.DrawImageLoadingIcon(p.InnerCanvas, r); if (r.Width > 19 && r.Height > 19) { p.DrawRectangle(Color.LightGray, r.X, r.Y, r.Width, r.Height); } } } break; case ImageBinderState.NoImage: { } break; case ImageBinderState.Error: { RenderUtils.DrawImageErrorIcon(p.InnerCanvas, r); } break; } //#if DEBUG // p.FillRectangle(Color.Red, rect.X, rect.Y, rect.Width, rect.Height); //#endif }
public override void Paint(PaintVisitor p, RectangleF rect) { PaintBackground(p, rect, true, true); if (this.HasSomeVisibleBorder) { p.PaintBorders(this, rect, true, true); } //--------------------------------------------------------- RectangleF r = _imgRun.Rectangle; r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; r.Y += ActualBorderTopWidth + ActualPaddingTop; r.X = (float)Math.Floor(r.X); r.Y = (float)Math.Floor(r.Y); bool tryLoadOnce = false; EVAL_STATE: switch (_imgRun.ImageBinder.State) { case ImageBinderState.Unload: { //async request image if (!tryLoadOnce) { p.RequestImageAsync(_imgRun.ImageBinder, this._imgRun, this); //retry again tryLoadOnce = true; goto EVAL_STATE; } } break; case ImageBinderState.Loading: { //RenderUtils.DrawImageLoadingIcon(g, r); } break; case ImageBinderState.Loaded: { Image img; if ((img = (Image)_imgRun.ImageBinder.Image) != null) { if (_imgRun.ImageRectangle == Rectangle.Empty) { p.DrawImage(img, r.Left, r.Top, img.Width, img.Height); } else { p.DrawImage(img, _imgRun.ImageRectangle); } } else { RenderUtils.DrawImageLoadingIcon(p.InnerCanvas, r); if (r.Width > 19 && r.Height > 19) { p.DrawRectangle(Color.LightGray, r.X, r.Y, r.Width, r.Height); } } } break; case ImageBinderState.NoImage: { } break; case ImageBinderState.Error: { RenderUtils.DrawImageErrorIcon(p.InnerCanvas, r); } break; } //#if DEBUG // p.FillRectangle(Color.Red, rect.X, rect.Y, rect.Width, rect.Height); //#endif }
public override void Paint(PaintVisitor p, RectangleF rect) { Color bgColorHint = p.CurrentSolidBackgroundColorHint;//save PaintBackground(p, rect, true, true); if (this.HasSomeVisibleBorder) { p.PaintBorders(this, rect, true, true); } //--------------------------------------------------------- RectangleF r = _imgRun.Rectangle; r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; r.Location = new PointF((float)Math.Floor(r.Left), (float)Math.Floor(r.Top + ActualBorderTopWidth + ActualPaddingTop)); bool tryLoadOnce = false; EVAL_STATE: switch (_imgRun.ImageBinder.State) { case BinderState.Unload: { if (_tmpTransitionImgBinder != null) { DrawWithTempTransitionImage(p, rect); } //async request image if (!tryLoadOnce) { p.RequestImageAsync(_imgRun.ImageBinder, _imgRun, this); //retry again tryLoadOnce = true; goto EVAL_STATE; } } break; case BinderState.Loading: { if (_tmpTransitionImgBinder != null) { DrawWithTempTransitionImage(p, rect); } //RenderUtils.DrawImageLoadingIcon(g, r); } break; case BinderState.Loaded: { if (_tmpTransitionImgBinder != null) { //*** clear tmp transition img after new image is loaded _tmpTransitionImgBinder = null; } Image img; if ((img = (Image)_imgRun.ImageBinder.LocalImage) != null) //assign and test { if (this.VisualWidth != 0) { //TODO: review here if (_imgRun.ImageRectangle == Rectangle.Empty) { p.DrawImage(img, r.Left, r.Top, this.VisualWidth, this.VisualHeight); } else { p.DrawImage(img, _imgRun.ImageRectangle); } } else { if (_imgRun.ImageRectangle == Rectangle.Empty) { p.DrawImage(img, r.Left, r.Top, img.Width, img.Height); } else { p.DrawImage(img, _imgRun.ImageRectangle); } } } else { RenderUtils.DrawImageLoadingIcon(p.InnerDrawBoard, r); if (r.Width > 19 && r.Height > 19) { p.DrawRectangle(KnownColors.LightGray, r.Left, r.Top, r.Width, r.Height); } } } break; case BinderState.Blank: { } break; case BinderState.Error: { RenderUtils.DrawImageErrorIcon(p.InnerDrawBoard, r); } break; } //#if DEBUG // p.FillRectangle(Color.Red, rect.X, rect.Y, rect.Width, rect.Height); //#endif p.CurrentSolidBackgroundColorHint = bgColorHint;//restore }