LCOV - code coverage report
Current view: top level - gfx/layers - CopyableCanvasLayer.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 36 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; 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 "CopyableCanvasLayer.h"
       7             : 
       8             : #include "BasicLayersImpl.h"            // for FillWithMask, etc
       9             : #include "GLContext.h"                  // for GLContext
      10             : #include "GLScreenBuffer.h"             // for GLScreenBuffer
      11             : #include "SharedSurface.h"              // for SharedSurface
      12             : #include "SharedSurfaceGL.h"              // for SharedSurface
      13             : #include "gfxPattern.h"                 // for gfxPattern, etc
      14             : #include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
      15             : #include "gfxRect.h"                    // for gfxRect
      16             : #include "gfxUtils.h"                   // for gfxUtils
      17             : #include "gfx2DGlue.h"                  // for thebes --> moz2d transition
      18             : #include "mozilla/gfx/BaseSize.h"       // for BaseSize
      19             : #include "mozilla/gfx/Tools.h"
      20             : #include "mozilla/gfx/Point.h"          // for IntSize
      21             : #include "mozilla/layers/AsyncCanvasRenderer.h"
      22             : #include "mozilla/layers/PersistentBufferProvider.h"
      23             : #include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING, etc
      24             : #include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
      25             : #include "nsRect.h"                     // for mozilla::gfx::IntRect
      26             : #include "gfxUtils.h"
      27             : #include "client/TextureClientSharedSurface.h"
      28             : 
      29             : namespace mozilla {
      30             : namespace layers {
      31             : 
      32             : using namespace mozilla::gfx;
      33             : using namespace mozilla::gl;
      34             : 
      35           0 : CopyableCanvasLayer::CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData) :
      36             :   CanvasLayer(aLayerManager, aImplData)
      37             :   , mGLFrontbuffer(nullptr)
      38             :   , mIsAlphaPremultiplied(true)
      39             :   , mOriginPos(gl::OriginPos::TopLeft)
      40           0 :   , mIsMirror(false)
      41             : {
      42           0 :   MOZ_COUNT_CTOR(CopyableCanvasLayer);
      43           0 : }
      44             : 
      45           0 : CopyableCanvasLayer::~CopyableCanvasLayer()
      46             : {
      47           0 :   MOZ_COUNT_DTOR(CopyableCanvasLayer);
      48           0 : }
      49             : 
      50             : void
      51           0 : CopyableCanvasLayer::Initialize(const Data& aData)
      52             : {
      53           0 :   if (aData.mGLContext) {
      54           0 :     mGLContext = aData.mGLContext;
      55           0 :     mIsAlphaPremultiplied = aData.mIsGLAlphaPremult;
      56           0 :     mOriginPos = gl::OriginPos::BottomLeft;
      57           0 :     mIsMirror = aData.mIsMirror;
      58             : 
      59           0 :     MOZ_ASSERT(mGLContext->IsOffscreen(), "canvas gl context isn't offscreen");
      60             : 
      61           0 :     if (aData.mFrontbufferGLTex) {
      62           0 :       gfx::IntSize size(aData.mSize.width, aData.mSize.height);
      63           0 :       mGLFrontbuffer = SharedSurface_Basic::Wrap(aData.mGLContext, size, aData.mHasAlpha,
      64           0 :                                                  aData.mFrontbufferGLTex);
      65           0 :       mBufferProvider = aData.mBufferProvider;
      66             :     }
      67           0 :   } else if (aData.mBufferProvider) {
      68           0 :     mBufferProvider = aData.mBufferProvider;
      69           0 :   } else if (aData.mRenderer) {
      70           0 :     mAsyncRenderer = aData.mRenderer;
      71           0 :     mOriginPos = gl::OriginPos::BottomLeft;
      72             :   } else {
      73           0 :     MOZ_CRASH("GFX: CanvasLayer created without BufferProvider, DrawTarget or GLContext?");
      74             :   }
      75             : 
      76           0 :   mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
      77           0 : }
      78             : 
      79             : bool
      80           0 : CopyableCanvasLayer::IsDataValid(const Data& aData)
      81             : {
      82           0 :   return mGLContext == aData.mGLContext;
      83             : }
      84             : 
      85             : DataSourceSurface*
      86           0 : CopyableCanvasLayer::GetTempSurface(const IntSize& aSize,
      87             :                                     const SurfaceFormat aFormat)
      88             : {
      89           0 :   if (!mCachedTempSurface ||
      90           0 :       aSize != mCachedTempSurface->GetSize() ||
      91           0 :       aFormat != mCachedTempSurface->GetFormat())
      92             :   {
      93             :     // Create a surface aligned to 8 bytes since that's the highest alignment WebGL can handle.
      94           0 :     uint32_t stride = GetAlignedStride<8>(aSize.width, BytesPerPixel(aFormat));
      95           0 :     mCachedTempSurface = Factory::CreateDataSourceSurfaceWithStride(aSize, aFormat, stride);
      96             :   }
      97             : 
      98           0 :   return mCachedTempSurface;
      99             : }
     100             : 
     101             : } // namespace layers
     102             : } // namespace mozilla

Generated by: LCOV version 1.13