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 <map> |
| 9 #include <memory> |
| 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. |
| 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 using PictureMap = std::map<uint32_t, cc::PictureData>; |
| 40 |
| 41 // A serializer that be used to pass in to SkPicture::serialize(...) for |
| 42 // serializing the SkPicture to a stream. |
| 43 SkPixelSerializer* pixel_serializer_; |
| 44 |
| 45 // The current cache of pictures. Cleared after every flush. |
| 46 PictureMap pictures_; |
| 47 |
| 48 // A ref-counted registry of SkPictures that are currently in use. |
| 49 BlimpPictureCacheRegistry registry_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCache); |
| 52 }; |
| 53 |
| 54 } // namespace engine |
| 55 } // namespace blimp |
| 56 |
| 57 #endif // BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ |
OLD | NEW |