Bug 1882703 [wpt PR 44848] - Update wpt metadata, a=testonly
[gecko.git] / gfx / gl / SharedSurfaceIO.h
blob938173b9823e1ed78e4c8489573e2522a901da14
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
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/. */
6 #ifndef SHARED_SURFACEIO_H_
7 #define SHARED_SURFACEIO_H_
9 #include "mozilla/RefPtr.h"
10 #include "SharedSurface.h"
12 class MacIOSurface;
14 namespace mozilla {
15 namespace gl {
17 class Texture;
19 class SharedSurface_IOSurface final : public SharedSurface {
20 public:
21 const UniquePtr<Texture> mTex;
22 const RefPtr<MacIOSurface> mIOSurf;
24 static UniquePtr<SharedSurface_IOSurface> Create(const SharedSurfaceDesc&);
26 private:
27 SharedSurface_IOSurface(const SharedSurfaceDesc&, UniquePtr<MozFramebuffer>,
28 UniquePtr<Texture>, const RefPtr<MacIOSurface>&);
30 public:
31 ~SharedSurface_IOSurface();
33 virtual void LockProdImpl() override {}
34 virtual void UnlockProdImpl() override {}
36 virtual void ProducerAcquireImpl() override {}
37 virtual void ProducerReleaseImpl() override;
39 virtual bool NeedsIndirectReads() const override { return true; }
41 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
44 class SurfaceFactory_IOSurface : public SurfaceFactory {
45 public:
46 const gfx::IntSize mMaxDims;
48 explicit SurfaceFactory_IOSurface(GLContext& gl);
50 virtual UniquePtr<SharedSurface> CreateSharedImpl(
51 const SharedSurfaceDesc& desc) override {
52 if (desc.size.width > mMaxDims.width ||
53 desc.size.height > mMaxDims.height) {
54 return nullptr;
56 return SharedSurface_IOSurface::Create(desc);
60 } // namespace gl
62 } /* namespace mozilla */
64 #endif /* SHARED_SURFACEIO_H_ */