#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:
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;
}
bool ServiceTransferCacheEntry::UsesGrContext(TransferCacheEntryType type) {
switch (type) {
case TransferCacheEntryType::kRawMemory:
case TransferCacheEntryType::kShader:
case TransferCacheEntryType::kSkottie:
return false;
case TransferCacheEntryType::kImage:
return true;
}
NOTREACHED();
return true;
}
}