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 CC_PROTO_PICTURE_CACHE_H_ |
| 6 #define CC_PROTO_PICTURE_CACHE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "cc/base/cc_export.h" |
| 13 #include "third_party/skia/include/core/SkData.h" |
| 14 #include "third_party/skia/include/core/SkRefCnt.h" |
| 15 |
| 16 class SkPicture; |
| 17 |
| 18 namespace cc { |
| 19 struct PictureData; |
| 20 |
| 21 // EnginePictureCache provides functionaltiy for marking when SkPictures are in |
| 22 // use an when they stop being in use. Based on this, a PictureCacheUpdate can |
| 23 // be retrieved that includes all the new items since last time it was called. |
| 24 // This PictureCacheUpdate is then supposed to be sent to the client. |
| 25 class EnginePictureCache { |
| 26 public: |
| 27 virtual ~EnginePictureCache() {} |
| 28 |
| 29 // MarkUsed must be called when an SkPicture needs to available on the client. |
| 30 virtual void MarkUsed(const SkPicture* picture) = 0; |
| 31 |
| 32 // Called when a PictureCacheUpdate is going to be sent to the client. This |
| 33 // must contain all the new SkPictures that are in use since last call. |
| 34 virtual std::vector<PictureData> CalculateCacheUpdateAndFlush() = 0; |
| 35 }; |
| 36 |
| 37 // ClientPictureCache provides functionaltiy for marking when SkPictures are in |
| 38 // use an when they stop being in use. PictureCacheUpdates are provided |
| 39 // with all new SkPictures that a client needs and the respective unique IDs |
| 40 // used on the engine. The SkPictures are kept in memory until they are no |
| 41 // longer in use. |
| 42 class ClientPictureCache { |
| 43 public: |
| 44 virtual ~ClientPictureCache() {} |
| 45 |
| 46 // MarkUsed must be called when the client has started using an SkPicture that |
| 47 // was sent to from the engine. |
| 48 virtual void MarkUsed(uint32_t engine_picture_id) = 0; |
| 49 |
| 50 // Retrieves an SkPicture from the in-memory cache. It is required that the |
| 51 // provided ID is the same as the unique ID that is given through the cache |
| 52 // update. |
| 53 virtual sk_sp<const SkPicture> GetPicture(uint32_t engine_picture_id) = 0; |
| 54 |
| 55 // Called when a PictureCacheUpdate has been retrieved from the engine. This |
| 56 // must contain all the new SkPictures that are in use. |
| 57 virtual void ApplyCacheUpdate(const std::vector<PictureData>& pictures) = 0; |
| 58 |
| 59 // Flushes the current state of the cache, removing unused SkPictures. Must be |
| 60 // called after deserialization is finished. |
| 61 virtual void Flush() = 0; |
| 62 }; |
| 63 |
| 64 } // namespace cc |
| 65 |
| 66 #endif // CC_PROTO_PICTURE_CACHE_H_ |
OLD | NEW |