LCOV - code coverage report
Current view: top level - gfx/layers/basic - BasicPaintedLayer.h (source / functions) Hit Total Coverage
Test: output.info Lines: 30 42 71.4 %
Date: 2017-07-14 16:53:18 Functions: 8 9 88.9 %
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             : #ifndef GFX_BASICPAINTEDLAYER_H
       7             : #define GFX_BASICPAINTEDLAYER_H
       8             : 
       9             : #include "Layers.h"                     // for PaintedLayer, LayerManager, etc
      10             : #include "RotatedBuffer.h"              // for RotatedContentBuffer, etc
      11             : #include "BasicImplData.h"              // for BasicImplData
      12             : #include "BasicLayers.h"                // for BasicLayerManager
      13             : #include "gfxPoint.h"                   // for gfxPoint
      14             : #include "mozilla/RefPtr.h"             // for RefPtr
      15             : #include "mozilla/gfx/BasePoint.h"      // for BasePoint
      16             : #include "mozilla/layers/ContentClient.h"  // for ContentClientBasic
      17             : #include "mozilla/mozalloc.h"           // for operator delete
      18             : #include "nsDebug.h"                    // for NS_ASSERTION
      19             : #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
      20             : #include "nsRegion.h"                   // for nsIntRegion
      21             : class gfxContext;
      22             : 
      23             : namespace mozilla {
      24             : namespace layers {
      25             : 
      26             : class ReadbackProcessor;
      27             : 
      28             : class BasicPaintedLayer : public PaintedLayer, public BasicImplData {
      29             : public:
      30             :   typedef RotatedContentBuffer::PaintState PaintState;
      31             :   typedef RotatedContentBuffer::ContentType ContentType;
      32             : 
      33         123 :   explicit BasicPaintedLayer(BasicLayerManager* aLayerManager, gfx::BackendType aBackend) :
      34             :     PaintedLayer(aLayerManager, static_cast<BasicImplData*>(this)),
      35             :     mContentClient(nullptr)
      36         123 :     , mBackend(aBackend)
      37             :   {
      38         123 :     MOZ_COUNT_CTOR(BasicPaintedLayer);
      39         123 :   }
      40             : 
      41             : protected:
      42         234 :   virtual ~BasicPaintedLayer()
      43         234 :   {
      44         117 :     MOZ_COUNT_DTOR(BasicPaintedLayer);
      45         351 :   }
      46             : 
      47             : public:
      48         185 :   virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
      49             :   {
      50         185 :     NS_ASSERTION(BasicManager()->InConstruction(),
      51             :                  "Can only set properties in construction phase");
      52         185 :     PaintedLayer::SetVisibleRegion(aRegion);
      53         185 :   }
      54          20 :   virtual void InvalidateRegion(const nsIntRegion& aRegion) override
      55             :   {
      56          20 :     NS_ASSERTION(BasicManager()->InConstruction(),
      57             :                  "Can only set properties in construction phase");
      58          20 :     mInvalidRegion.Add(aRegion);
      59          20 :     UpdateValidRegionAfterInvalidRegionChanged();
      60          20 :   }
      61             : 
      62             :   virtual void PaintThebes(gfxContext* aContext,
      63             :                            Layer* aMaskLayer,
      64             :                            LayerManager::DrawPaintedLayerCallback aCallback,
      65             :                            void* aCallbackData) override;
      66             : 
      67             :   virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback,
      68             :                         void* aCallbackData,
      69             :                         ReadbackProcessor* aReadback) override;
      70             : 
      71          48 :   virtual void ClearCachedResources() override
      72             :   {
      73          48 :     if (mContentClient) {
      74          48 :       mContentClient->Clear();
      75             :     }
      76          48 :     ClearValidRegion();
      77          48 :   }
      78             : 
      79         215 :   virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
      80             :   {
      81         215 :     if (!BasicManager()->IsRetained()) {
      82             :       // Don't do any snapping of our transform, since we're just going to
      83             :       // draw straight through without intermediate buffers.
      84         215 :       mEffectiveTransform = GetLocalTransform() * aTransformToSurface;
      85         215 :       if (gfxPoint(0,0) != mResidualTranslation) {
      86           0 :         mResidualTranslation = gfxPoint(0,0);
      87           0 :         ClearValidRegion();
      88             :       }
      89         215 :       ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
      90         215 :       return;
      91             :     }
      92           0 :     PaintedLayer::ComputeEffectiveTransforms(aTransformToSurface);
      93             :   }
      94             : 
      95         632 :   BasicLayerManager* BasicManager()
      96             :   {
      97         632 :     return static_cast<BasicLayerManager*>(mManager);
      98             :   }
      99             : 
     100             : protected:
     101             :   virtual void
     102           0 :   PaintBuffer(gfxContext* aContext,
     103             :               const nsIntRegion& aRegionToDraw,
     104             :               const nsIntRegion& aExtendedRegionToDraw,
     105             :               const nsIntRegion& aRegionToInvalidate,
     106             :               bool aDidSelfCopy,
     107             :               DrawRegionClip aClip,
     108             :               LayerManager::DrawPaintedLayerCallback aCallback,
     109             :               void* aCallbackData)
     110             :   {
     111           0 :     if (!aCallback) {
     112           0 :       BasicManager()->SetTransactionIncomplete();
     113           0 :       return;
     114             :     }
     115           0 :     aCallback(this, aContext, aExtendedRegionToDraw, aExtendedRegionToDraw,
     116           0 :               aClip, aRegionToInvalidate, aCallbackData);
     117             :     // Everything that's visible has been validated. Do this instead of just
     118             :     // OR-ing with aRegionToDraw, since that can lead to a very complex region
     119             :     // here (OR doesn't automatically simplify to the simplest possible
     120             :     // representation of a region.)
     121           0 :     nsIntRegion tmp;
     122           0 :     tmp.Or(mVisibleRegion.ToUnknownRegion(), aExtendedRegionToDraw);
     123           0 :     AddToValidRegion(tmp);
     124             :   }
     125             : 
     126             :   RefPtr<ContentClientBasic> mContentClient;
     127             :   gfx::BackendType mBackend;
     128             : };
     129             : 
     130             : } // namespace layers
     131             : } // namespace mozilla
     132             : 
     133             : #endif

Generated by: LCOV version 1.13