Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SmallPathShapeData.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SmallPathShapeData_DEFINED
9#define SmallPathShapeData_DEFINED
10
11#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
12
13#include "src/core/SkChecksum.h"
15
16class GrStyledShape;
17
18namespace skgpu::ganesh {
19
21public:
22 // TODO: add a move variant
24 fKey.reset(that.fKey.count());
25 memcpy(fKey.get(), that.fKey.get(), fKey.count() * sizeof(uint32_t));
26 }
27
29
30 // for SDF paths
31 SmallPathShapeDataKey(const GrStyledShape&, uint32_t dim);
32
33 // for bitmap paths
35
36 bool operator==(const SmallPathShapeDataKey & that) const {
37 return fKey.count() == that.fKey.count() &&
38 0 == memcmp(fKey.get(), that.fKey.get(), sizeof(uint32_t) * fKey.count());
39 }
40
41 int count32() const { return fKey.count(); }
42 const uint32_t* data() const { return fKey.get(); }
43
44private:
45 // The key is composed of the GrStyledShape's key, and either the dimensions of the DF
46 // generated for the path (32x32 max, 64x64 max, 128x128 max) if an SDF image or
47 // the matrix for the path with only fractional translation.
49};
50
52public:
54
58
60
61 static inline const SmallPathShapeDataKey& GetKey(const SmallPathShapeData& data) {
62 return data.fKey;
63 }
64
65 static inline uint32_t Hash(const SmallPathShapeDataKey& key) {
66 return SkChecksum::Hash32(key.data(), sizeof(uint32_t) * key.count32());
67 }
68};
69
70} // namespace skgpu::ganesh
71
72#endif // SK_ENABLE_OPTIMIZE_SIZE
73
74#endif // SmallPathShapeData_DEFINED
bool operator==(const SmallPathShapeDataKey &that) const
SmallPathShapeDataKey & operator=(const SmallPathShapeDataKey &)=delete
SmallPathShapeDataKey(const SmallPathShapeDataKey &that)
static uint32_t Hash(const SmallPathShapeDataKey &key)
SK_DECLARE_INTERNAL_LLIST_INTERFACE(SmallPathShapeData)
static const SmallPathShapeDataKey & GetKey(const SmallPathShapeData &data)
SmallPathShapeData(const SmallPathShapeDataKey &key)
const SmallPathShapeDataKey fKey
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)