Line data Source code
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 0 : AutoMoz2DMaskData() { }
22 0 : ~AutoMoz2DMaskData() { }
23 :
24 0 : void Construct(const gfx::Matrix& aTransform,
25 : gfx::SourceSurface* aSurface)
26 : {
27 0 : MOZ_ASSERT(!IsConstructed());
28 0 : mTransform = aTransform;
29 0 : mSurface = aSurface;
30 0 : }
31 :
32 0 : gfx::SourceSurface* GetSurface()
33 : {
34 0 : MOZ_ASSERT(IsConstructed());
35 0 : return mSurface.get();
36 : }
37 :
38 0 : const gfx::Matrix& GetTransform()
39 : {
40 0 : MOZ_ASSERT(IsConstructed());
41 0 : return mTransform;
42 : }
43 :
44 : private:
45 0 : bool IsConstructed()
46 : {
47 0 : return !!mSurface;
48 : }
49 :
50 : gfx::Matrix mTransform;
51 : RefPtr<gfx::SourceSurface> mSurface;
52 :
53 : AutoMoz2DMaskData(const AutoMoz2DMaskData&) = delete;
54 : AutoMoz2DMaskData& operator=(const AutoMoz2DMaskData&) = delete;
55 : };
56 :
57 : } // namespace layers
58 : } // namespace mozilla
59 :
60 : #endif // GFX_AUTOMASKDATA_H_
|