blob: 938c66b844a5add29a61a9bc56d3352c64c3561b [file] [log] [blame]
// Copyright 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.
#ifndef CC_PAINT_PAINT_TYPEFACE_TRANSFER_CACHE_ENTRY_H_
#define CC_PAINT_PAINT_TYPEFACE_TRANSFER_CACHE_ENTRY_H_
#include "base/containers/span.h"
#include "cc/paint/paint_export.h"
#include "cc/paint/paint_typeface.h"
#include "cc/paint/transfer_cache_entry.h"
namespace cc {
class CC_PAINT_EXPORT ClientPaintTypefaceTransferCacheEntry
: public ClientTransferCacheEntryBase<
TransferCacheEntryType::kPaintTypeface> {
public:
explicit ClientPaintTypefaceTransferCacheEntry(const PaintTypeface& typeface);
~ClientPaintTypefaceTransferCacheEntry() final;
uint32_t Id() const final;
size_t SerializedSize() const final;
bool Serialize(base::span<uint8_t> data) const final;
private:
template <typename Writer>
bool SerializeInternal(Writer* writer) const;
const PaintTypeface typeface_;
size_t size_ = 0u;
};
class CC_PAINT_EXPORT ServicePaintTypefaceTransferCacheEntry
: public ServiceTransferCacheEntryBase<
TransferCacheEntryType::kPaintTypeface> {
public:
ServicePaintTypefaceTransferCacheEntry();
~ServicePaintTypefaceTransferCacheEntry() final;
size_t CachedSize() const final;
bool Deserialize(GrContext* context, base::span<uint8_t> data) final;
const PaintTypeface& typeface() const { return typeface_; }
private:
template <typename T>
void ReadSimple(T* val);
void ReadData(size_t bytes, void* data);
PaintTypeface typeface_;
size_t size_ = 0;
bool valid_ = true;
base::span<uint8_t> data_;
};
} // namespace cc
#endif // CC_PAINT_PAINT_TYPEFACE_TRANSFER_CACHE_ENTRY_H_