LCOV - code coverage report
Current view: top level - layout/printing - PrintTranslator.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 32 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "PrintTranslator.h"
       8             : 
       9             : #include "gfxContext.h"
      10             : #include "nsDeviceContext.h"
      11             : #include "mozilla/gfx/RecordedEvent.h"
      12             : #include "mozilla/gfx/RecordingTypes.h"
      13             : #include "mozilla/UniquePtr.h"
      14             : 
      15             : using namespace mozilla::gfx;
      16             : 
      17             : namespace mozilla {
      18             : namespace layout {
      19             : 
      20           0 : PrintTranslator::PrintTranslator(nsDeviceContext* aDeviceContext)
      21           0 :   : mDeviceContext(aDeviceContext)
      22             : {
      23           0 :   RefPtr<gfxContext> context = mDeviceContext->CreateReferenceRenderingContext();
      24           0 :   mBaseDT = context->GetDrawTarget();
      25           0 : }
      26             : 
      27             : bool
      28           0 : PrintTranslator::TranslateRecording(std::istream& aRecording)
      29             : {
      30             :   uint32_t magicInt;
      31           0 :   ReadElement(aRecording, magicInt);
      32           0 :   if (magicInt != mozilla::gfx::kMagicInt) {
      33           0 :     return false;
      34             :   }
      35             : 
      36             :   uint16_t majorRevision;
      37           0 :   ReadElement(aRecording, majorRevision);
      38           0 :   if (majorRevision != kMajorRevision) {
      39           0 :     return false;
      40             :   }
      41             : 
      42             :   uint16_t minorRevision;
      43           0 :   ReadElement(aRecording, minorRevision);
      44           0 :   if (minorRevision > kMinorRevision) {
      45           0 :     return false;
      46             :   }
      47             : 
      48             :   int32_t eventType;
      49           0 :   ReadElement(aRecording, eventType);
      50           0 :   while (aRecording.good()) {
      51             :     UniquePtr<RecordedEvent> recordedEvent(
      52             :       RecordedEvent::LoadEventFromStream(aRecording,
      53           0 :       static_cast<RecordedEvent::EventType>(eventType)));
      54             : 
      55             :     // Make sure that the whole event was read from the stream successfully.
      56           0 :     if (!aRecording.good() || !recordedEvent) {
      57           0 :       return false;
      58             :     }
      59             : 
      60           0 :     if (!recordedEvent->PlayEvent(this)) {
      61           0 :       return false;
      62             :     }
      63             : 
      64           0 :     ReadElement(aRecording, eventType);
      65             :   }
      66             : 
      67           0 :   return true;
      68             : }
      69             : 
      70             : already_AddRefed<DrawTarget>
      71           0 : PrintTranslator::CreateDrawTarget(ReferencePtr aRefPtr,
      72             :                                   const gfx::IntSize &aSize,
      73             :                                   gfx::SurfaceFormat aFormat)
      74             : {
      75           0 :   RefPtr<gfxContext> context = mDeviceContext->CreateRenderingContext();
      76           0 :   if (!context) {
      77           0 :     NS_WARNING("Failed to create rendering context for print.");
      78           0 :     return nullptr;
      79             :   }
      80             : 
      81           0 :   RefPtr<DrawTarget> drawTarget = context->GetDrawTarget();
      82           0 :   AddDrawTarget(aRefPtr, drawTarget);
      83           0 :   return drawTarget.forget();
      84             : }
      85             : 
      86             : } // namespace layout
      87             : } // namespace mozilla

Generated by: LCOV version 1.13