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
54
55
56
57
58
59
cc / paint / transfer_cache_entry.cc [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/paint/transfer_cache_entry.h"
#include <memory>
#include "base/notreached.h"
#include "cc/paint/image_transfer_cache_entry.h"
#include "cc/paint/raw_memory_transfer_cache_entry.h"
#include "cc/paint/shader_transfer_cache_entry.h"
#include "cc/paint/skottie_transfer_cache_entry.h"
namespace cc {
std::unique_ptr<ServiceTransferCacheEntry> ServiceTransferCacheEntry::Create(
TransferCacheEntryType type) {
switch (type) {
case TransferCacheEntryType::kRawMemory:
return std::make_unique<ServiceRawMemoryTransferCacheEntry>();
case TransferCacheEntryType::kImage:
return std::make_unique<ServiceImageTransferCacheEntry>();
case TransferCacheEntryType::kShader:
// ServiceShader/TextBlobTransferCache is only created via
// CreateLocalEntry and is never serialized/deserialized.
return nullptr;
case TransferCacheEntryType::kSkottie:
return std::make_unique<ServiceSkottieTransferCacheEntry>();
}
return nullptr;
}
bool ServiceTransferCacheEntry::SafeConvertToType(
uint32_t raw_type,
TransferCacheEntryType* type) {
if (raw_type > static_cast<uint32_t>(TransferCacheEntryType::kLast))
return false;
*type = static_cast<TransferCacheEntryType>(raw_type);
return true;
}
// static
bool ServiceTransferCacheEntry::UsesGpuContext(TransferCacheEntryType type) {
switch (type) {
case TransferCacheEntryType::kRawMemory:
case TransferCacheEntryType::kShader:
case TransferCacheEntryType::kSkottie:
return false;
case TransferCacheEntryType::kImage:
return true;
}
NOTREACHED();
}
} // namespace cc