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

Side by Side Diff: blimp/client/feature/compositor/blimp_client_picture_cache_unittest.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, 5 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 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/client/feature/compositor/blimp_client_picture_cache.h"
6
7 #include <stdint.h>
8 #include <memory>
9 #include <vector>
10
11 #include "blimp/test/support/compositor/picture_cache_test_support.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/skia/include/core/SkColor.h"
14 #include "third_party/skia/include/core/SkPicture.h"
15 #include "third_party/skia/include/core/SkRefCnt.h"
16
17 namespace blimp {
18 namespace client {
19 namespace {
20
21 bool FakeImageDecoder(const void* input, size_t input_size, SkBitmap* bitmap) {
22 return true;
23 }
24
25 class BlimpClientPictureCacheTest : public testing::Test {
26 public:
27 BlimpClientPictureCacheTest() : cache_(&FakeImageDecoder) {}
28 ~BlimpClientPictureCacheTest() override = default;
29
30 protected:
31 BlimpClientPictureCache cache_;
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCacheTest);
35 };
36
37 TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) {
38 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
39 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
40 cc::PictureData picture1_data = CreatePictureData(picture1);
41 cc::PictureData picture2_data = CreatePictureData(picture2);
42
43 std::vector<cc::PictureData> cache_update;
44 cache_update.push_back(picture1_data);
45 cache_update.push_back(picture2_data);
46
47 cache_.ApplyCacheUpdate(cache_update);
48
49 cache_.MarkUsed(picture1->uniqueID());
50 cache_.MarkUsed(picture2->uniqueID());
51
52 sk_sp<const SkPicture> cached_picture1 =
53 cache_.GetPicture(picture1->uniqueID());
54 EXPECT_NE(nullptr, cached_picture1);
55 EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1));
56 sk_sp<const SkPicture> cached_picture2 =
57 cache_.GetPicture(picture2->uniqueID());
58 EXPECT_NE(nullptr, cached_picture2);
59 EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2));
60
61 cache_.Flush();
62 }
63
64 } // namespace
65 } // namespace client
66 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/feature/compositor/blimp_client_picture_cache.cc ('k') | blimp/client/feature/compositor/blimp_image_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698