OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 #include "cc/blimp/picture_data_conversions.h" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "base/logging.h" | |
10 #include "base/memory/ptr_util.h" | |
11 #include "cc/proto/display_item.pb.h" | |
12 #include "cc/proto/layer_tree_host.pb.h" | |
13 | |
14 namespace cc { | |
15 namespace proto { | |
16 | |
17 void PictureDataVectorToSkPicturesProto( | |
18 const std::vector<PictureData>& cache_update, | |
19 SkPictures* proto_pictures) { | |
20 for (const PictureData& picture : cache_update) { | |
21 proto::SkPictureData* picture_data = proto_pictures->add_pictures(); | |
22 proto::SkPictureID* picture_id = picture_data->mutable_id(); | |
23 picture_id->set_unique_id(picture.unique_id); | |
24 picture_data->set_payload(picture.data->data(), picture.data->size()); | |
25 } | |
26 } | |
27 | |
28 std::vector<PictureData> SkPicturesProtoToPictureDataVector( | |
29 const SkPictures& proto_pictures) { | |
30 std::vector<PictureData> result; | |
31 for (int i = 0; i < proto_pictures.pictures_size(); ++i) { | |
32 SkPictureData proto_picture = proto_pictures.pictures(i); | |
33 DCHECK(proto_picture.has_id()); | |
34 DCHECK(proto_picture.id().has_unique_id()); | |
35 DCHECK(proto_picture.has_payload()); | |
36 PictureData picture_data( | |
37 proto_picture.id().unique_id(), | |
38 SkData::MakeWithCopy(proto_picture.payload().data(), | |
39 proto_picture.payload().size())); | |
40 result.push_back(picture_data); | |
41 } | |
42 return result; | |
43 } | |
44 | |
45 } // namespace proto | |
46 } // namespace cc | |
OLD | NEW |