Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
vmpstr
2016/06/16 22:09:59
Why is this defined in cc/proto? This doesn't look
nyquist
2016/06/24 11:11:14
Maybe it looks more like that now? Now it's only c
| |
| 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 | |
| 20 // PictureData is a holder object for a serialized SkPicture and its unique ID. | |
| 21 struct CC_EXPORT PictureData { | |
|
vmpstr
2016/06/16 22:09:59
Each individual struct/class should have its own f
nyquist
2016/06/24 11:11:14
Done.
| |
| 22 PictureData(); | |
|
vmpstr
2016/06/16 22:09:59
remove this have unique_id = 0 below
nyquist
2016/06/24 11:11:14
C++ yells at me because it's a complex struct (the
| |
| 23 PictureData(const PictureData& other); | |
| 24 ~PictureData(); | |
| 25 | |
| 26 uint32_t unique_id; | |
| 27 sk_sp<SkData> data; | |
| 28 }; | |
| 29 | |
| 30 using PictureCacheUpdate = std::vector<PictureData>; | |
|
vmpstr
2016/06/16 22:09:59
Maybe just use std::vector<PictureData> wherever y
nyquist
2016/06/24 11:11:14
Done.
| |
| 31 | |
| 32 // EnginePictureCache provides functionaltiy for marking when SkPictures are in | |
| 33 // use an when they stop being in use. Based on this, a PictureCacheUpdate can | |
| 34 // be retrieved that includes all the new items since last time it was called. | |
| 35 // This PictureCacheUpdate is then supposed to be sent to the client. | |
| 36 class EnginePictureCache { | |
| 37 public: | |
| 38 virtual ~EnginePictureCache() {} | |
| 39 | |
| 40 // These methods must be called when an SkPicture is referenced and when it | |
| 41 // is no longer referenced. | |
| 42 virtual void MarkPictureForUnregistration(const SkPicture* picture) = 0; | |
| 43 virtual void MarkPictureForRegistration(const SkPicture* picture) = 0; | |
| 44 | |
| 45 // Called when a PictureCacheUpdate is going to be sent to the client. This | |
| 46 // must contain all the new SkPictures that are in use since last call. | |
| 47 virtual PictureCacheUpdate CalculateCacheUpdateAndFlush() = 0; | |
| 48 }; | |
| 49 | |
| 50 // ClientPictureCache provides functionaltiy for marking when SkPictures are in | |
| 51 // use an when they stop being in use. PictureCacheUpdates are provided | |
| 52 // with all new SkPictures that a client needs and the respective unique IDs | |
| 53 // used on the engine. The SkPictures are kept in memory until they are no | |
| 54 // longer in use. | |
| 55 class ClientPictureCache { | |
| 56 public: | |
| 57 virtual ~ClientPictureCache() {} | |
| 58 | |
| 59 // These methods must be called when an SkPicture is referenced and when it | |
| 60 // is no longer referenced. It is required that the provided ID is the same as | |
| 61 // the unique ID that is given through the cache update. | |
| 62 virtual void MarkPictureForUnregistration(uint32_t engine_picture_id) = 0; | |
| 63 virtual void MarkPictureForRegistration(uint32_t engine_picture_id) = 0; | |
| 64 | |
| 65 // Retrieves an SkPicture from the in-memory cache. It is required that the | |
| 66 // provided ID is the same as the unique ID that is given through the cache | |
| 67 // update. | |
| 68 virtual sk_sp<const SkPicture> GetPicture(uint32_t engine_picture_id) = 0; | |
| 69 | |
| 70 // Called when a PictureCacheUpdate has been retrieved from the engine. This | |
| 71 // must contain all the new SkPictures that are in use. | |
| 72 virtual void ApplyCacheUpdate(const PictureCacheUpdate& pictures) = 0; | |
| 73 | |
| 74 // Flushes the current state of the cache, removing unused SkPictures. Must be | |
| 75 // called after deserialization is finished. | |
| 76 virtual void Flush() = 0; | |
| 77 }; | |
| 78 | |
| 79 } // namespace cc | |
| 80 | |
| 81 #endif // CC_PROTO_PICTURE_CACHE_H_ | |
| OLD | NEW |