Confirmed users
138
edits
|  (→Roc) |  (→Bas) | ||
| Line 97: | Line 97: | ||
| == Bas == | == Bas == | ||
| // The controlling class that controls the composition of frames. This | |||
| // lives on a rectangular area on the client's screen, and controls the | |||
| // composition of all layers on the compositor. This runs its own thread | |||
| // internally from which all OpenGL/D3D operations are executed. All re- | |||
| // scheduling of drawing and invalidations are run based on operations | |||
| // executed on the compositor and its layers. | |||
| class Compositor | |||
| { | |||
|   // Create a layer that can be used to render to, the size here | |||
|   // describes the size in pixels. The format the format of the data, | |||
|   // This can be RGB, RGBA, YUV. The compositor will know what to do | |||
|   // with these layers, and how to render them properly. When the last | |||
|   // reference to the layer dies there will be only one left, and it's | |||
|   // ready to be destroyed. Type can be one of hardware or managed. | |||
|   // Only managed layers can be drawn to directly from software. | |||
|   // Any created layer can contain other layers inside, places anywhere | |||
|   // on its surface. | |||
|   Layer *CreateLayer(size, format, type); | |||
| } | |||
| // These are operations that can be executed on all layers. | |||
| class ILayer | |||
| { | |||
|   // Color by which the layers pixels are multiplied, | |||
|   // This contains an alpha value so opacity can implicitly | |||
|   // be controlled. | |||
|   SetColor(color);  | |||
|   // Sets an affine transformation to place the layer with. | |||
|   SetTransform(matrix); | |||
|   // Add a layer to this layer. This layer may be blitted onto | |||
|   // this layer's hardware surface. | |||
|   AddLayer(ILayer); | |||
|   // Optional pixel shader program to run on this layer. This can be | |||
|   // used to apply a variety of effects to the layer when rendered. | |||
|   SetShader(shader); | |||
| } | |||
| // Layers exposing this interface allow access to the surface. Double | |||
| // buffered, this means that if it's currently being drawn to the compositor | |||
| // will simply draw the texture. This will ensure rendering of the compositor | |||
| // area doesn't stall waiting on an expensive software render. | |||
| class ILockableLayer | |||
| { | |||
|   // Lock the surface of this layer. Returns a gfxContext to draw to. | |||
|   gfxContext *Lock(); | |||
|   // Unlock the surface, this means we're done. And will signal the | |||
|   // compositor to update the associated texture and redraw. | |||
|   Unlock(); | |||
| } | |||
| // Layers exposing this interface can have their hardware surface accessed, | |||
| // which can then be used as a render target for other accelerated parts of | |||
| // the code. | |||
| class IHardwareLayer | |||
| { | |||
|   // Return hardware surface in whatever structure we pick. Might need | |||
|   // locking/unlocking logic. | |||
|   HardwareSurface *Surface(); | |||
| } | |||