LCOV - code coverage report
Current view: top level - gfx/layers/basic - BasicImageLayer.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 45 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 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 "BasicLayersImpl.h"            // for FillRectWithMask, etc
       7             : #include "ImageContainer.h"             // for AutoLockImage, etc
       8             : #include "ImageLayers.h"                // for ImageLayer
       9             : #include "Layers.h"                     // for Layer (ptr only), etc
      10             : #include "basic/BasicImplData.h"        // for BasicImplData
      11             : #include "basic/BasicLayers.h"          // for BasicLayerManager
      12             : #include "mozilla/mozalloc.h"           // for operator new
      13             : #include "nsCOMPtr.h"                   // for already_AddRefed
      14             : #include "nsDebug.h"                    // for NS_ASSERTION
      15             : #include "nsISupportsImpl.h"            // for gfxPattern::Release, etc
      16             : #include "nsRect.h"                     // for mozilla::gfx::IntRect
      17             : #include "nsRegion.h"                   // for nsIntRegion
      18             : #include "mozilla/gfx/Point.h"          // for IntSize
      19             : 
      20             : using namespace mozilla::gfx;
      21             : 
      22             : namespace mozilla {
      23             : namespace layers {
      24             : 
      25             : class BasicImageLayer : public ImageLayer, public BasicImplData {
      26             : public:
      27           0 :   explicit BasicImageLayer(BasicLayerManager* aLayerManager) :
      28             :     ImageLayer(aLayerManager, static_cast<BasicImplData*>(this)),
      29           0 :     mSize(-1, -1)
      30             :   {
      31           0 :     MOZ_COUNT_CTOR(BasicImageLayer);
      32           0 :   }
      33             : protected:
      34           0 :   ~BasicImageLayer() override
      35           0 :   {
      36           0 :     MOZ_COUNT_DTOR(BasicImageLayer);
      37           0 :   }
      38             : 
      39             : public:
      40           0 :   void SetVisibleRegion(const LayerIntRegion& aRegion) override
      41             :   {
      42           0 :     NS_ASSERTION(BasicManager()->InConstruction(),
      43             :                  "Can only set properties in construction phase");
      44           0 :     ImageLayer::SetVisibleRegion(aRegion);
      45           0 :   }
      46             : 
      47             :   void Paint(DrawTarget* aDT,
      48             :              const gfx::Point& aDeviceOffset,
      49             :              Layer* aMaskLayer) override;
      50             : 
      51             :   already_AddRefed<SourceSurface> GetAsSourceSurface() override;
      52             : 
      53             : protected:
      54           0 :   BasicLayerManager* BasicManager()
      55             :   {
      56           0 :     return static_cast<BasicLayerManager*>(mManager);
      57             :   }
      58             : 
      59             :   gfx::IntSize mSize;
      60             : };
      61             : 
      62             : void
      63           0 : BasicImageLayer::Paint(DrawTarget* aDT,
      64             :                        const gfx::Point& aDeviceOffset,
      65             :                        Layer* aMaskLayer)
      66             : {
      67           0 :   if (IsHidden() || !mContainer) {
      68           0 :     return;
      69             :   }
      70             : 
      71           0 :   RefPtr<ImageFactory> originalIF = mContainer->GetImageFactory();
      72           0 :   mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory());
      73             : 
      74           0 :   AutoLockImage autoLock(mContainer);
      75           0 :   Image *image = autoLock.GetImage(BasicManager()->GetCompositionTime());
      76           0 :   if (!image) {
      77           0 :     mContainer->SetImageFactory(originalIF);
      78           0 :     return;
      79             :   }
      80           0 :   RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface();
      81           0 :   if (!surface || !surface->IsValid()) {
      82           0 :     mContainer->SetImageFactory(originalIF);
      83           0 :     return;
      84             :   }
      85             : 
      86           0 :   gfx::IntSize size = mSize = surface->GetSize();
      87           0 :   FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, size.width, size.height),
      88             :                    surface, mSamplingFilter,
      89           0 :                    DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
      90           0 :                    aMaskLayer);
      91             : 
      92           0 :   mContainer->SetImageFactory(originalIF);
      93             : }
      94             : 
      95             : already_AddRefed<SourceSurface>
      96           0 : BasicImageLayer::GetAsSourceSurface()
      97             : {
      98           0 :   if (!mContainer) {
      99           0 :     return nullptr;
     100             :   }
     101             : 
     102           0 :   AutoLockImage lockImage(mContainer);
     103           0 :   Image* image = lockImage.GetImage();
     104           0 :   if (!image) {
     105           0 :     return nullptr;
     106             :   }
     107           0 :   return image->GetAsSourceSurface();
     108             : }
     109             : 
     110             : already_AddRefed<ImageLayer>
     111           0 : BasicLayerManager::CreateImageLayer()
     112             : {
     113           0 :   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
     114           0 :   RefPtr<ImageLayer> layer = new BasicImageLayer(this);
     115           0 :   return layer.forget();
     116             : }
     117             : 
     118             : } // namespace layers
     119             : } // namespace mozilla

Generated by: LCOV version 1.13