gfx/layers/opengl/Composer2D.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/opengl/Composer2D.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * vim: sw=2 ts=8 et :
     1.6 + */
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.9 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef mozilla_layers_Composer2D_h
    1.12 +#define mozilla_layers_Composer2D_h
    1.13 +
    1.14 +#include "gfxTypes.h"
    1.15 +#include "nsISupportsImpl.h"
    1.16 +
    1.17 +/**
    1.18 + * Many platforms have dedicated hardware for simple composition.
    1.19 + * This hardware is usually faster or more power efficient than the
    1.20 + * GPU.  However, in exchange for this better performance, generality
    1.21 + * has to be sacrificed: no 3d transforms, no intermediate surfaces,
    1.22 + * no special shader effects, loss of other goodies depending on the
    1.23 + * platform.
    1.24 + *
    1.25 + * Composer2D is a very simple interface to this class of hardware
    1.26 + * that allows an implementation to "try rendering" with the fast
    1.27 + * path.  If the given layer tree requires more generality than the
    1.28 + * hardware provides, the implementation should bail and have the
    1.29 + * layer manager fall back on full GPU composition.
    1.30 + */
    1.31 +
    1.32 +namespace mozilla {
    1.33 +
    1.34 +namespace gfx {
    1.35 +struct Matrix;
    1.36 +}
    1.37 +
    1.38 +namespace layers {
    1.39 +
    1.40 +class Layer;
    1.41 +
    1.42 +class Composer2D {
    1.43 +  NS_INLINE_DECL_REFCOUNTING(Composer2D)
    1.44 +
    1.45 +protected:
    1.46 +  // Protected destructor, to discourage deletion outside of Release():
    1.47 +  virtual ~Composer2D() {}
    1.48 +
    1.49 +public:
    1.50 +  /**
    1.51 +   * Return true if |aRoot| met the implementation's criteria for fast
    1.52 +   * composition and the render was successful.  Return false to fall
    1.53 +   * back on the GPU.
    1.54 +   *
    1.55 +   * |aWorldTransform| must be applied to |aRoot|'s subtree when
    1.56 +   * rendering to the framebuffer.  This is a global transform on the
    1.57 +   * entire scene, defined in GL space.  If the Composer2D
    1.58 +   * implementation is unable to honor the transform, it should return
    1.59 +   * false.
    1.60 +   *
    1.61 +   * Currently, when TryRender() returns true, the entire framebuffer
    1.62 +   * must have been rendered.
    1.63 +   */
    1.64 +  virtual bool TryRender(Layer* aRoot, const gfx::Matrix& aWorldTransform,
    1.65 +                         bool aGeometryChanged) = 0;
    1.66 +};
    1.67 +
    1.68 +} // namespace layers
    1.69 +} // namespace mozilla
    1.70 +
    1.71 +#endif // mozilla_layers_Composer2D_h

mercurial