gfx/thebes/PrintTargetThebes.h
author Jonathan Watt <jwatt@jwatt.org>
Thu, 27 Oct 2016 19:24:12 +0100
changeset 363047 bcb5f7b49427929996c0b8425cb9220f0c07e7bc
parent 342020 633b29c1f22c1ee1a9a10554581563dbc2575905
child 365423 1ceec185789fca53a2eee3dba0da59ce34ff601c
permissions -rw-r--r--
Bug 1280324, part 1 - Add functionality to the PrintTarget sub-classes to return reference DrawTargets. r=edwin

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef MOZILLA_GFX_PRINTTARGETTHEBES_H
#define MOZILLA_GFX_PRINTTARGETTHEBES_H

#include "mozilla/gfx/PrintTarget.h"

class gfxASurface;

namespace mozilla {
namespace gfx {

/**
 * XXX Remove this class.
 *
 * This class should go away once all the logic from the gfxASurface subclasses
 * has been moved to new PrintTarget subclasses and we no longer need to
 * wrap a gfxASurface.
 *
 * When removing this class, be sure to make PrintTarget::MakeDrawTarget
 * non-virtual!
 */
class PrintTargetThebes final : public PrintTarget {
public:

  static already_AddRefed<PrintTargetThebes>
  CreateOrNull(gfxASurface* aSurface);

  virtual nsresult BeginPrinting(const nsAString& aTitle,
                                 const nsAString& aPrintToFileName) override;
  virtual nsresult EndPrinting() override;
  virtual nsresult AbortPrinting() override;
  virtual nsresult BeginPage() override;
  virtual nsresult EndPage() override;
  virtual void Finish() override;

  virtual already_AddRefed<DrawTarget>
  MakeDrawTarget(const IntSize& aSize,
                 DrawEventRecorder* aRecorder = nullptr) override;

  virtual already_AddRefed<DrawTarget> GetReferenceDrawTarget() final;

private:

  // Only created via CreateOrNull
  explicit PrintTargetThebes(gfxASurface* aSurface);

  RefPtr<gfxASurface> mGfxSurface;
};

} // namespace gfx
} // namespace mozilla

#endif /* MOZILLA_GFX_PRINTTARGETTHEBES_H */