1 // Copyright 2017 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_COMMON_METAFILE_UTILS_H_ 6 #define PRINTING_COMMON_METAFILE_UTILS_H_ 7 8 #include <string> 9 10 #include "base/containers/flat_map.h" 11 #include "base/containers/flat_set.h" 12 #include "base/unguessable_token.h" 13 #include "skia/ext/platform_canvas.h" 14 #include "third_party/skia/include/core/SkDocument.h" 15 #include "third_party/skia/include/core/SkRefCnt.h" 16 #include "third_party/skia/include/core/SkSerialProcs.h" 17 #include "third_party/skia/include/core/SkStream.h" 18 #include "ui/accessibility/ax_tree_update_forward.h" 19 20 namespace printing { 21 22 using ContentToProxyTokenMap = base::flat_map<uint32_t, base::UnguessableToken>; 23 using ContentProxySet = base::flat_set<uint32_t>; 24 25 // Stores the mapping between a content's unique id and its actual content. 26 using PictureDeserializationContext = 27 base::flat_map<uint32_t, sk_sp<SkPicture>>; 28 using TypefaceDeserializationContext = 29 base::flat_map<uint32_t, sk_sp<SkTypeface>>; 30 31 // Stores the mapping between content's unique id and its corresponding frame 32 // proxy token. 33 using PictureSerializationContext = ContentToProxyTokenMap; 34 35 // Stores the set of typeface unique ids used by the picture frame content. 36 using TypefaceSerializationContext = ContentProxySet; 37 38 sk_sp<SkDocument> MakePdfDocument(const std::string& creator, 39 const ui::AXTreeUpdate& accessibility_tree, 40 SkWStream* stream); 41 42 SkSerialProcs SerializationProcs(PictureSerializationContext* picture_ctx, 43 TypefaceSerializationContext* typeface_ctx); 44 45 SkDeserialProcs DeserializationProcs( 46 PictureDeserializationContext* picture_ctx, 47 TypefaceDeserializationContext* typeface_ctx); 48 49 } // namespace printing 50 51 #endif // PRINTING_COMMON_METAFILE_UTILS_H_ 52