Chromium Code Reviews| Index: cc/proto/picture_cache.h |
| diff --git a/cc/proto/picture_cache.h b/cc/proto/picture_cache.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d72aa68e03b735b1b6d66f67234a04dd2da70f8d |
| --- /dev/null |
| +++ b/cc/proto/picture_cache.h |
| @@ -0,0 +1,81 @@ |
| +// 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
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_PROTO_PICTURE_CACHE_H_ |
| +#define CC_PROTO_PICTURE_CACHE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/memory/ptr_util.h" |
| +#include "cc/base/cc_export.h" |
| +#include "third_party/skia/include/core/SkData.h" |
| +#include "third_party/skia/include/core/SkRefCnt.h" |
| + |
| +class SkPicture; |
| + |
| +namespace cc { |
| + |
| +// PictureData is a holder object for a serialized SkPicture and its unique ID. |
| +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.
|
| + 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
|
| + PictureData(const PictureData& other); |
| + ~PictureData(); |
| + |
| + uint32_t unique_id; |
| + sk_sp<SkData> data; |
| +}; |
| + |
| +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.
|
| + |
| +// EnginePictureCache provides functionaltiy for marking when SkPictures are in |
| +// use an when they stop being in use. Based on this, a PictureCacheUpdate can |
| +// be retrieved that includes all the new items since last time it was called. |
| +// This PictureCacheUpdate is then supposed to be sent to the client. |
| +class EnginePictureCache { |
| + public: |
| + virtual ~EnginePictureCache() {} |
| + |
| + // These methods must be called when an SkPicture is referenced and when it |
| + // is no longer referenced. |
| + virtual void MarkPictureForUnregistration(const SkPicture* picture) = 0; |
| + virtual void MarkPictureForRegistration(const SkPicture* picture) = 0; |
| + |
| + // Called when a PictureCacheUpdate is going to be sent to the client. This |
| + // must contain all the new SkPictures that are in use since last call. |
| + virtual PictureCacheUpdate CalculateCacheUpdateAndFlush() = 0; |
| +}; |
| + |
| +// ClientPictureCache provides functionaltiy for marking when SkPictures are in |
| +// use an when they stop being in use. PictureCacheUpdates are provided |
| +// with all new SkPictures that a client needs and the respective unique IDs |
| +// used on the engine. The SkPictures are kept in memory until they are no |
| +// longer in use. |
| +class ClientPictureCache { |
| + public: |
| + virtual ~ClientPictureCache() {} |
| + |
| + // These methods must be called when an SkPicture is referenced and when it |
| + // is no longer referenced. It is required that the provided ID is the same as |
| + // the unique ID that is given through the cache update. |
| + virtual void MarkPictureForUnregistration(uint32_t engine_picture_id) = 0; |
| + virtual void MarkPictureForRegistration(uint32_t engine_picture_id) = 0; |
| + |
| + // Retrieves an SkPicture from the in-memory cache. It is required that the |
| + // provided ID is the same as the unique ID that is given through the cache |
| + // update. |
| + virtual sk_sp<const SkPicture> GetPicture(uint32_t engine_picture_id) = 0; |
| + |
| + // Called when a PictureCacheUpdate has been retrieved from the engine. This |
| + // must contain all the new SkPictures that are in use. |
| + virtual void ApplyCacheUpdate(const PictureCacheUpdate& pictures) = 0; |
| + |
| + // Flushes the current state of the cache, removing unused SkPictures. Must be |
| + // called after deserialization is finished. |
| + virtual void Flush() = 0; |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_PROTO_PICTURE_CACHE_H_ |