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

Side by Side Diff: cc/blimp/picture_data_conversions.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from vmpstr, including adding //cc/blimp 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
« no previous file with comments | « cc/blimp/picture_data_conversions.h ('k') | cc/blimp/picture_data_conversions_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « cc/blimp/picture_data_conversions.h ('k') | cc/blimp/picture_data_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698