Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_gfx_layers_LayersHelpers_h
7 : #define mozilla_gfx_layers_LayersHelpers_h
8 :
9 : #include "mozilla/Maybe.h"
10 : #include "mozilla/gfx/Rect.h"
11 : #include "mozilla/gfx/Matrix.h"
12 : #include "mozilla/gfx/Polygon.h"
13 : #include "nsRegion.h"
14 : #include "nsTArray.h"
15 :
16 : namespace mozilla {
17 : namespace layers {
18 :
19 : class Layer;
20 :
21 : // Compute compositor information for copying the backdrop for a mix-blend
22 : // operation.
23 : gfx::IntRect
24 : ComputeBackdropCopyRect(const gfx::Rect& aRect,
25 : const gfx::IntRect& aClipRect,
26 : const gfx::Matrix4x4& aTransform,
27 : const gfx::IntRect& aRenderTargetRect,
28 : gfx::Matrix4x4* aOutTransform,
29 : gfx::Rect* aOutLayerQuad = nullptr);
30 :
31 : // Compute uv-coordinates for a rect inside a texture.
32 : template <typename T>
33 : static inline gfx::Rect
34 0 : TextureRectToCoords(const T& aRect, const gfx::IntSize& aSize)
35 : {
36 : return gfx::Rect(
37 0 : float(aRect.x) / aSize.width,
38 0 : float(aRect.y) / aSize.height,
39 0 : float(aRect.width) / aSize.width,
40 0 : float(aRect.height) / aSize.height);
41 : }
42 :
43 : // This is defined in Compositor.cpp.
44 : nsTArray<gfx::TexturedTriangle>
45 : GenerateTexturedTriangles(const gfx::Polygon& aPolygon,
46 : const gfx::Rect& aRect,
47 : const gfx::Rect& aTexRect);
48 :
49 : // This is defined in ContainerLayerComposite.cpp.
50 : void TransformLayerGeometry(Layer* aLayer, Maybe<gfx::Polygon>& aGeometry);
51 :
52 : } // namespace layers
53 : } // namespace mozilla
54 :
55 : #endif // mozilla_gfx_layers_LayersHelpers_h
|