Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
flow
layers
opacity_layer.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_FLOW_LAYERS_OPACITY_LAYER_H_
6
#define FLUTTER_FLOW_LAYERS_OPACITY_LAYER_H_
7
8
#include "flutter/flow/layers/cacheable_layer.h"
9
#include "flutter/flow/layers/layer.h"
10
#include "
include/core/SkMatrix.h
"
11
12
namespace
flutter
{
13
14
// Don't add an OpacityLayer with no children to the layer tree. Painting an
15
// OpacityLayer is very costly due to the saveLayer call. If there's no child,
16
// having the OpacityLayer or not has the same effect. In debug_unopt build,
17
// |Preroll| will assert if there are no children.
18
class
OpacityLayer
:
public
CacheableContainerLayer
{
19
public
:
20
// An offset is provided here because OpacityLayer.addToScene method in the
21
// Flutter framework can take an optional offset argument.
22
//
23
// By default, that offset is always zero, and all the offsets are handled by
24
// some parent TransformLayers. But we allow the offset to be non-zero for
25
// backward compatibility. If it's non-zero, the old behavior is to propage
26
// that offset to all the leaf layers (e.g., DisplayListLayer). That will make
27
// the retained rendering inefficient as a small offset change could propagate
28
// to many leaf layers. Therefore we try to capture that offset here to stop
29
// the propagation as repainting the OpacityLayer is expensive.
30
OpacityLayer
(
SkAlpha
alpha,
const
SkPoint
&
offset
);
31
32
void
Diff
(
DiffContext
* context,
const
Layer
* old_layer)
override
;
33
34
void
Preroll
(
PrerollContext
* context)
override
;
35
36
void
Paint
(
PaintContext
& context)
const override
;
37
38
// Returns whether the children are capable of inheriting an opacity value
39
// and modifying their rendering accordingly. This value is only guaranteed
40
// to be valid after the local |Preroll| method is called.
41
bool
children_can_accept_opacity
()
const
{
42
return
children_can_accept_opacity_;
43
}
44
void
set_children_can_accept_opacity
(
bool
value) {
45
children_can_accept_opacity_ =
value
;
46
}
47
48
SkScalar
opacity
()
const
{
return
alpha_ * 1.0f /
SK_AlphaOPAQUE
; }
49
50
private
:
51
SkAlpha
alpha_;
52
SkPoint
offset_;
53
bool
children_can_accept_opacity_ =
false
;
54
55
FML_DISALLOW_COPY_AND_ASSIGN
(
OpacityLayer
);
56
};
57
58
}
// namespace flutter
59
60
#endif
// FLUTTER_FLOW_LAYERS_OPACITY_LAYER_H_
SkAlpha
uint8_t SkAlpha
Definition
SkColor.h:26
SK_AlphaOPAQUE
constexpr SkAlpha SK_AlphaOPAQUE
Definition
SkColor.h:94
SkMatrix.h
flutter::CacheableContainerLayer
Definition
cacheable_layer.h:32
flutter::DiffContext
Definition
diff_context.h:44
flutter::Layer
Definition
layer.h:126
flutter::OpacityLayer
Definition
opacity_layer.h:18
flutter::OpacityLayer::Diff
void Diff(DiffContext *context, const Layer *old_layer) override
Definition
opacity_layer.cc:20
flutter::OpacityLayer::opacity
SkScalar opacity() const
Definition
opacity_layer.h:48
flutter::OpacityLayer::children_can_accept_opacity
bool children_can_accept_opacity() const
Definition
opacity_layer.h:41
flutter::OpacityLayer::Preroll
void Preroll(PrerollContext *context) override
Definition
opacity_layer.cc:37
flutter::OpacityLayer::set_children_can_accept_opacity
void set_children_can_accept_opacity(bool value)
Definition
opacity_layer.h:44
flutter::Paint
Definition
paint.h:15
SkScalar
float SkScalar
Definition
extension.cpp:12
value
uint8_t value
Definition
fl_standard_message_codec.cc:36
FML_DISALLOW_COPY_AND_ASSIGN
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition
macros.h:27
flutter
Definition
asset_manager.cc:10
offset
Point offset
Definition
stroke_path_geometry.cc:256
SkPoint
Definition
SkPoint_impl.h:163
flutter::PaintContext
Definition
layer.h:87
flutter::PrerollContext
Definition
layer.h:54
Generated on Fri Apr 26 2024 06:14:04 for Flutter Engine by
1.9.8