Gecko:Layers: Difference between revisions

Line 103: Line 103:
== Bas ==
== Bas ==


// The controlling class that controls the composition of frames. This
// The controlling class that controls the composition of frames. This
// lives on a rectangular area on the client's screen, and controls the
// 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
// composition of all layers on the compositor. This runs its own thread
// internally from which all OpenGL/D3D operations are executed. All re-
// internally from which all OpenGL/D3D operations are executed. All re-
// scheduling of drawing and invalidations are run based on operations
// scheduling of drawing and invalidations are run based on operations
// executed on the compositor and its layers.
// executed on the compositor and its layers.
class Compositor
class Compositor
{
{
  // Create a layer that can be used to render to, the size here
  // 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,
  // 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
  // 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
  // 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
  // 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.
  // ready to be destroyed. Type can be one of hardware or managed.
  // Only managed layers can be drawn to directly from software.
  // Only managed layers can be drawn to directly from software.
  // Any created layer can contain other layers inside, places anywhere
  // Any created layer can contain other layers inside, places anywhere
  // on its surface.
  // on its surface.
  Layer *CreateLayer(size, format, type);
  Layer *CreateLayer(size, format, type);
};
};


// These are operations that can be executed on all layers.
// These are operations that can be executed on all layers.
class ILayer
class ILayer
{
{
  // Color by which the layers pixels are multiplied,
  // Color by which the layers pixels are multiplied,
  // This contains an alpha value so opacity can implicitly
  // This contains an alpha value so opacity can implicitly
  // be controlled.
  // be controlled.
  SetColor(color);  
  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);
};


  // Sets an affine transformation to place the layer with.
// Layers exposing this interface allow access to the surface. Double
  SetTransform(matrix);
// 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();
};


  // Add a layer to this layer. This layer may be blitted onto
// Layers exposing this interface can have their hardware surface accessed,
  // this layer's hardware surface.
// which can then be used as a render target for other accelerated parts of
  AddLayer(ILayer);
// the code.
 
class IHardwareLayer
  // Optional pixel shader program to run on this layer. This can be
{
  // used to apply a variety of effects to the layer when rendered.
  // Return hardware surface in whatever structure we pick. Might need
  SetShader(shader);
  // locking/unlocking logic.
};
  HardwareSurface *Surface();
 
};
// 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();
};
Confirmed users
138

edits