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/. */
7 #ifndef MOZILLA_PAINTING_MATRIXSTACK_H
8 #define MOZILLA_PAINTING_MATRIXSTACK_H
11 #include "mozilla/gfx/MatrixFwd.h"
16 * MatrixStack stores a stack of matrices and keeps track of the accumulated
22 MatrixStack() = default;
24 ~MatrixStack() { MOZ_ASSERT(mMatrices
.IsEmpty()); }
27 * Returns the current accumulated transform matrix.
29 const T
& CurrentMatrix() const { return mCurrentMatrix
; }
32 * Returns true if any matrices are currently pushed to the stack.
34 bool HasTransform() const { return mMatrices
.Length() > 0; }
37 * Pushes the given |aMatrix| to the stack.
39 void Push(const T
& aMatrix
) {
40 mMatrices
.AppendElement(mCurrentMatrix
);
41 mCurrentMatrix
= aMatrix
* mCurrentMatrix
;
45 * Pops the most recently added matrix from the stack.
48 MOZ_ASSERT(mMatrices
.Length() > 0);
49 mCurrentMatrix
= mMatrices
.PopLastElement();
54 AutoTArray
<T
, 2> mMatrices
;
57 typedef MatrixStack
<gfx::Matrix4x4Flagged
> MatrixStack4x4
;
59 } // namespace mozilla
61 #endif /* MOZILLA_PAINTING_MATRIXSTACK_H */