gfx/layers/basic/AutoMaskData.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:93cdaa1e73c3
1 /* -*- Mode: C++; tab-width: 2; 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 GFX_AUTOMASKDATA_H_
7 #define GFX_AUTOMASKDATA_H_
8
9 #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
10
11 namespace mozilla {
12 namespace layers {
13
14 /**
15 * Drawing with a mask requires a mask surface and a transform.
16 *
17 * This helper class manages the SourceSurface logic.
18 */
19 class MOZ_STACK_CLASS AutoMoz2DMaskData {
20 public:
21 AutoMoz2DMaskData() { }
22 ~AutoMoz2DMaskData() { }
23
24 void Construct(const gfx::Matrix& aTransform,
25 gfx::SourceSurface* aSurface)
26 {
27 MOZ_ASSERT(!IsConstructed());
28 mTransform = aTransform;
29 mSurface = aSurface;
30 }
31
32 gfx::SourceSurface* GetSurface()
33 {
34 MOZ_ASSERT(IsConstructed());
35 return mSurface.get();
36 }
37
38 const gfx::Matrix& GetTransform()
39 {
40 MOZ_ASSERT(IsConstructed());
41 return mTransform;
42 }
43
44 private:
45 bool IsConstructed()
46 {
47 return !!mSurface;
48 }
49
50 gfx::Matrix mTransform;
51 RefPtr<gfx::SourceSurface> mSurface;
52
53 AutoMoz2DMaskData(const AutoMoz2DMaskData&) MOZ_DELETE;
54 AutoMoz2DMaskData& operator=(const AutoMoz2DMaskData&) MOZ_DELETE;
55 };
56
57 }
58 }
59
60 #endif // GFX_AUTOMASKDATA_H_

mercurial