15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PRINTING_METAFILE_SKIA_WRAPPER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PRINTING_METAFILE_SKIA_WRAPPER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "printing/printing_export.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkRefCnt.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SkCanvas;
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace printing {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass PdfMetafileSkia;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// A wrapper class with static methods to set and retrieve a PdfMetafileSkia
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// on an SkCanvas.  The ownership of the metafile is not affected and it
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is the caller's responsibility to ensure that the metafile remains valid
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// as long as the canvas.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PRINTING_EXPORT MetafileSkiaWrapper : public SkRefCnt {
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  static void SetMetafileOnCanvas(const SkCanvas& canvas,
241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                  PdfMetafileSkia* metafile);
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  static PdfMetafileSkia* GetMetafileFromCanvas(const SkCanvas& canvas);
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Methods to set and retrieve custom scale factor for metafile from canvas.
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void SetCustomScaleOnCanvas(const SkCanvas& canvas, double scale);
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool GetCustomScaleOnCanvas(const SkCanvas& canvas, double* scale);
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  explicit MetafileSkiaWrapper(PdfMetafileSkia* metafile);
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  PdfMetafileSkia* metafile_;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace printing
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // PRINTING_METAFILE_SKIA_WRAPPER_H_
41