利用者:Jwilkins/GSoC2012/Blender Doodles

提供: wiki
移動先: 案内検索

This is currently a lot of rough notes, but hopefully I can clean it up as I get a better handle on everything.

Heavy Drawing

cdderivedmesh Begin/End - lots of code paths, has va/vbo versions, lots of state switching, lots of "dilemas" (legacy/vbo) DrawArrays - Why not DrawElements and DrawRangeElements?

DerivedMesh (Begin/End, QUADS, NAVMESH, gameengine, no va/vbo version!, when is this code used?)

editderivedmesh (Begin/End, no vbo versions!, complicated drawing options, stipple, lots of state changes, lots of "dilemas" (has vertexCos?))

subsurf_ccg (Begin/End, no vbo versions!, attempt to optimize for subsurf)

uvedit_draw (Begin/End, no vbo versions!, similar to editderivedmesh)

gpu_buffer (Begin/End, legacy drawing code, but why? are there cases where we create buffers but have no support to draw? why can't we use vertex arrays? Is it the *mesh* thats legacy?)

Light Drawing

Fonts

File: blenfont/blf_glyph.c

Uses Begin/End, QUADS, should combine entire strings into batches. The users of blenfont need to be re-factored for this to work better.

Status: Now uses gpuBegin/gpuEnd, but it is slow due to too many small batches in some situations.



Animation Editor

File: editors/animation/anim_draw.c

Animation Current Position Indicator

void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)

A single line segment, uses Color (encapsulated in UI_ThemeColor), LineWidth > 1.0, Begin/Vertex/End.

The exact status of using glLineWidth with values greater than 1.0 is uncertain. It appears to have been deprecated but then added back.


Preview Range Curtains

void ANIM_draw_previewrange(const bContext *C, View2D *v2d)

One or two boxes. Uses Color, Rect.


File: editors/animation/anim_markers.c

Scene Markers In Time Window

void draw_markers_time(const bContext *C, int flag)

Multiple separate line segments, icons, and text, uses Scale, LineStipple (indirectly through linestyle), Color (both directly and indirectly though UI_ThemeColor), and Begin/Vertex/End. Also uses UI icon drawing and text drawing indirectly through UI_icon_draw and UI_draw_string.

Probably not that bad most of the time (like text), but may need to be re-factored to draw the lines, icons, and text in separate batches if this does not mess up the painting priority.


File: editors/animation/keyframes_draw.c

Diamond Shaped Markers

void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha)

Point-like, a unit diamond, uses GenLists, NewList, Begin/Vertex/End, QUADS, EndList, Color, Translate, Scale, CallList. LINE_SMOOTH is used, but not recommended.

Even though the diamonds are static, it seems like it would be faster to transform them on the CPU and draw them all at once than to send them each as a small batch with different translations and colors (obviously this needs to be tested). A candidate for either instancing or point sprites.


Key Blocks

Uses Rect and Color (indirectly through UI_ThemeColor).


Channels

Simply draws all the diamond shaped markers and key blocks.



File: editors/animation/anim_channels_define.c

Backdrops

boxes that serve as backgrounds. Uses Color and Rect.

Grease Pencil

File: editors/gpencil/drawgpencil.c

Line strips and points. Uses Color, Begin/Vertex/End, LineWidth (uncertain about the width), QUADS, gluDisk, PolygonStipple (through linestyle). Use of LINE_SMOOTH is not recommended.

A stroke is progress would use gpuImmediate while an existing layer can be stored in a gpuRetained.


Interface

Mesh Editing

Screen

Sculpt/Paint

Movie Clip Editor

Console

Graphs Editor

Images Editor

Info

Logic Editor

NLA Editor

Node Editor

Outliner

Sequencer

Time

View3D

Text Editor

Transform

UV Editor

Window Manager

Game Engine

(Rough)

  • on these simple shapes, like the animation markers and fonts, should queue up all or many of them and draw all at once

interface_draw (Begin/End, GetFloat, lots of different widgets drawn here)

interface_icons (Begin/End

view2d (Begin/End, couple of grid drawing routines)

editmesh_knife (Begin/End, single LINE, POINTS, intermixed)

  • anim_draw and editmesh_knife both have routines that draw single lines
  • knife is kind of a beast, maybe an object like interface just for specifying all of its "stuff" then one routine to blast it to the screen, this approach could be used for a lot of the "widgets"

editmesh_loopcut (Begin/End, a single LINES batch)

editmesh_select (Begin/End, TRIANGLES, LINE_LOOP)

  • some files like editmesh_select have drawing in a really isolated way, like 10 lines of a 5k file

editmesh_slide (Begin/End, LINES, in one case a single line)

area.c (Begin/End, LINES, another grid drawing routine)

glutil (Begin/End, LINE_STRIP, EvalCoord!, there is a line draw routine that is not used in a lot of places it could be, bglBegin looks suspicious)

screen_edit (Begin/End, Rect, POLYGON!)

paint_cursor.c (Begin/End, QUADS, texture overlay)

action_draw (Begin/End, another single line)

clip_dopesheet_draw (Begin/End, puts LINE_LOOP or QUADS into a display list!)

clip_draw (Begin/End, lots of different widgets here)

clip_graph_draw (Begin/End, slightly complicated analysis because Begin/End are not in the same scope)

clip_utils (Begin/End, single line)

graph_draw (Begin/End, lots of different line strips)

space_graph (Begin/End, single line)

image_draw (Begin/End, QUADS, LINE_LOOP, image info overlay)

nla_draw (Begin/End, some boxes and curves)

drawnode (Begin/End, commented out POLYGON, lots of different curves)

node_draw (Begin/End, POLYGON! used to draw circle (circle also has LINE_LOOP outline using same points),

sequencer_draw (Begin/End, curves, curve handles, shadedstrip, image sequence, box (could use fdrawbox), sequencer backdrop)

text_draw (Begin/End, Markers are just boxes)

space_time (Begin/End, lots of single lines)

drawanimviz (Begin/End, curves)

drawarmature (Begin/End, solid cube, uses display lists, octohedron, sphere (with lod?), rest is putting it together into bone widgets)

drawobject (Begin/End, lots and lots of widgets!!

drawvolume (Begin/End, appears to compile and then delete a fragment program in a single call of a function!)

view3d_draw (Begin/End, stars, gridfloor (which is yet another grid), axis widget?, view icon, camera border, 3D cursor, widgets that are associated with the view itself, not a particular object)

view3d_fly (Begin/End, mouse safe area, two boxes?)

transform (begin/end, manipulators? or axes?)

transform_contraints (begin/end, single line!)

transform_generics (Begin/End, single line, but this has a whole function dedicated to drawing a single line, hmm)

transform_manipulators (Begin/End, manipulator widgets, another solid cube routine!)

transform_snap (Begin/End, single line)

gpu_draw (Begin/End, text rendering, POLYGON?!)

gpu_extensions (Begin/End, framebuffer blurring)

wm_draw (Begin/End, drawing saved buffer rectangles)

wm_gesture (Begin/End, lasso and box select widgets)

wm_operators (Begin/End, radial control texture)

  • need to look for all glu functions that draw
  • make sure to check for Rect
  • lookup the glutil routines to see where they are used
  • a general strategy is to find places where functions are called multiple times and see how they can be combined into a single batch instead of multiple batches
  • functions that call functions that draw need to be checked, to see if they call the routine multiple times
  • rule for vertex arrays is to not disable what you do not need, but trust that it has been left disabled after use

Some More Formal Names For Different Doodles

  • Glyphs
  • Animation Markers
  • Grease Pencil
  • Interface Widgets
  • Icons
  • Grids
  • Mesh Editor Highlights
  • Knife Tool
  • Screen Editing Indicators
  • Paint Cursor