Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: cc/proto/picture_cache_conversions.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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/proto/picture_cache_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(const PictureCacheUpdate& cache_update,
18 SkPictures* proto_pictures) {
19 for (const PictureData& picture : cache_update) {
20 proto::SkPictureData* picture_data = proto_pictures->add_pictures();
21 proto::SkPictureID* picture_id = picture_data->mutable_id();
22 picture_id->set_unique_id(picture.unique_id);
23 picture_data->set_payload(picture.data->data(), picture.data->size());
24 }
25 }
26
27 PictureCacheUpdate SkPicturesProtoToPictureDataVector(
28 const SkPictures& proto_pictures) {
29 PictureCacheUpdate result;
30 for (int i = 0; i < proto_pictures.pictures_size(); ++i) {
31 PictureData picture_data;
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 picture_data.unique_id = proto_picture.id().unique_id();
37 picture_data.data = SkData::MakeWithCopy(proto_picture.payload().data(),
38 proto_picture.payload().size());
39 result.push_back(picture_data);
40 }
41 return result;
42 }
43
44 } // namespace proto
45 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698