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

Side by Side Diff: blimp/client/feature/compositor/blimp_client_picture_cache.h

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 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 #ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_CLIENT_PICTURE_CACHE_H_
6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_CLIENT_PICTURE_CACHE_H_
7
8 #include <stdint.h>
9 #include <memory>
10 #include <unordered_map>
11 #include <unordered_set>
12
13 #include "base/logging.h"
14 #include "base/macros.h"
15 #include "blimp/common/compositor/reference_tracker.h"
16 #include "cc/proto/picture_cache.h"
17 #include "third_party/skia/include/core/SkPicture.h"
18 #include "third_party/skia/include/core/SkRefCnt.h"
19
20 namespace blimp {
21 namespace client {
22
23 // BlimpClientPictureCache provides functionality for caching SkPictures once
24 // they are received from the engine, and cleaning up once the pictures are no
25 // longer in use. It is required to update this cache when an SkPicture starts
26 // being used and when it is not longer in use by calling
27 // MarkPictureForRegistration and MarkPictureForUnregistration respectively.
28 class BlimpClientPictureCache : public cc::ClientPictureCache {
vmpstr 2016/06/16 22:09:58 might need an export
nyquist 2016/06/24 11:11:14 Wouldn't that lead to some kind of compile error o
29 public:
30 explicit BlimpClientPictureCache(
31 SkPicture::InstallPixelRefProc pixel_deserializer);
32 ~BlimpClientPictureCache() override;
33
34 // cc::ClientPictureCache implementation.
35 sk_sp<const SkPicture> GetPicture(uint32_t engine_picture_id) override;
36 void ApplyCacheUpdate(const cc::PictureCacheUpdate& cache_update) override;
37 void Flush() override;
38 void MarkPictureForUnregistration(uint32_t engine_picture_id) override;
39 void MarkPictureForRegistration(uint32_t engine_picture_id) override;
40
41 private:
42 // Adds new pictures from the |cache_update| to |pictures_|.
43 void AddNewPicturesToCache(const cc::PictureCacheUpdate& cache_update);
44
45 // Removes all unusued pictures from |pictures_|.
46 void RemoveUnusedPicturesFromCache(const std::vector<uint32_t>& picture_ids);
vmpstr 2016/06/16 22:09:58 comment on what the parameter is
nyquist 2016/06/24 11:11:14 Done.
47
48 // Retrieves the SkPicture with the given |picture_id| from the cache. The
49 // given |picture_id| is the unique ID that the engine used to identify the
50 // picture in the cc::PictureCacheUpdate that contained the image.
51 sk_sp<const SkPicture> GetPictureFromCache(uint32_t picture_id);
52
53 #if DCHECK_IS_ON()
54 // Verify that the incoming cache update matches the new items that were added
55 // to the |reference_tracker_|.
56 void VerifyCacheUpdateMatchesReferenceTrackerData(
57 const std::vector<uint32_t>& new_tracked_items);
58
59 // A set of the items that were added when the last cache update was applied.
60 // Used for verifying that the calculation from the registry matches the
61 // expectations.
62 std::unordered_set<uint32_t> last_added_;
63 #endif // DCHECK_IS_ON()
64
65 // A function pointer valid to use for deserializing images when
66 // using SkPicture::CreateFromStream to create an SkPicture from a stream.
67 SkPicture::InstallPixelRefProc pixel_deserializer_;
68
69 // The current cache of SkPictures. The key is the unique ID used by the
70 // engine, and the value is the SkPicture itself.
71 std::unordered_map<uint32_t, sk_sp<const SkPicture>> pictures_;
72
73 // The reference tracker maintains the reference count of used SkPictures.
74 ReferenceTracker reference_tracker_;
75
76 DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCache);
77 };
78
79 } // namespace client
80 } // namespace blimp
81
82 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_CLIENT_PICTURE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698