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

Side by Side Diff: blimp/test/support/compositor/picture_cache_test_support.cc

Issue 2626423004: Remove all //blimp code. (Closed)
Patch Set: One last(?) `git merge` for good measure. 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 | « blimp/test/support/compositor/picture_cache_test_support.h ('k') | blimp/tools/Dockerfile.base » ('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 "blimp/test/support/compositor/picture_cache_test_support.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "blimp/common/blob_cache/blob_cache.h"
9 #include "blimp/common/blob_cache/id_util.h"
10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkColor.h"
12 #include "third_party/skia/include/core/SkData.h"
13 #include "third_party/skia/include/core/SkPicture.h"
14 #include "third_party/skia/include/core/SkPictureRecorder.h"
15 #include "third_party/skia/include/core/SkRefCnt.h"
16 #include "ui/gfx/geometry/point_f.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/rect_f.h"
19 #include "ui/gfx/skia_util.h"
20
21 namespace blimp {
22
23 sk_sp<const SkPicture> CreateSkPicture(SkColor color) {
24 SkPictureRecorder recorder;
25 SkCanvas* canvas = recorder.beginRecording(SkRect::MakeWH(1, 1));
26 canvas->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 BlobId GetBlobId(sk_sp<const SkPicture> picture) {
37 sk_sp<SkData> data = SerializePicture(picture);
38 return CalculateBlobId(data->data(), data->size());
39 }
40
41 sk_sp<const SkPicture> DeserializePicture(sk_sp<SkData> data) {
42 return SkPicture::MakeFromData(data.get());
43 }
44
45 bool PicturesEqual(sk_sp<const SkPicture> picture,
46 const cc::PictureData& picture_data) {
47 if (picture->uniqueID() != picture_data.unique_id) {
48 return false;
49 }
50 sk_sp<const SkPicture> deserialized_picture =
51 DeserializePicture(picture_data.data);
52 return GetBlobId(picture) == GetBlobId(deserialized_picture);
53 }
54
55 cc::PictureData CreatePictureData(sk_sp<const SkPicture> picture) {
56 return cc::PictureData(picture->uniqueID(), SerializePicture(picture));
57 }
58
59 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/test/support/compositor/picture_cache_test_support.h ('k') | blimp/tools/Dockerfile.base » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698