LCOV - code coverage report
Current view: top level - gfx/layers/basic - BasicTextLayer.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 27 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 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 "Layers.h"                     // for ColorLayer, etc
       8             : #include "BasicImplData.h"              // for BasicImplData
       9             : #include "BasicLayers.h"                // for BasicLayerManager
      10             : #include "gfxContext.h"                 // for gfxContext, etc
      11             : #include "gfxRect.h"                    // for gfxRect
      12             : #include "gfx2DGlue.h"
      13             : #include "mozilla/mozalloc.h"           // for operator new
      14             : #include "nsCOMPtr.h"                   // for already_AddRefed
      15             : #include "nsDebug.h"                    // for NS_ASSERTION
      16             : #include "nsISupportsImpl.h"            // for Layer::AddRef, etc
      17             : #include "nsRect.h"                     // for mozilla::gfx::IntRect
      18             : #include "nsRegion.h"                   // for nsIntRegion
      19             : #include "mozilla/gfx/PathHelpers.h"
      20             : #include "mozilla/layers/LayersMessages.h" // for GlyphArray
      21             : 
      22             : using namespace mozilla::gfx;
      23             : 
      24             : namespace mozilla {
      25             : namespace layers {
      26             : 
      27             : class BasicTextLayer : public TextLayer, public BasicImplData {
      28             : public:
      29           0 :   explicit BasicTextLayer(BasicLayerManager* aLayerManager) :
      30           0 :     TextLayer(aLayerManager, static_cast<BasicImplData*>(this))
      31             :   {
      32           0 :     MOZ_COUNT_CTOR(BasicTextLayer);
      33           0 :   }
      34             : 
      35             : protected:
      36           0 :   virtual ~BasicTextLayer()
      37           0 :   {
      38           0 :     MOZ_COUNT_DTOR(BasicTextLayer);
      39           0 :   }
      40             : 
      41             : public:
      42           0 :   virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
      43             :   {
      44           0 :     NS_ASSERTION(BasicManager()->InConstruction(),
      45             :                  "Can only set properties in construction phase");
      46           0 :     TextLayer::SetVisibleRegion(aRegion);
      47           0 :   }
      48             : 
      49           0 :   virtual void Paint(DrawTarget* aDT,
      50             :                      const gfx::Point& aDeviceOffset,
      51             :                      Layer* aMaskLayer) override
      52             :   {
      53           0 :     if (IsHidden() || !mFont) {
      54           0 :       return;
      55             :     }
      56             : 
      57           0 :     Rect snapped(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
      58           0 :     MaybeSnapToDevicePixels(snapped, *aDT, true);
      59             : 
      60             :     // We don't currently support subpixel-AA in TextLayers since we
      61             :     // don't check if there's an opaque background color behind them.
      62             :     // We should fix this before using them in production.
      63           0 :     aDT->SetPermitSubpixelAA(false);
      64             : 
      65           0 :     for (GlyphArray& g : mGlyphs) {
      66           0 :       GlyphBuffer buffer = { g.glyphs().Elements(), (uint32_t)g.glyphs().Length() };
      67           0 :       aDT->FillGlyphs(mFont, buffer, ColorPattern(g.color().value()));
      68             :     }
      69             :   }
      70             : 
      71             : protected:
      72           0 :   BasicLayerManager* BasicManager()
      73             :   {
      74           0 :     return static_cast<BasicLayerManager*>(mManager);
      75             :   }
      76             : };
      77             : 
      78             : already_AddRefed<TextLayer>
      79           0 : BasicLayerManager::CreateTextLayer()
      80             : {
      81           0 :   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
      82           0 :   RefPtr<TextLayer> layer = new BasicTextLayer(this);
      83           0 :   return layer.forget();
      84             : }
      85             : 
      86             : } // namespace layers
      87             : } // namespace mozilla

Generated by: LCOV version 1.13