michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_AUTOMASKDATA_H_ michael@0: #define GFX_AUTOMASKDATA_H_ michael@0: michael@0: #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: /** michael@0: * Drawing with a mask requires a mask surface and a transform. michael@0: * michael@0: * This helper class manages the SourceSurface logic. michael@0: */ michael@0: class MOZ_STACK_CLASS AutoMoz2DMaskData { michael@0: public: michael@0: AutoMoz2DMaskData() { } michael@0: ~AutoMoz2DMaskData() { } michael@0: michael@0: void Construct(const gfx::Matrix& aTransform, michael@0: gfx::SourceSurface* aSurface) michael@0: { michael@0: MOZ_ASSERT(!IsConstructed()); michael@0: mTransform = aTransform; michael@0: mSurface = aSurface; michael@0: } michael@0: michael@0: gfx::SourceSurface* GetSurface() michael@0: { michael@0: MOZ_ASSERT(IsConstructed()); michael@0: return mSurface.get(); michael@0: } michael@0: michael@0: const gfx::Matrix& GetTransform() michael@0: { michael@0: MOZ_ASSERT(IsConstructed()); michael@0: return mTransform; michael@0: } michael@0: michael@0: private: michael@0: bool IsConstructed() michael@0: { michael@0: return !!mSurface; michael@0: } michael@0: michael@0: gfx::Matrix mTransform; michael@0: RefPtr mSurface; michael@0: michael@0: AutoMoz2DMaskData(const AutoMoz2DMaskData&) MOZ_DELETE; michael@0: AutoMoz2DMaskData& operator=(const AutoMoz2DMaskData&) MOZ_DELETE; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif // GFX_AUTOMASKDATA_H_