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

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

Issue 2646623002: cc: Remove all blimp code from cc. (Closed)
Patch Set: test build Created 3 years, 11 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.cc ('k') | cc/blimp/remote_compositor_bridge.h » ('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 #include <set>
9
10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h"
12 #include "cc/blimp/picture_data.h"
13 #include "cc/proto/layer_tree_host.pb.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "third_party/skia/include/core/SkColor.h"
17 #include "third_party/skia/include/core/SkData.h"
18 #include "third_party/skia/include/core/SkPicture.h"
19 #include "third_party/skia/include/core/SkPictureRecorder.h"
20 #include "third_party/skia/include/core/SkRefCnt.h"
21
22 namespace cc {
23 namespace {
24 sk_sp<const SkPicture> CreateSkPicture(SkColor color) {
25 SkPictureRecorder recorder;
26 recorder.beginRecording(SkRect::MakeWH(1, 1))->drawColor(color);
27 return recorder.finishRecordingAsPicture();
28 }
29
30 sk_sp<SkData> SerializePicture(sk_sp<const SkPicture> picture) {
31 sk_sp<SkData> data = picture->serialize();
32 DCHECK_GT(data->size(), 0u);
33 return data;
34 }
35
36 bool SamePicture(sk_sp<const SkPicture> picture,
37 const PictureData& picture_data) {
38 if (picture->uniqueID() != picture_data.unique_id)
39 return false;
40
41 sk_sp<const SkData> serialized_picture = SerializePicture(picture);
42 return picture_data.data->equals(serialized_picture.get());
43 }
44
45 PictureData CreatePictureData(sk_sp<const SkPicture> picture) {
46 return PictureData(picture->uniqueID(), SerializePicture(picture));
47 }
48
49 TEST(PictureCacheConversionsTest, SerializePictureCaheUpdate) {
50 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorRED);
51 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorBLUE);
52 std::vector<PictureData> update;
53 update.push_back(CreatePictureData(picture1));
54 update.push_back(CreatePictureData(picture2));
55
56 proto::SkPictures proto_pictures;
57 PictureDataVectorToSkPicturesProto(update, &proto_pictures);
58 ASSERT_EQ(2, proto_pictures.pictures_size());
59
60 std::vector<PictureData> deserialized =
61 SkPicturesProtoToPictureDataVector(proto_pictures);
62
63 ASSERT_EQ(2U, deserialized.size());
64 PictureData picture_data_1 = deserialized.at(0);
65 PictureData picture_data_2 = deserialized.at(1);
66 EXPECT_TRUE(SamePicture(picture1, picture_data_1));
67 EXPECT_TRUE(SamePicture(picture2, picture_data_2));
68 }
69
70 } // namespace
71 } // namespace cc
OLDNEW
« no previous file with comments | « cc/blimp/picture_data_conversions.cc ('k') | cc/blimp/remote_compositor_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698