| Index: cc/proto/picture_data_conversions.cc
|
| diff --git a/cc/proto/picture_data_conversions.cc b/cc/proto/picture_data_conversions.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c56b54ecc03659718774f33f6eb7175f649bab9d
|
| --- /dev/null
|
| +++ b/cc/proto/picture_data_conversions.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2016 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.
|
| +
|
| +#include "cc/proto/picture_data_conversions.h"
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/memory/ptr_util.h"
|
| +#include "cc/proto/display_item.pb.h"
|
| +#include "cc/proto/layer_tree_host.pb.h"
|
| +
|
| +namespace cc {
|
| +namespace proto {
|
| +
|
| +void PictureDataVectorToSkPicturesProto(
|
| + const std::vector<PictureData>& cache_update,
|
| + SkPictures* proto_pictures) {
|
| + for (const PictureData& picture : cache_update) {
|
| + proto::SkPictureData* picture_data = proto_pictures->add_pictures();
|
| + proto::SkPictureID* picture_id = picture_data->mutable_id();
|
| + picture_id->set_unique_id(picture.unique_id);
|
| + picture_data->set_payload(picture.data->data(), picture.data->size());
|
| + }
|
| +}
|
| +
|
| +std::vector<PictureData> SkPicturesProtoToPictureDataVector(
|
| + const SkPictures& proto_pictures) {
|
| + std::vector<PictureData> result;
|
| + for (int i = 0; i < proto_pictures.pictures_size(); ++i) {
|
| + SkPictureData proto_picture = proto_pictures.pictures(i);
|
| + DCHECK(proto_picture.has_id());
|
| + DCHECK(proto_picture.id().has_unique_id());
|
| + DCHECK(proto_picture.has_payload());
|
| + PictureData picture_data(
|
| + proto_picture.id().unique_id(),
|
| + SkData::MakeWithCopy(proto_picture.payload().data(),
|
| + proto_picture.payload().size()));
|
| + result.push_back(picture_data);
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +} // namespace proto
|
| +} // namespace cc
|
|
|