1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/basic/AutoMaskData.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_AUTOMASKDATA_H_ 1.10 +#define GFX_AUTOMASKDATA_H_ 1.11 + 1.12 +#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor 1.13 + 1.14 +namespace mozilla { 1.15 +namespace layers { 1.16 + 1.17 +/** 1.18 + * Drawing with a mask requires a mask surface and a transform. 1.19 + * 1.20 + * This helper class manages the SourceSurface logic. 1.21 + */ 1.22 +class MOZ_STACK_CLASS AutoMoz2DMaskData { 1.23 +public: 1.24 + AutoMoz2DMaskData() { } 1.25 + ~AutoMoz2DMaskData() { } 1.26 + 1.27 + void Construct(const gfx::Matrix& aTransform, 1.28 + gfx::SourceSurface* aSurface) 1.29 + { 1.30 + MOZ_ASSERT(!IsConstructed()); 1.31 + mTransform = aTransform; 1.32 + mSurface = aSurface; 1.33 + } 1.34 + 1.35 + gfx::SourceSurface* GetSurface() 1.36 + { 1.37 + MOZ_ASSERT(IsConstructed()); 1.38 + return mSurface.get(); 1.39 + } 1.40 + 1.41 + const gfx::Matrix& GetTransform() 1.42 + { 1.43 + MOZ_ASSERT(IsConstructed()); 1.44 + return mTransform; 1.45 + } 1.46 + 1.47 +private: 1.48 + bool IsConstructed() 1.49 + { 1.50 + return !!mSurface; 1.51 + } 1.52 + 1.53 + gfx::Matrix mTransform; 1.54 + RefPtr<gfx::SourceSurface> mSurface; 1.55 + 1.56 + AutoMoz2DMaskData(const AutoMoz2DMaskData&) MOZ_DELETE; 1.57 + AutoMoz2DMaskData& operator=(const AutoMoz2DMaskData&) MOZ_DELETE; 1.58 +}; 1.59 + 1.60 +} 1.61 +} 1.62 + 1.63 +#endif // GFX_AUTOMASKDATA_H_