Flutter Engine
The Flutter Engine
third_party
skia
include
core
SkFlattenable.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 SkFlattenable_DEFINED
9
#define SkFlattenable_DEFINED
10
11
#include "
include/core/SkRefCnt.h
"
12
#include "
include/core/SkTypes.h
"
13
14
#include <cstddef>
15
16
class
SkData
;
17
class
SkReadBuffer
;
18
class
SkWriteBuffer
;
19
struct
SkDeserialProcs
;
20
struct
SkSerialProcs
;
21
22
/** \class SkFlattenable
23
24
SkFlattenable is the base class for objects that need to be flattened
25
into a data stream for either transport or as part of the key to the
26
font cache.
27
*/
28
class
SK_API
SkFlattenable
:
public
SkRefCnt
{
29
public
:
30
enum
Type
{
31
kSkColorFilter_Type
,
32
kSkBlender_Type
,
33
kSkDrawable_Type
,
34
kSkDrawLooper_Type
,
// no longer supported by Skia
35
kSkImageFilter_Type
,
36
kSkMaskFilter_Type
,
37
kSkPathEffect_Type
,
38
kSkShader_Type
,
39
};
40
41
typedef
sk_sp<SkFlattenable>
(*
Factory
)(
SkReadBuffer
&);
42
43
SkFlattenable
() {}
44
45
/** Implement this to return a factory function pointer that can be called
46
to recreate your class given a buffer (previously written to by your
47
override of flatten().
48
*/
49
virtual
Factory
getFactory
()
const
= 0;
50
51
/**
52
* Returns the name of the object's class.
53
*/
54
virtual
const
char
*
getTypeName
()
const
= 0;
55
56
static
Factory
NameToFactory(
const
char
name
[]);
57
static
const
char
* FactoryToName(
Factory
);
58
59
static
void
Register
(
const
char
name
[],
Factory
);
60
61
/**
62
* Override this if your subclass needs to record data that it will need to recreate itself
63
* from its CreateProc (returned by getFactory()).
64
*
65
* DEPRECATED public : will move to protected ... use serialize() instead
66
*/
67
virtual
void
flatten
(
SkWriteBuffer
&)
const
{}
68
69
virtual
Type
getFlattenableType
()
const
= 0;
70
71
//
72
// public ways to serialize / deserialize
73
//
74
sk_sp<SkData>
serialize(
const
SkSerialProcs
* =
nullptr
)
const
;
75
size_t
serialize(
void
* memory,
size_t
memory_size,
76
const
SkSerialProcs
* =
nullptr
)
const
;
77
static
sk_sp<SkFlattenable>
Deserialize(
Type
,
const
void
*
data
,
size_t
length
,
78
const
SkDeserialProcs
* procs =
nullptr
);
79
80
protected
:
81
class
PrivateInitializer
{
82
public
:
83
static
void
InitEffects();
84
static
void
InitImageFilters();
85
};
86
87
private
:
88
static
void
RegisterFlattenablesIfNeeded();
89
static
void
Finalize();
90
91
friend
class
SkGraphics
;
92
93
using
INHERITED
=
SkRefCnt
;
94
};
95
96
#if defined(SK_DISABLE_EFFECT_DESERIALIZATION)
97
#define SK_REGISTER_FLATTENABLE(type) do{}while(false)
98
99
#define SK_FLATTENABLE_HOOKS(type) \
100
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
101
friend class SkFlattenable::PrivateInitializer; \
102
Factory getFactory() const override { return nullptr; } \
103
const char* getTypeName() const override { return #type; }
104
#else
105
#define SK_REGISTER_FLATTENABLE(type) \
106
SkFlattenable::Register(#type, type::CreateProc)
107
108
#define SK_FLATTENABLE_HOOKS(type) \
109
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
110
friend class SkFlattenable::PrivateInitializer; \
111
Factory getFactory() const override { return type::CreateProc; } \
112
const char* getTypeName() const override { return #type; }
113
#endif
114
115
#endif
SK_API
#define SK_API
Definition:
SkAPI.h:35
SkRefCnt.h
SkTypes.h
SkData
Definition:
SkData.h:25
SkFlattenable::PrivateInitializer
Definition:
SkFlattenable.h:81
SkFlattenable
Definition:
SkFlattenable.h:28
SkFlattenable::flatten
virtual void flatten(SkWriteBuffer &) const
Definition:
SkFlattenable.h:67
SkFlattenable::getFlattenableType
virtual Type getFlattenableType() const =0
SkFlattenable::SkFlattenable
SkFlattenable()
Definition:
SkFlattenable.h:43
SkFlattenable::getTypeName
virtual const char * getTypeName() const =0
SkFlattenable::kSkDrawable_Type
@ kSkDrawable_Type
Definition:
SkFlattenable.h:33
SkFlattenable::kSkPathEffect_Type
@ kSkPathEffect_Type
Definition:
SkFlattenable.h:37
SkFlattenable::kSkShader_Type
@ kSkShader_Type
Definition:
SkFlattenable.h:38
SkFlattenable::kSkMaskFilter_Type
@ kSkMaskFilter_Type
Definition:
SkFlattenable.h:36
SkFlattenable::kSkColorFilter_Type
@ kSkColorFilter_Type
Definition:
SkFlattenable.h:31
SkFlattenable::kSkDrawLooper_Type
@ kSkDrawLooper_Type
Definition:
SkFlattenable.h:34
SkFlattenable::kSkBlender_Type
@ kSkBlender_Type
Definition:
SkFlattenable.h:32
SkFlattenable::kSkImageFilter_Type
@ kSkImageFilter_Type
Definition:
SkFlattenable.h:35
SkFlattenable::getFactory
virtual Factory getFactory() const =0
SkGraphics
Definition:
SkGraphics.h:23
SkReadBuffer
Definition:
SkReadBuffer.h:52
SkRefCnt
Definition:
SkRefCnt.h:119
SkWriteBuffer
Definition:
SkWriteBuffer.h:41
sk_sp< SkFlattenable >
length
size_t length
Definition:
key_event_handler.cc:41
SkShapers::Primitive::Factory
SKSHAPER_API sk_sp< Factory > Factory()
Definition:
SkShaper_factory.cpp:32
Type
Definition:
asyncrescaleandread.cpp:530
dart::Register
Register
Definition:
constants_arm.h:81
flutter::name
DEF_SWITCHES_START aot vmservice shared library name
Definition:
switches.h:32
SkDeserialProcs
Definition:
SkSerialProcs.h:97
SkSerialProcs
Definition:
SkSerialProcs.h:86
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:02 for Flutter Engine by
1.9.4