Bug 1638136 [wpt PR 23617] - Clipboard API Tests: Move permissions tests to WPT....
[gecko.git] / gfx / 2d / SourceSurfaceDual.h
blob4125c3c59c8b978745fb79f97561b9fd06a5012a
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/. */
7 #ifndef MOZILLA_GFX_SOURCESURFACEDUAL_H_
8 #define MOZILLA_GFX_SOURCESURFACEDUAL_H_
10 #include "2D.h"
12 namespace mozilla {
13 namespace gfx {
15 class DualSurface;
16 class DualPattern;
18 class SourceSurfaceDual : public SourceSurface {
19 public:
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceDual, override)
22 SourceSurfaceDual(DrawTarget* aDTA, DrawTarget* aDTB)
23 : mA(aDTA->Snapshot()), mB(aDTB->Snapshot()) {}
25 SourceSurfaceDual(SourceSurface* aSourceA, SourceSurface* aSourceB)
26 : mA(aSourceA), mB(aSourceB) {}
28 virtual SurfaceType GetType() const override { return SurfaceType::DUAL_DT; }
29 virtual IntSize GetSize() const override { return mA->GetSize(); }
30 virtual SurfaceFormat GetFormat() const override { return mA->GetFormat(); }
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.
35 virtual already_AddRefed<DataSourceSurface> GetDataSurface() override {
36 return mA->GetDataSurface();
39 SourceSurface* GetFirstSurface() {
40 MOZ_ASSERT(mA->GetType() == mB->GetType());
41 return mA;
44 bool SameSurfaceTypes() { return mA->GetType() == mB->GetType(); }
46 private:
47 friend class DualSurface;
48 friend class DualPattern;
50 RefPtr<SourceSurface> mA;
51 RefPtr<SourceSurface> mB;
54 } // namespace gfx
55 } // namespace mozilla
57 #endif /* MOZILLA_GFX_SOURCESURFACEDUAL_H_ */