transfer_cache_serialize_helper.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 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_TRANSFER_CACHE_SERIALIZE_HELPER_H_
  5. #define CC_PAINT_TRANSFER_CACHE_SERIALIZE_HELPER_H_
  6. #include <set>
  7. #include <vector>
  8. #include "cc/paint/paint_export.h"
  9. #include "cc/paint/transfer_cache_entry.h"
  10. namespace cc {
  11. class CC_PAINT_EXPORT TransferCacheSerializeHelper {
  12. public:
  13. TransferCacheSerializeHelper();
  14. virtual ~TransferCacheSerializeHelper();
  15. bool LockEntry(TransferCacheEntryType type, uint32_t id);
  16. // The PaintOpWriter passes the address where the transfer cache may inline
  17. // this entry. The size returned is the memory used if the entry is inlined,
  18. // or 0u if no data is inlined.
  19. uint32_t CreateEntry(const ClientTransferCacheEntry& entry, char* memory);
  20. void FlushEntries();
  21. void AssertLocked(TransferCacheEntryType type, uint32_t id);
  22. protected:
  23. using EntryKey = std::pair<TransferCacheEntryType, uint32_t>;
  24. virtual bool LockEntryInternal(const EntryKey& key) = 0;
  25. virtual uint32_t CreateEntryInternal(const ClientTransferCacheEntry& entry,
  26. char* memory) = 0;
  27. virtual void FlushEntriesInternal(std::set<EntryKey> keys) = 0;
  28. private:
  29. std::set<EntryKey> added_entries_;
  30. };
  31. } // namespace cc
  32. #endif // CC_PAINT_TRANSFER_CACHE_SERIALIZE_HELPER_H_