/// <summary> /// Recursive rendering logic. /// </summary> /// <param name="skin">Skin to use.</param> /// <param name="clipRect">Clipping rectangle.</param> protected virtual void RenderRecursive(Skin.SkinBase skin, Rectangle clipRect) { Renderer.RendererBase render = skin.Renderer; Point oldRenderOffset = render.RenderOffset; render.AddRenderOffset(clipRect); RenderUnder(skin); Rectangle oldRegion = render.ClipRegion; if (ShouldClip) { render.AddClipRegion(RenderBounds); if (!render.ClipRegionVisible) { render.RenderOffset = oldRenderOffset; render.ClipRegion = oldRegion; return; } render.StartClip(); } //Render myself first Render(skin); if (m_Children.Count > 0) { //Now render my kids foreach (ControlBase child in m_Children) { if (child.IsHidden) { continue; } child.DoRender(skin); } } render.ClipRegion = oldRegion; render.StartClip(); RenderOver(skin); RenderFocus(skin); render.RenderOffset = oldRenderOffset; }
/// <summary> /// Renders the control to a cache using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> /// <param name="master">Root parent.</param> protected virtual void DoCacheRender(Skin.SkinBase skin, ControlBase master) { Renderer.RendererBase render = skin.Renderer; Renderer.ICacheToTexture cache = render.CTT; if (cache == null) { return; } Point oldRenderOffset = render.RenderOffset; Rectangle oldRegion = render.ClipRegion; if (this != master) { render.AddRenderOffset(Bounds); render.AddClipRegion(Bounds); } else { render.RenderOffset = Point.Empty; render.ClipRegion = new Rectangle(0, 0, Width, Height); } if (m_CacheTextureDirty && render.ClipRegionVisible) { render.StartClip(); if (ShouldCacheToTexture) { cache.SetupCacheTexture(this); } //Render myself first //var old = render.ClipRegion; //render.ClipRegion = Bounds; //var old = render.RenderOffset; //render.RenderOffset = new Point(Bounds.X, Bounds.Y); Render(skin); //render.RenderOffset = old; //render.ClipRegion = old; if (m_Children.Count > 0) { //Now render my kids foreach (ControlBase child in m_Children) { if (child.IsHidden) { continue; } child.DoCacheRender(skin, master); } } if (ShouldCacheToTexture) { cache.FinishCacheTexture(this); m_CacheTextureDirty = false; } } render.ClipRegion = oldRegion; render.StartClip(); render.RenderOffset = oldRenderOffset; if (ShouldCacheToTexture) { cache.DrawCachedControlTexture(this); } }