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

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: Fix non-existing SkPicture::uniqueID() when dealing with display items without SkPictures Created 4 years, 7 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 <map>
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "blimp/common/compositor/blimp_picture_cache_registry.h"
14 #include "cc/proto/picture_cache.h"
15 #include "third_party/skia/include/core/SkPicture.h"
16 #include "third_party/skia/include/core/SkRefCnt.h"
17
18 namespace blimp {
19 namespace client {
20
21 // BlimpClientPictureCache provides functionality for caching SkPictures once
22 // they are received from the engine, and cleaning up once the pictures are no
23 // longer in use. It is required to update this cache when an SkPicture starts
24 // being used and when it is not longer in use by calling
25 // MarkPictureForRegistration and MarkPictureForUnregistration respectively.
26 class BlimpClientPictureCache : public cc::ClientPictureCache {
27 public:
28 explicit BlimpClientPictureCache(
29 SkPicture::InstallPixelRefProc pixel_deserializer);
30 ~BlimpClientPictureCache() override;
31
32 // cc::ClientPictureCache implementation.
33 sk_sp<const SkPicture> GetPicture(uint32_t engine_picture_id) override;
34 void ApplyCacheUpdate(const cc::PictureCacheUpdate& cache_update) override;
35 void Flush() override;
36 void MarkPictureForUnregistration(uint32_t engine_picture_id) override;
37 void MarkPictureForRegistration(uint32_t engine_picture_id) override;
38
39 private:
40 // Helper function to deserialize the content of |picture_data| into an
41 // SkPicture.
42 sk_sp<SkPicture> DeserializePicture(const cc::PictureData& picture_data);
vmpstr 2016/05/25 01:54:06 This should be in .cc anonymous block (and take pi
nyquist 2016/05/26 01:08:09 Done.
43
44 // A function pointer valid to use for deserializing images when
45 // using SkPicture::CreateFromStream to create an SkPicture from a stream.
46 SkPicture::InstallPixelRefProc pixel_deserializer_;
47
48 // The current cache of SkPictures. The key is the unique ID used by the
49 // engine, and the value is the SkPicture itself.
50 std::map<uint32_t, sk_sp<SkPicture>> pictures_;
51
52 // A ref-counted registry of SkPictures that are currently in use.
53 BlimpPictureCacheRegistry registry_;
54
55 // A set of the items that were added when the last cache update was applied.
56 // Used for verifying that the calculation from the registry matches the
57 // expectations.
58 std::set<uint32_t> last_added_;
59
60 DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCache);
61 };
62
63 } // namespace client
64 } // namespace blimp
65
66 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_CLIENT_PICTURE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698