summaryrefslogtreecommitdiffstats
path: root/printing/metafile_skia_wrapper.h
blob: fdf5f751f1ae74e13a6d4251c997b61e102e1d82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PRINTING_METAFILE_SKIA_WRAPPER_H_
#define PRINTING_METAFILE_SKIA_WRAPPER_H_

#include "printing/printing_export.h"
#include "third_party/skia/include/core/SkRefCnt.h"

class SkCanvas;

namespace printing {

class PdfMetafileSkia;

// A wrapper class with static methods to set and retrieve a PdfMetafileSkia
// on an SkCanvas.  The ownership of the metafile is not affected and it
// is the caller's responsibility to ensure that the metafile remains valid
// as long as the canvas.
class PRINTING_EXPORT MetafileSkiaWrapper : public SkRefCnt {
 public:
  static void SetMetafileOnCanvas(const SkCanvas& canvas,
                                  PdfMetafileSkia* metafile);

  static PdfMetafileSkia* GetMetafileFromCanvas(const SkCanvas& canvas);

  // Methods to set and retrieve custom scale factor for metafile from canvas.
  static void SetCustomScaleOnCanvas(const SkCanvas& canvas, double scale);
  static bool GetCustomScaleOnCanvas(const SkCanvas& canvas, double* scale);

 private:
  explicit MetafileSkiaWrapper(PdfMetafileSkia* metafile);

  PdfMetafileSkia* metafile_;
};

}  // namespace printing

#endif  // PRINTING_METAFILE_SKIA_WRAPPER_H_