LCOV - code coverage report
Current view: top level - gfx/layers - BufferTexture.h (source / functions) Hit Total Coverage
Test: output.info Lines: 7 8 87.5 %
Date: 2017-07-14 16:53:18 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       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 MOZILLA_LAYERS_BUFFERETEXTURE
       7             : #define MOZILLA_LAYERS_BUFFERETEXTURE
       8             : 
       9             : #include "mozilla/layers/TextureClient.h"
      10             : #include "mozilla/ipc/SharedMemory.h"
      11             : #include "mozilla/gfx/Types.h"
      12             : #include "mozilla/gfx/2D.h"
      13             : #include "mozilla/RefPtr.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace layers {
      17             : 
      18             : bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
      19             :                                   LayersBackend aLayersBackend);
      20             : 
      21           6 : class BufferTextureData : public TextureData
      22             : {
      23             : public:
      24             :   static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
      25             :                                    gfx::BackendType aMoz2DBackend,
      26             :                                    LayersBackend aLayersBackend,
      27             :                                    TextureFlags aFlags,
      28             :                                    TextureAllocationFlags aAllocFlags,
      29             :                                    LayersIPCChannel* aAllocator);
      30             : 
      31             :   static BufferTextureData* CreateForYCbCr(KnowsCompositor* aAllocator,
      32             :                                            gfx::IntSize aYSize,
      33             :                                            gfx::IntSize aCbCrSize,
      34             :                                            StereoMode aStereoMode,
      35             :                                            YUVColorSpace aYUVColorSpace,
      36             :                                            TextureFlags aTextureFlags);
      37             : 
      38             :   // It is generally better to use CreateForYCbCr instead.
      39             :   // This creates a half-initialized texture since we don't know the sizes and
      40             :   // offsets in the buffer.
      41             :   static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
      42             :                                                          int32_t aSize,
      43             :                                                          YUVColorSpace aYUVColorSpace,
      44             :                                                          TextureFlags aTextureFlags);
      45             : 
      46          47 :   virtual bool Lock(OpenMode aMode) override { return true; }
      47             : 
      48          47 :   virtual void Unlock() override {}
      49             : 
      50             :   virtual void FillInfo(TextureData::Info& aInfo) const override;
      51             : 
      52             :   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
      53             : 
      54             :   virtual bool BorrowMappedData(MappedTextureData& aMap) override;
      55             : 
      56             :   virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) override;
      57             : 
      58             :   // use TextureClient's default implementation
      59             :   virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
      60             : 
      61           0 :   virtual BufferTextureData* AsBufferTextureData() override { return this; }
      62             : 
      63             :   // Don't use this.
      64             :   void SetDesciptor(const BufferDescriptor& aDesc);
      65             : 
      66             :   Maybe<gfx::IntSize> GetCbCrSize() const;
      67             : 
      68             :   Maybe<YUVColorSpace> GetYUVColorSpace() const;
      69             : 
      70             :   Maybe<StereoMode> GetStereoMode() const;
      71             : 
      72             : protected:
      73             :   gfx::IntSize GetSize() const;
      74             : 
      75             :   gfx::SurfaceFormat GetFormat() const;
      76             : 
      77             :   static BufferTextureData* CreateInternal(LayersIPCChannel* aAllocator,
      78             :                                            const BufferDescriptor& aDesc,
      79             :                                            gfx::BackendType aMoz2DBackend,
      80             :                                            int32_t aBufferSize,
      81             :                                            TextureFlags aTextureFlags);
      82             : 
      83             :   virtual uint8_t* GetBuffer() = 0;
      84             :   virtual size_t GetBufferSize() = 0;
      85             : 
      86           9 :   BufferTextureData(const BufferDescriptor& aDescriptor, gfx::BackendType aMoz2DBackend)
      87           9 :   : mDescriptor(aDescriptor)
      88           9 :   , mMoz2DBackend(aMoz2DBackend)
      89           9 :   {}
      90             : 
      91             :   RefPtr<gfx::DrawTarget> mDrawTarget;
      92             :   BufferDescriptor mDescriptor;
      93             :   gfx::BackendType mMoz2DBackend;
      94             : };
      95             : 
      96             : } // namespace
      97             : } // namespace
      98             : 
      99             : #endif

Generated by: LCOV version 1.13