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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       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 "PrintTargetThebes.h"
       7             : 
       8             : #include "gfxASurface.h"
       9             : #include "gfxPlatform.h"
      10             : #include "mozilla/gfx/Logging.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace gfx {
      14             : 
      15             : /* static */ already_AddRefed<PrintTargetThebes>
      16           0 : PrintTargetThebes::CreateOrNull(gfxASurface* aSurface)
      17             : {
      18           0 :   MOZ_ASSERT(aSurface);
      19             : 
      20           0 :   if (!aSurface || aSurface->CairoStatus()) {
      21           0 :     return nullptr;
      22             :   }
      23             : 
      24           0 :   RefPtr<PrintTargetThebes> target = new PrintTargetThebes(aSurface);
      25             : 
      26           0 :   return target.forget();
      27             : }
      28             : 
      29           0 : PrintTargetThebes::PrintTargetThebes(gfxASurface* aSurface)
      30           0 :   : PrintTarget(nullptr, aSurface->GetSize())
      31           0 :   , mGfxSurface(aSurface)
      32             : {
      33           0 : }
      34             : 
      35             : already_AddRefed<DrawTarget>
      36           0 : PrintTargetThebes::MakeDrawTarget(const IntSize& aSize,
      37             :                                   DrawEventRecorder* aRecorder)
      38             : {
      39             :   // This should not be called outside of BeginPage()/EndPage() calls since
      40             :   // some backends can only provide a valid DrawTarget at that time.
      41           0 :   MOZ_ASSERT(mHasActivePage, "We can't guarantee a valid DrawTarget");
      42             : 
      43             :   RefPtr<gfx::DrawTarget> dt =
      44           0 :     gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mGfxSurface, aSize);
      45           0 :   if (!dt || !dt->IsValid()) {
      46           0 :     return nullptr;
      47             :   }
      48             : 
      49           0 :   if (aRecorder) {
      50           0 :     dt = CreateWrapAndRecordDrawTarget(aRecorder, dt);
      51           0 :     if (!dt || !dt->IsValid()) {
      52           0 :       return nullptr;
      53             :     }
      54             :   }
      55             : 
      56           0 :   return dt.forget();
      57             : }
      58             : 
      59             : already_AddRefed<DrawTarget>
      60           0 : PrintTargetThebes::GetReferenceDrawTarget(DrawEventRecorder* aRecorder)
      61             : {
      62           0 :   if (!mRefDT) {
      63             :     RefPtr<gfx::DrawTarget> dt =
      64           0 :       gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mGfxSurface, mSize);
      65           0 :     if (!dt || !dt->IsValid()) {
      66           0 :       return nullptr;
      67             :     }
      68           0 :     mRefDT = dt->CreateSimilarDrawTarget(IntSize(1,1), dt->GetFormat());
      69             :   }
      70             : 
      71           0 :   if (aRecorder) {
      72           0 :     if (!mRecordingRefDT) {
      73           0 :       RefPtr<DrawTarget> dt = CreateWrapAndRecordDrawTarget(aRecorder, mRefDT);
      74           0 :       if (!dt || !dt->IsValid()) {
      75           0 :         return nullptr;
      76             :       }
      77           0 :       mRecordingRefDT = dt.forget();
      78             : #ifdef DEBUG
      79           0 :       mRecorder = aRecorder;
      80             : #endif
      81             :     }
      82             : #ifdef DEBUG
      83             :     else {
      84           0 :       MOZ_ASSERT(aRecorder == mRecorder,
      85             :                  "Caching mRecordingRefDT assumes the aRecorder is an invariant");
      86             :     }
      87             : #endif
      88             : 
      89           0 :     return do_AddRef(mRecordingRefDT);
      90             :   }
      91             : 
      92           0 :   return do_AddRef(mRefDT);
      93             : }
      94             : 
      95             : nsresult
      96           0 : PrintTargetThebes::BeginPrinting(const nsAString& aTitle,
      97             :                                  const nsAString& aPrintToFileName,
      98             :                                  int32_t aStartPage,
      99             :                                  int32_t aEndPage)
     100             : {
     101           0 :   return mGfxSurface->BeginPrinting(aTitle, aPrintToFileName);
     102             : }
     103             : 
     104             : nsresult
     105           0 : PrintTargetThebes::EndPrinting()
     106             : {
     107           0 :   return mGfxSurface->EndPrinting();
     108             : }
     109             : 
     110             : nsresult
     111           0 : PrintTargetThebes::AbortPrinting()
     112             : {
     113             : #ifdef DEBUG
     114           0 :   mHasActivePage = false;
     115             : #endif
     116           0 :   return mGfxSurface->AbortPrinting();
     117             : }
     118             : 
     119             : nsresult
     120           0 : PrintTargetThebes::BeginPage()
     121             : {
     122             : #ifdef DEBUG
     123           0 :   mHasActivePage = true;
     124             : #endif
     125           0 :   return mGfxSurface->BeginPage();
     126             : }
     127             : 
     128             : nsresult
     129           0 : PrintTargetThebes::EndPage()
     130             : {
     131             : #ifdef DEBUG
     132           0 :   mHasActivePage = false;
     133             : #endif
     134           0 :   return mGfxSurface->EndPage();
     135             : }
     136             : 
     137             : void
     138           0 : PrintTargetThebes::Finish()
     139             : {
     140           0 :   return mGfxSurface->Finish();
     141             : }
     142             : 
     143             : } // namespace gfx
     144             : } // namespace mozilla

Generated by: LCOV version 1.13