LCOV - code coverage report
Current view: top level - gfx/layers/opengl - TextureClientOGL.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 27 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
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             : #include "GLContext.h"                  // for GLContext, etc
       7             : #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
       8             : #include "mozilla/layers/ISurfaceAllocator.h"
       9             : #include "mozilla/layers/TextureClientOGL.h"
      10             : #include "mozilla/gfx/Point.h"          // for IntSize
      11             : #include "GLLibraryEGL.h"
      12             : 
      13             : using namespace mozilla::gl;
      14             : 
      15             : namespace mozilla {
      16             : namespace layers {
      17             : 
      18             : class CompositableForwarder;
      19             : 
      20             : ////////////////////////////////////////////////////////////////////////
      21             : // EGLImage
      22             : 
      23           0 : EGLImageTextureData::EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSize)
      24             : : mImage(aImage)
      25           0 : , mSize(aSize)
      26             : {
      27           0 :   MOZ_ASSERT(aImage);
      28           0 : }
      29             : 
      30             : already_AddRefed<TextureClient>
      31           0 : EGLImageTextureData::CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize,
      32             :                                          LayersIPCChannel* aAllocator, TextureFlags aFlags)
      33             : {
      34           0 :   MOZ_ASSERT(XRE_IsParentProcess(),
      35             :              "Can't pass an `EGLImage` between processes.");
      36             : 
      37           0 :   if (!aImage || !XRE_IsParentProcess()) {
      38           0 :     return nullptr;
      39             :   }
      40             : 
      41             :   // XXX - This is quite sad and slow.
      42           0 :   aFlags |= TextureFlags::DEALLOCATE_CLIENT;
      43             : 
      44           0 :   if (aImage->GetOriginPos() == gl::OriginPos::BottomLeft) {
      45           0 :     aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT;
      46             :   }
      47             : 
      48             :   return TextureClient::CreateWithData(
      49           0 :     new EGLImageTextureData(aImage, aSize),
      50             :     aFlags, aAllocator
      51           0 :   );
      52             : }
      53             : 
      54             : void
      55           0 : EGLImageTextureData::FillInfo(TextureData::Info& aInfo) const
      56             : {
      57           0 :   aInfo.size = mSize;
      58           0 :   aInfo.format = gfx::SurfaceFormat::UNKNOWN;
      59           0 :   aInfo.hasIntermediateBuffer = false;
      60           0 :   aInfo.hasSynchronization = false;
      61           0 :   aInfo.supportsMoz2D = false;
      62           0 :   aInfo.canExposeMappedData = false;
      63           0 : }
      64             : 
      65             : bool
      66           0 : EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
      67             : {
      68           0 :   const bool hasAlpha = true;
      69             :   aOutDescriptor =
      70           0 :     EGLImageDescriptor((uintptr_t)mImage->GetImage(),
      71           0 :                        (uintptr_t)mImage->GetSync(),
      72           0 :                        mImage->GetSize(), hasAlpha);
      73           0 :   return true;
      74             : }
      75             : 
      76             : ////////////////////////////////////////////////////////////////////////
      77             : // AndroidSurface
      78             : 
      79             : #ifdef MOZ_WIDGET_ANDROID
      80             : 
      81             : already_AddRefed<TextureClient>
      82             : AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTextureHandle aHandle,
      83             :                                                gfx::IntSize aSize,
      84             :                                                bool aContinuous,
      85             :                                                gl::OriginPos aOriginPos,
      86             :                                                LayersIPCChannel* aAllocator,
      87             :                                                TextureFlags aFlags)
      88             : {
      89             :   if (aOriginPos == gl::OriginPos::BottomLeft) {
      90             :     aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT;
      91             :   }
      92             : 
      93             :   return TextureClient::CreateWithData(
      94             :     new AndroidSurfaceTextureData(aHandle, aSize, aContinuous),
      95             :     aFlags, aAllocator
      96             :   );
      97             : }
      98             : 
      99             : AndroidSurfaceTextureData::AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle,
     100             :                                                      gfx::IntSize aSize, bool aContinuous)
     101             :   : mHandle(aHandle)
     102             :   , mSize(aSize)
     103             :   , mContinuous(aContinuous)
     104             : {
     105             :   MOZ_ASSERT(mHandle);
     106             : }
     107             : 
     108             : AndroidSurfaceTextureData::~AndroidSurfaceTextureData()
     109             : {}
     110             : 
     111             : void
     112             : AndroidSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const
     113             : {
     114             :   aInfo.size = mSize;
     115             :   aInfo.format = gfx::SurfaceFormat::UNKNOWN;
     116             :   aInfo.hasIntermediateBuffer = false;
     117             :   aInfo.hasSynchronization = false;
     118             :   aInfo.supportsMoz2D = false;
     119             :   aInfo.canExposeMappedData = false;
     120             : }
     121             : 
     122             : bool
     123             : AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
     124             : {
     125             :   aOutDescriptor = SurfaceTextureDescriptor(mHandle, mSize, mContinuous);
     126             :   return true;
     127             : }
     128             : 
     129             : #endif // MOZ_WIDGET_ANDROID
     130             : 
     131             : } // namespace layers
     132             : } // namespace mozilla

Generated by: LCOV version 1.13