1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PRINTING_METAFILE_SKIA_WRAPPER_H_
6#define PRINTING_METAFILE_SKIA_WRAPPER_H_
7
8#include "printing/printing_export.h"
9#include "third_party/skia/include/core/SkRefCnt.h"
10
11class SkCanvas;
12
13namespace printing {
14
15class PdfMetafileSkia;
16
17// A wrapper class with static methods to set and retrieve a PdfMetafileSkia
18// on an SkCanvas.  The ownership of the metafile is not affected and it
19// is the caller's responsibility to ensure that the metafile remains valid
20// as long as the canvas.
21class PRINTING_EXPORT MetafileSkiaWrapper : public SkRefCnt {
22 public:
23  static void SetMetafileOnCanvas(const SkCanvas& canvas,
24                                  PdfMetafileSkia* metafile);
25
26  static PdfMetafileSkia* GetMetafileFromCanvas(const SkCanvas& canvas);
27
28  // Methods to set and retrieve custom scale factor for metafile from canvas.
29  static void SetCustomScaleOnCanvas(const SkCanvas& canvas, double scale);
30  static bool GetCustomScaleOnCanvas(const SkCanvas& canvas, double* scale);
31
32 private:
33  explicit MetafileSkiaWrapper(PdfMetafileSkia* metafile);
34
35  PdfMetafileSkia* metafile_;
36};
37
38}  // namespace printing
39
40#endif  // PRINTING_METAFILE_SKIA_WRAPPER_H_
41