skottie_transfer_cache_entry.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2020 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. #ifndef CC_PAINT_SKOTTIE_TRANSFER_CACHE_ENTRY_H_
  5. #define CC_PAINT_SKOTTIE_TRANSFER_CACHE_ENTRY_H_
  6. #include "base/containers/span.h"
  7. #include "base/memory/ref_counted_memory.h"
  8. #include "cc/paint/transfer_cache_entry.h"
  9. namespace cc {
  10. class SkottieWrapper;
  11. // Client/ServiceSkottieTransferCacheEntry implements a transfer cache entry
  12. // for transferring skottie data.
  13. class CC_PAINT_EXPORT ClientSkottieTransferCacheEntry final
  14. : public ClientTransferCacheEntryBase<TransferCacheEntryType::kSkottie> {
  15. public:
  16. explicit ClientSkottieTransferCacheEntry(
  17. scoped_refptr<SkottieWrapper> skottie);
  18. ~ClientSkottieTransferCacheEntry() final;
  19. uint32_t Id() const final;
  20. // ClientTransferCacheEntry implementation:
  21. uint32_t SerializedSize() const final;
  22. bool Serialize(base::span<uint8_t> data) const final;
  23. private:
  24. scoped_refptr<SkottieWrapper> skottie_;
  25. };
  26. class CC_PAINT_EXPORT ServiceSkottieTransferCacheEntry final
  27. : public ServiceTransferCacheEntryBase<TransferCacheEntryType::kSkottie> {
  28. public:
  29. ServiceSkottieTransferCacheEntry();
  30. ~ServiceSkottieTransferCacheEntry() final;
  31. // ServiceTransferCacheEntry implementation:
  32. size_t CachedSize() const final;
  33. bool Deserialize(GrDirectContext* context,
  34. base::span<const uint8_t> data) final;
  35. const scoped_refptr<SkottieWrapper>& skottie() const { return skottie_; }
  36. private:
  37. scoped_refptr<SkottieWrapper> skottie_;
  38. uint32_t cached_size_ = 0;
  39. };
  40. } // namespace cc
  41. #endif // CC_PAINT_SKOTTIE_TRANSFER_CACHE_ENTRY_H_