Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : *
3 : * This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef _include_gfx_layers_mlgpu_ShaderDefinitions_inl_h
8 : #define _include_gfx_layers_mlgpu_ShaderDefinitions_inl_h
9 :
10 : namespace mozilla {
11 : namespace layers {
12 : namespace mlg {
13 :
14 : inline const Maybe<gfx::Polygon>&
15 0 : SimpleTraits::geometry() const
16 : {
17 0 : return mItem.geometry;
18 : }
19 :
20 : inline nsTArray<gfx::Triangle>
21 0 : SimpleTraits::GenerateTriangles(const gfx::Polygon& aPolygon) const
22 : {
23 0 : return aPolygon.ToTriangles();
24 : }
25 :
26 : inline SimpleTraits::TriangleVertices
27 0 : SimpleTraits::MakeVertex(const FirstTriangle& aIgnore) const
28 : {
29 : TriangleVertices v = {
30 0 : mRect.BottomLeft(), mRect.TopLeft(), mRect.TopRight(),
31 0 : mItem.layerIndex, mItem.sortOrder
32 0 : };
33 0 : return v;
34 : }
35 :
36 : inline SimpleTraits::TriangleVertices
37 0 : SimpleTraits::MakeVertex(const SecondTriangle& aIgnore) const
38 : {
39 : TriangleVertices v = {
40 0 : mRect.TopRight(), mRect.BottomRight(), mRect.BottomLeft(),
41 0 : mItem.layerIndex, mItem.sortOrder
42 0 : };
43 0 : return v;
44 : }
45 :
46 : inline SimpleTraits::TriangleVertices
47 0 : SimpleTraits::MakeVertex(const gfx::Triangle& aTriangle) const
48 : {
49 : TriangleVertices v = {
50 : aTriangle.p1, aTriangle.p2, aTriangle.p3,
51 0 : mItem.layerIndex, mItem.sortOrder
52 0 : };
53 0 : return v;
54 : }
55 :
56 : inline SimpleTraits::UnitQuadVertex
57 0 : SimpleTraits::MakeUnitQuadVertex() const
58 : {
59 0 : UnitQuadVertex v = { mRect, mItem.layerIndex, mItem.sortOrder };
60 0 : return v;
61 : }
62 :
63 : inline nsTArray<gfx::TexturedTriangle>
64 0 : TexturedTraits::GenerateTriangles(const gfx::Polygon& aPolygon) const
65 : {
66 0 : return GenerateTexturedTriangles(aPolygon, mRect, mTexCoords);
67 : }
68 :
69 : inline TexturedTraits::VertexData
70 0 : TexturedTraits::MakeVertexData(const FirstTriangle& aIgnore) const
71 : {
72 0 : VertexData v = { mTexCoords.BottomLeft(), mTexCoords.TopLeft(), mTexCoords.TopRight() };
73 0 : return v;
74 : }
75 :
76 : inline TexturedTraits::VertexData
77 0 : TexturedTraits::MakeVertexData(const SecondTriangle& aIgnore) const
78 : {
79 0 : VertexData v = { mTexCoords.TopRight(), mTexCoords.BottomRight(), mTexCoords.BottomLeft() };
80 0 : return v;
81 : }
82 :
83 : inline TexturedTraits::VertexData
84 0 : TexturedTraits::MakeVertexData(const gfx::TexturedTriangle& aTriangle) const
85 : {
86 0 : VertexData v = { aTriangle.textureCoords.p1, aTriangle.textureCoords.p2, aTriangle.textureCoords.p3 };
87 0 : return v;
88 : }
89 :
90 : } // namespace mlg
91 : } // namespace layers
92 : } // namespace mozilla
93 :
94 : #endif // _include_gfx_layers_mlgpu_ShaderDefinitions_inl_h
|