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