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_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ | |
| 6 #define BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <unordered_map> | |
| 10 #include <vector> | |
| 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 | |
| 17 class SkPixelSerializer; | |
| 18 | |
| 19 namespace blimp { | |
| 20 namespace engine { | |
| 21 | |
| 22 // BlimpEnginePictureCache provides functionality for caching SkPictures before | |
| 23 // they are sent from the engine to the client. The cache is cleared after | |
| 24 // every time it is flushed, but the expected state of what the client already | |
| 25 // has cached is tracked. It is required to update this cache when an SkPicture | |
| 26 // starts being used and when it is not longer in use by calling | |
| 27 // MarkPictureForRegistration and MarkPictureForUnregistration respectively. | |
|
Kevin M
2016/06/06 23:33:59
What's the lifetime of an engine picture cache?
nyquist
2016/06/10 22:02:24
Done.
| |
| 28 class BlimpEnginePictureCache : public cc::EnginePictureCache { | |
| 29 public: | |
| 30 explicit BlimpEnginePictureCache(SkPixelSerializer* pixel_serializer); | |
| 31 ~BlimpEnginePictureCache() override; | |
| 32 | |
| 33 // cc::EnginePictureCache implementation. | |
| 34 void MarkPictureForUnregistration(const SkPicture* picture) override; | |
| 35 void MarkPictureForRegistration(const SkPicture* picture) override; | |
| 36 cc::PictureCacheUpdate CalculateCacheUpdateAndFlush() override; | |
| 37 | |
| 38 private: | |
| 39 // A serializer that be used to pass in to SkPicture::serialize(...) for | |
| 40 // serializing the SkPicture to a stream. | |
| 41 SkPixelSerializer* pixel_serializer_; | |
| 42 | |
| 43 // The current cache of pictures. Cleared after every flush. | |
|
Kevin M
2016/06/06 23:33:59
What is a "flush" here?
nyquist
2016/06/10 22:02:24
Clarified comment.
| |
| 44 std::unordered_map<uint32_t, cc::PictureData> pictures_; | |
| 45 | |
| 46 // A ref-counted registry of SkPictures that are currently in use. | |
| 47 BlimpPictureCacheRegistry registry_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCache); | |
| 50 }; | |
| 51 | |
| 52 } // namespace engine | |
| 53 } // namespace blimp | |
| 54 | |
| 55 #endif // BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ | |
| OLD | NEW |