forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraw_memory_transfer_cache_entry.cc
53 lines (40 loc) · 1.42 KB
/
raw_memory_transfer_cache_entry.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/paint/raw_memory_transfer_cache_entry.h"
#include <string.h>
namespace cc {
ClientRawMemoryTransferCacheEntry::ClientRawMemoryTransferCacheEntry(
std::vector<uint8_t> data)
: id_(s_next_id_.GetNext()), data_(std::move(data)) {}
ClientRawMemoryTransferCacheEntry::~ClientRawMemoryTransferCacheEntry() =
default;
// static
base::AtomicSequenceNumber ClientRawMemoryTransferCacheEntry::s_next_id_;
size_t ClientRawMemoryTransferCacheEntry::SerializedSize() const {
return data_.size();
}
uint32_t ClientRawMemoryTransferCacheEntry::Id() const {
return id_;
}
bool ClientRawMemoryTransferCacheEntry::Serialize(
base::span<uint8_t> data) const {
if (data.size() != data_.size())
return false;
memcpy(data.data(), data_.data(), data.size());
return true;
}
ServiceRawMemoryTransferCacheEntry::ServiceRawMemoryTransferCacheEntry() =
default;
ServiceRawMemoryTransferCacheEntry::~ServiceRawMemoryTransferCacheEntry() =
default;
size_t ServiceRawMemoryTransferCacheEntry::CachedSize() const {
return data_.size();
}
bool ServiceRawMemoryTransferCacheEntry::Deserialize(
GrContext* context,
base::span<const uint8_t> data) {
data_ = std::vector<uint8_t>(data.begin(), data.end());
return true;
}
} // namespace cc