[M108 Migration][Loading Performance] Introduce |BeginMainFrame| throttling
[platform/framework/web/chromium-efl.git] / cc / paint / skottie_transfer_cache_entry.cc
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/paint/skottie_transfer_cache_entry.h"
6
7 #include <utility>
8
9 #include "cc/paint/skottie_wrapper.h"
10
11 namespace cc {
12
13 ClientSkottieTransferCacheEntry::ClientSkottieTransferCacheEntry(
14     scoped_refptr<SkottieWrapper> skottie)
15     : skottie_(std::move(skottie)) {}
16
17 ClientSkottieTransferCacheEntry::~ClientSkottieTransferCacheEntry() = default;
18
19 uint32_t ClientSkottieTransferCacheEntry::Id() const {
20   return skottie_->id();
21 }
22
23 uint32_t ClientSkottieTransferCacheEntry::SerializedSize() const {
24   return skottie_->raw_data().size();
25 }
26
27 bool ClientSkottieTransferCacheEntry::Serialize(
28     base::span<uint8_t> data) const {
29   DCHECK_GE(data.size(), SerializedSize());
30   memcpy(data.data(), skottie_->raw_data().data(), SerializedSize());
31   return true;
32 }
33
34 ServiceSkottieTransferCacheEntry::ServiceSkottieTransferCacheEntry() = default;
35 ServiceSkottieTransferCacheEntry::~ServiceSkottieTransferCacheEntry() = default;
36
37 size_t ServiceSkottieTransferCacheEntry::CachedSize() const {
38   return cached_size_;
39 }
40
41 bool ServiceSkottieTransferCacheEntry::Deserialize(
42     GrDirectContext* context,
43     base::span<const uint8_t> data) {
44   skottie_ = SkottieWrapper::CreateNonSerializable(data);
45   cached_size_ = data.size();
46   return skottie_->is_valid();
47 }
48
49 }  // namespace cc