Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
core
SkDescriptor.h
Go to the documentation of this file.
1
/*
2
* Copyright 2006 The Android Open Source Project
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 SkDescriptor_DEFINED
9
#define SkDescriptor_DEFINED
10
11
#include "
include/core/SkString.h
"
12
#include "
include/private/base/SkAssert.h
"
13
#include "
include/private/base/SkNoncopyable.h
"
14
#include "
src/core/SkScalerContext.h
"
15
16
#include <cstddef>
17
#include <cstdint>
18
#include <memory>
19
#include <optional>
20
21
class
SkReadBuffer
;
22
class
SkWriteBuffer
;
23
24
class
SkDescriptor
:
SkNoncopyable
{
25
public
:
26
static
size_t
ComputeOverhead
(
int
entryCount) {
27
SkASSERT
(entryCount >= 0);
28
return
sizeof
(
SkDescriptor
) + entryCount *
sizeof
(
Entry
);
29
}
30
31
static
std::unique_ptr<SkDescriptor>
Alloc
(
size_t
length
);
32
33
//
34
// Ensure the unsized delete is called.
35
void
operator
delete
(
void
* p);
36
void
*
operator
new
(size_t);
37
void
*
operator
new
(size_t,
void
* p) {
return
p; }
38
39
void
flatten
(
SkWriteBuffer
&
buffer
)
const
;
40
41
uint32_t
getLength
()
const
{
return
fLength; }
42
void
*
addEntry
(uint32_t tag,
size_t
length
,
const
void
* data =
nullptr
);
43
void
computeChecksum
();
44
45
// Assumes that getLength <= capacity of this SkDescriptor.
46
bool
isValid
()
const
;
47
48
#ifdef SK_DEBUG
49
void
assertChecksum()
const
{
50
SkASSERT
(SkDescriptor::ComputeChecksum(
this
) == fChecksum);
51
}
52
#endif
53
54
const
void
*
findEntry
(uint32_t tag, uint32_t*
length
)
const
;
55
56
std::unique_ptr<SkDescriptor>
copy
()
const
;
57
58
// This assumes that all memory added has a length that is a multiple of 4. This is checked
59
// by the assert in addEntry.
60
bool
operator==
(
const
SkDescriptor
& other)
const
;
61
bool
operator!=
(
const
SkDescriptor
& other)
const
{
return
!(*
this
== other); }
62
63
uint32_t
getChecksum
()
const
{
return
fChecksum; }
64
65
struct
Entry
{
66
uint32_t
fTag
;
67
uint32_t
fLen
;
68
};
69
70
uint32_t
getCount
()
const
{
return
fCount; }
71
72
SkString
dumpRec
()
const
;
73
74
private
:
75
SkDescriptor
() =
default
;
76
friend
class
SkDescriptorTestHelper
;
77
friend
class
SkAutoDescriptor
;
78
79
static
uint32_t ComputeChecksum(
const
SkDescriptor
* desc);
80
81
uint32_t fChecksum{0};
// must be first
82
uint32_t fLength{
sizeof
(
SkDescriptor
)};
// must be second
83
uint32_t fCount{0};
84
};
85
86
class
SkAutoDescriptor
{
87
public
:
88
SkAutoDescriptor
();
89
explicit
SkAutoDescriptor
(
size_t
size);
90
explicit
SkAutoDescriptor
(
const
SkDescriptor
&);
91
SkAutoDescriptor
(
const
SkAutoDescriptor
&);
92
SkAutoDescriptor
&
operator=
(
const
SkAutoDescriptor
&);
93
SkAutoDescriptor
(
SkAutoDescriptor
&&);
94
SkAutoDescriptor
&
operator=
(
SkAutoDescriptor
&&);
95
~SkAutoDescriptor
();
96
97
// Returns no value if there is an error.
98
static
std::optional<SkAutoDescriptor>
MakeFromBuffer
(
SkReadBuffer
&
buffer
);
99
100
void
reset
(
size_t
size);
101
void
reset
(
const
SkDescriptor
& desc);
102
SkDescriptor
*
getDesc
()
const
{
SkASSERT
(fDesc);
return
fDesc; }
103
104
private
:
105
void
free();
106
static
constexpr
size_t
kStorageSize
107
=
sizeof
(
SkDescriptor
)
108
+
sizeof
(
SkDescriptor::Entry
) +
sizeof
(
SkScalerContextRec
)
// for rec
109
+
sizeof
(
SkDescriptor::Entry
) +
sizeof
(
void
*)
// for typeface
110
+ 32;
// slop for occasional small extras
111
112
SkDescriptor
* fDesc{
nullptr
};
113
alignas
(uint32_t)
char
fStorage[kStorageSize];
114
};
115
116
#endif
//SkDescriptor_DEFINED
reset
m reset()
SkAssert.h
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkNoncopyable.h
SkScalerContext.h
SkString.h
SkAutoDescriptor
Definition
SkDescriptor.h:86
SkAutoDescriptor::~SkAutoDescriptor
~SkAutoDescriptor()
Definition
SkDescriptor.cpp:173
SkAutoDescriptor::operator=
SkAutoDescriptor & operator=(const SkAutoDescriptor &)
Definition
SkDescriptor.cpp:150
SkAutoDescriptor::SkAutoDescriptor
SkAutoDescriptor()
SkAutoDescriptor::getDesc
SkDescriptor * getDesc() const
Definition
SkDescriptor.h:102
SkAutoDescriptor::MakeFromBuffer
static std::optional< SkAutoDescriptor > MakeFromBuffer(SkReadBuffer &buffer)
Definition
SkDescriptor.cpp:175
SkDescriptorTestHelper
Definition
DescriptorTest.cpp:22
SkDescriptor
Definition
SkDescriptor.h:24
SkDescriptor::addEntry
void * addEntry(uint32_t tag, size_t length, const void *data=nullptr)
Definition
SkDescriptor.cpp:35
SkDescriptor::flatten
void flatten(SkWriteBuffer &buffer) const
Definition
SkDescriptor.cpp:31
SkDescriptor::Alloc
static std::unique_ptr< SkDescriptor > Alloc(size_t length)
Definition
SkDescriptor.cpp:20
SkDescriptor::copy
std::unique_ptr< SkDescriptor > copy() const
Definition
SkDescriptor.cpp:72
SkDescriptor::getChecksum
uint32_t getChecksum() const
Definition
SkDescriptor.h:63
SkDescriptor::computeChecksum
void computeChecksum()
Definition
SkDescriptor.cpp:52
SkDescriptor::getLength
uint32_t getLength() const
Definition
SkDescriptor.h:41
SkDescriptor::dumpRec
SkString dumpRec() const
Definition
SkDescriptor.cpp:93
SkDescriptor::ComputeOverhead
static size_t ComputeOverhead(int entryCount)
Definition
SkDescriptor.h:26
SkDescriptor::operator!=
bool operator!=(const SkDescriptor &other) const
Definition
SkDescriptor.h:61
SkDescriptor::isValid
bool isValid() const
Definition
SkDescriptor.cpp:111
SkDescriptor::findEntry
const void * findEntry(uint32_t tag, uint32_t *length) const
Definition
SkDescriptor.cpp:56
SkDescriptor::operator==
bool operator==(const SkDescriptor &other) const
Definition
SkDescriptor.cpp:78
SkDescriptor::getCount
uint32_t getCount() const
Definition
SkDescriptor.h:70
SkNoncopyable
Definition
SkNoncopyable.h:18
SkReadBuffer
Definition
SkReadBuffer.h:52
SkString
Definition
SkString.h:118
SkWriteBuffer
Definition
SkWriteBuffer.h:41
buffer
static const uint8_t buffer[]
Definition
fl_pixel_buffer_texture_test.cc:44
length
size_t length
Definition
key_event_handler.cc:41
SkDescriptor::Entry
Definition
SkDescriptor.h:65
SkDescriptor::Entry::fLen
uint32_t fLen
Definition
SkDescriptor.h:67
SkDescriptor::Entry::fTag
uint32_t fTag
Definition
SkDescriptor.h:66
SkScalerContextRec
Definition
SkScalerContext.h:61
Generated on Fri Apr 26 2024 06:16:42 for Flutter Engine by
1.9.8