/src/mozilla-central/gfx/layers/basic/AutoMaskData.h
Line | Count | Source (jump to first uncovered line) |
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 GFX_AUTOMASKDATA_H_ |
8 | | #define GFX_AUTOMASKDATA_H_ |
9 | | |
10 | | #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor |
11 | | |
12 | | namespace mozilla { |
13 | | namespace layers { |
14 | | |
15 | | /** |
16 | | * Drawing with a mask requires a mask surface and a transform. |
17 | | * |
18 | | * This helper class manages the SourceSurface logic. |
19 | | */ |
20 | | class MOZ_STACK_CLASS AutoMoz2DMaskData { |
21 | | public: |
22 | 0 | AutoMoz2DMaskData() { } |
23 | 0 | ~AutoMoz2DMaskData() { } |
24 | | |
25 | | void Construct(const gfx::Matrix& aTransform, |
26 | | gfx::SourceSurface* aSurface) |
27 | 0 | { |
28 | 0 | MOZ_ASSERT(!IsConstructed()); |
29 | 0 | mTransform = aTransform; |
30 | 0 | mSurface = aSurface; |
31 | 0 | } |
32 | | |
33 | | gfx::SourceSurface* GetSurface() |
34 | 0 | { |
35 | 0 | MOZ_ASSERT(IsConstructed()); |
36 | 0 | return mSurface.get(); |
37 | 0 | } |
38 | | |
39 | | const gfx::Matrix& GetTransform() |
40 | 0 | { |
41 | 0 | MOZ_ASSERT(IsConstructed()); |
42 | 0 | return mTransform; |
43 | 0 | } |
44 | | |
45 | | private: |
46 | | bool IsConstructed() |
47 | 0 | { |
48 | 0 | return !!mSurface; |
49 | 0 | } |
50 | | |
51 | | gfx::Matrix mTransform; |
52 | | RefPtr<gfx::SourceSurface> mSurface; |
53 | | |
54 | | AutoMoz2DMaskData(const AutoMoz2DMaskData&) = delete; |
55 | | AutoMoz2DMaskData& operator=(const AutoMoz2DMaskData&) = delete; |
56 | | }; |
57 | | |
58 | | } // namespace layers |
59 | | } // namespace mozilla |
60 | | |
61 | | #endif // GFX_AUTOMASKDATA_H_ |