Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 mozilla_gfx_layers_LayersHelpers_h
8
#define mozilla_gfx_layers_LayersHelpers_h
9
10
#include "mozilla/Maybe.h"
11
#include "mozilla/gfx/Rect.h"
12
#include "mozilla/gfx/Matrix.h"
13
#include "mozilla/gfx/Polygon.h"
14
#include "nsRegion.h"
15
#include "nsTArray.h"
16
17
namespace mozilla {
18
namespace layers {
19
20
class Layer;
21
22
// Compute compositor information for copying the backdrop for a mix-blend
23
// operation.
24
gfx::IntRect 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 TextureRectToCoords(const T& aRect,
34
const gfx::IntSize& aSize) {
35
return gfx::Rect(
36
float(aRect.X()) / aSize.width, float(aRect.Y()) / aSize.height,
37
float(aRect.Width()) / aSize.width, float(aRect.Height()) / aSize.height);
38
}
39
40
// This is defined in Compositor.cpp.
41
nsTArray<gfx::TexturedTriangle> GenerateTexturedTriangles(
42
const gfx::Polygon& aPolygon, const gfx::Rect& aRect,
43
const gfx::Rect& aTexRect);
44
45
// This is defined in ContainerLayerComposite.cpp.
46
void TransformLayerGeometry(Layer* aLayer, Maybe<gfx::Polygon>& aGeometry);
47
48
} // namespace layers
49
} // namespace mozilla
50
51
#endif // mozilla_gfx_layers_LayersHelpers_h