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