raw_memory_transfer_cache_entry.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2017 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_RAW_MEMORY_TRANSFER_CACHE_ENTRY_H_
  5. #define CC_PAINT_RAW_MEMORY_TRANSFER_CACHE_ENTRY_H_
  6. #include <vector>
  7. #include "base/atomic_sequence_num.h"
  8. #include "cc/paint/transfer_cache_entry.h"
  9. namespace cc {
  10. // Client/ServiceRawMemoryTransferCacheEntry implement a transfer cache entry
  11. // backed by raw memory, with no conversion during serialization or
  12. // deserialization.
  13. class CC_PAINT_EXPORT ClientRawMemoryTransferCacheEntry final
  14. : public ClientTransferCacheEntryBase<TransferCacheEntryType::kRawMemory> {
  15. public:
  16. explicit ClientRawMemoryTransferCacheEntry(std::vector<uint8_t> data);
  17. ~ClientRawMemoryTransferCacheEntry() final;
  18. uint32_t Id() const final;
  19. uint32_t SerializedSize() const final;
  20. bool Serialize(base::span<uint8_t> data) const final;
  21. private:
  22. uint32_t id_;
  23. std::vector<uint8_t> data_;
  24. static base::AtomicSequenceNumber s_next_id_;
  25. };
  26. class CC_PAINT_EXPORT ServiceRawMemoryTransferCacheEntry final
  27. : public ServiceTransferCacheEntryBase<TransferCacheEntryType::kRawMemory> {
  28. public:
  29. ServiceRawMemoryTransferCacheEntry();
  30. ~ServiceRawMemoryTransferCacheEntry() final;
  31. size_t CachedSize() const final;
  32. bool Deserialize(GrDirectContext* context,
  33. base::span<const uint8_t> data) final;
  34. const std::vector<uint8_t>& data() { return data_; }
  35. private:
  36. std::vector<uint8_t> data_;
  37. };
  38. } // namespace cc
  39. #endif // CC_PAINT_RAW_MEMORY_TRANSFER_CACHE_ENTRY_H_