Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: sw=2 ts=8 et : |
michael@0 | 3 | */ |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 6 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef mozilla_layers_Composer2D_h |
michael@0 | 9 | #define mozilla_layers_Composer2D_h |
michael@0 | 10 | |
michael@0 | 11 | #include "gfxTypes.h" |
michael@0 | 12 | #include "nsISupportsImpl.h" |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * Many platforms have dedicated hardware for simple composition. |
michael@0 | 16 | * This hardware is usually faster or more power efficient than the |
michael@0 | 17 | * GPU. However, in exchange for this better performance, generality |
michael@0 | 18 | * has to be sacrificed: no 3d transforms, no intermediate surfaces, |
michael@0 | 19 | * no special shader effects, loss of other goodies depending on the |
michael@0 | 20 | * platform. |
michael@0 | 21 | * |
michael@0 | 22 | * Composer2D is a very simple interface to this class of hardware |
michael@0 | 23 | * that allows an implementation to "try rendering" with the fast |
michael@0 | 24 | * path. If the given layer tree requires more generality than the |
michael@0 | 25 | * hardware provides, the implementation should bail and have the |
michael@0 | 26 | * layer manager fall back on full GPU composition. |
michael@0 | 27 | */ |
michael@0 | 28 | |
michael@0 | 29 | namespace mozilla { |
michael@0 | 30 | |
michael@0 | 31 | namespace gfx { |
michael@0 | 32 | struct Matrix; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | namespace layers { |
michael@0 | 36 | |
michael@0 | 37 | class Layer; |
michael@0 | 38 | |
michael@0 | 39 | class Composer2D { |
michael@0 | 40 | NS_INLINE_DECL_REFCOUNTING(Composer2D) |
michael@0 | 41 | |
michael@0 | 42 | protected: |
michael@0 | 43 | // Protected destructor, to discourage deletion outside of Release(): |
michael@0 | 44 | virtual ~Composer2D() {} |
michael@0 | 45 | |
michael@0 | 46 | public: |
michael@0 | 47 | /** |
michael@0 | 48 | * Return true if |aRoot| met the implementation's criteria for fast |
michael@0 | 49 | * composition and the render was successful. Return false to fall |
michael@0 | 50 | * back on the GPU. |
michael@0 | 51 | * |
michael@0 | 52 | * |aWorldTransform| must be applied to |aRoot|'s subtree when |
michael@0 | 53 | * rendering to the framebuffer. This is a global transform on the |
michael@0 | 54 | * entire scene, defined in GL space. If the Composer2D |
michael@0 | 55 | * implementation is unable to honor the transform, it should return |
michael@0 | 56 | * false. |
michael@0 | 57 | * |
michael@0 | 58 | * Currently, when TryRender() returns true, the entire framebuffer |
michael@0 | 59 | * must have been rendered. |
michael@0 | 60 | */ |
michael@0 | 61 | virtual bool TryRender(Layer* aRoot, const gfx::Matrix& aWorldTransform, |
michael@0 | 62 | bool aGeometryChanged) = 0; |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | } // namespace layers |
michael@0 | 66 | } // namespace mozilla |
michael@0 | 67 | |
michael@0 | 68 | #endif // mozilla_layers_Composer2D_h |