SharedSurfaceIO.h (1790B)
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/. */ 5 6 #ifndef SHARED_SURFACEIO_H_ 7 #define SHARED_SURFACEIO_H_ 8 9 #include "mozilla/RefPtr.h" 10 #include "SharedSurface.h" 11 12 class MacIOSurface; 13 14 namespace mozilla { 15 namespace gl { 16 17 class Texture; 18 19 class SharedSurface_IOSurface final : public SharedSurface { 20 public: 21 const UniquePtr<Texture> mTex; 22 const RefPtr<MacIOSurface> mIOSurf; 23 24 static UniquePtr<SharedSurface_IOSurface> Create(const SharedSurfaceDesc&); 25 26 private: 27 SharedSurface_IOSurface(const SharedSurfaceDesc&, UniquePtr<MozFramebuffer>, 28 UniquePtr<Texture>, const RefPtr<MacIOSurface>&); 29 30 public: 31 ~SharedSurface_IOSurface(); 32 33 virtual void LockProdImpl() override {} 34 virtual void UnlockProdImpl() override {} 35 36 virtual void ProducerAcquireImpl() override {} 37 virtual void ProducerReleaseImpl() override; 38 39 virtual bool NeedsIndirectReads() const override { return true; } 40 41 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override; 42 }; 43 44 class SurfaceFactory_IOSurface : public SurfaceFactory { 45 public: 46 const gfx::IntSize mMaxDims; 47 48 explicit SurfaceFactory_IOSurface(GLContext& gl); 49 50 bool SupportsCspaces() const override { return true; } 51 52 virtual UniquePtr<SharedSurface> CreateSharedImpl( 53 const SharedSurfaceDesc& desc) override { 54 if (desc.size.width > mMaxDims.width || 55 desc.size.height > mMaxDims.height) { 56 return nullptr; 57 } 58 return SharedSurface_IOSurface::Create(desc); 59 } 60 }; 61 62 } // namespace gl 63 64 } /* namespace mozilla */ 65 66 #endif /* SHARED_SURFACEIO_H_ */