private void FillNode(TreemapNode n, RectD nBounds, RectD vBounds, double pxX, double pxY, int depth) { if (Overlaps(nBounds, vBounds)) { GLTexture tex = n.Texture; if (tex != null && tex.Valid) { OpenGL.glEnd(); OpenGL.glEnable(OpenGL.GL_TEXTURE_2D); OpenGL.glDisable(OpenGL.GL_BLEND); tex.Bind(); OpenGL.glColor3f(1.0f, 1.0f, 1.0f); OpenGL.glBegin(OpenGL.GL_QUADS); } else { RGB col = new RGB(new HSV(depth * (1.0f / 6.0f), 0.5f - depth / 256.0f, 1)); OpenGL.glColor3f(col.r, col.g, col.b); } { OpenGL.glTexCoord2f(0.0f, 0.0f); OpenGL.glVertex2f((float)nBounds.Left, (float)nBounds.Top); OpenGL.glTexCoord2f(0.0f, 1.0f); OpenGL.glVertex2f((float)nBounds.Left, (float)nBounds.Bottom); OpenGL.glTexCoord2f(1.0f, 1.0f); OpenGL.glVertex2f((float)nBounds.Right, (float)nBounds.Bottom); OpenGL.glTexCoord2f(1.0f, 0.0f); OpenGL.glVertex2f((float)nBounds.Right, (float)nBounds.Top); } if (tex != null && tex.Valid) { OpenGL.glEnd(); tex.Unbind(); OpenGL.glDisable(OpenGL.GL_TEXTURE_2D); OpenGL.glEnable(OpenGL.GL_BLEND); OpenGL.glBegin(OpenGL.GL_QUADS); } RectD conBounds = new RectD( nBounds.Left + nBounds.Width * 0.01f, nBounds.Top + nBounds.Height * 0.03f, nBounds.Right - nBounds.Width * 0.01f, nBounds.Bottom - nBounds.Height * 0.01f); for (int i = 0, c = n.Children.Count; i != c; ++i) { TreemapNode cn = n.Children[i]; RectD cBounds = new RectD( cn.Bounds.Left * conBounds.Width + conBounds.Left, cn.Bounds.Top * conBounds.Height + conBounds.Top, cn.Bounds.Right * conBounds.Width + conBounds.Left, cn.Bounds.Bottom * conBounds.Height + conBounds.Top); if (cBounds.Width > pxX * 5) { cBounds.Left += pxX * m_pxNodeMargin; cBounds.Right -= pxX * m_pxNodeMargin; } if (cBounds.Height > pxY * 5) { cBounds.Top += pxY * m_pxNodeMargin; cBounds.Bottom -= pxY * m_pxNodeMargin; } FillNode(cn, cBounds, vBounds, pxX, pxY, depth + 1); } } }
protected override void glDraw() { while (true) { KeyValuePair <Image, GLTexture> req; lock (m_thumbnailComplete) { if (m_thumbnailComplete.Count == 0) { break; } req = m_thumbnailComplete[0]; m_thumbnailComplete.RemoveAt(0); } if (req.Key != null) { req.Value.Update((Bitmap)req.Key); req.Key.Dispose(); } } if (m_logViews.Count > 0) { LogView lv = m_logViews[0]; LogData ld = lv.m_logData; if (m_remakeTree) { VirtualBounds = new RectD(0, 0, 1, 1); View = new RectD(0, 0, 1, 1); TreemapNode rootNode = CreateTree(); FrameRecord fr = m_frameRecord; if (fr != null) { lock (ld) { List <RDIElementValue <ProfilerRDI> > children = new List <RDIElementValue <ProfilerRDI> >(); float totalSize = 0; foreach (RDIElementValue <ProfilerRDI> prdiEv in m_logControl.m_prdiTree.GetValueEnumerator(fr)) { float size = prdiEv.m_value; if (size == 0.0f) { continue; } children.Add(prdiEv); totalSize += size; } rootNode.Name = String.Format("{0} MB", totalSize); children.Sort((a, b) => - a.m_value.CompareTo(b.m_value)); foreach (RDIElementValue <ProfilerRDI> ev in children) { float size = ev.m_value; string path = ev.m_rdi.Path; int sep = path.LastIndexOf('/'); GLTexture tex = null; if (path.StartsWith("/TexStrm/")) { string texturepath = path.Substring("/TexStrm/".Length).Replace(".dds", ".tif"); tex = RequestThumbnail(texturepath, -size); } TreemapNode child = CreateChild(rootNode); child.Size = size / totalSize; child.Name = (sep >= 0) ? path.Substring(sep + 1) : path; child.Tag = ev; child.Texture = tex; } } } VirtualBounds = new RectD(0, 0, 1, 1); View = new RectD(0, 0, 1, 1); m_remakeTree = false; } } base.glDraw(); }