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 MOZILLA_GFX_SOURCESURFACEDUAL_H_ 8 #define MOZILLA_GFX_SOURCESURFACEDUAL_H_ 9 10 #include "2D.h" 11 12 namespace mozilla { 13 namespace gfx { 14 15 class DualSurface; 16 class DualPattern; 17 18 class SourceSurfaceDual : public SourceSurface { 19 public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceDual,override)20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceDual, override) 21 22 SourceSurfaceDual(DrawTarget* aDTA, DrawTarget* aDTB) 23 : mA(aDTA->Snapshot()), mB(aDTB->Snapshot()) {} 24 SourceSurfaceDual(SourceSurface * aSourceA,SourceSurface * aSourceB)25 SourceSurfaceDual(SourceSurface* aSourceA, SourceSurface* aSourceB) 26 : mA(aSourceA), mB(aSourceB) {} 27 GetType()28 virtual SurfaceType GetType() const override { return SurfaceType::DUAL_DT; } GetSize()29 virtual IntSize GetSize() const override { return mA->GetSize(); } GetFormat()30 virtual SurfaceFormat GetFormat() const override { return mA->GetFormat(); } 31 32 // TODO: This is probably wrong as this was originally only 33 // used for debugging purposes, but now has legacy relying on 34 // giving the first type only. GetDataSurface()35 virtual already_AddRefed<DataSourceSurface> GetDataSurface() override { 36 return mA->GetDataSurface(); 37 } 38 GetFirstSurface()39 SourceSurface* GetFirstSurface() { 40 MOZ_ASSERT(mA->GetType() == mB->GetType()); 41 return mA; 42 } 43 SameSurfaceTypes()44 bool SameSurfaceTypes() { return mA->GetType() == mB->GetType(); } 45 46 private: 47 friend class DualSurface; 48 friend class DualPattern; 49 50 RefPtr<SourceSurface> mA; 51 RefPtr<SourceSurface> mB; 52 }; 53 54 } // namespace gfx 55 } // namespace mozilla 56 57 #endif /* MOZILLA_GFX_SOURCESURFACEDUAL_H_ */ 58