File: draw_property_utils.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (120 lines) | stat: -rw-r--r-- 4,635 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_TREES_DRAW_PROPERTY_UTILS_H_
#define CC_TREES_DRAW_PROPERTY_UTILS_H_

#include <optional>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "cc/cc_export.h"
#include "cc/layers/layer_collections.h"

namespace gfx {
class Transform;
class Vector2dF;
}  // namespace gfx

namespace cc {

class Layer;
class LayerImpl;
class LayerTreeHost;
class LayerTreeImpl;
class EffectTree;
class TransformTree;
class PropertyTrees;
struct EffectNode;
struct TransformNode;
struct ViewportPropertyIds;

namespace draw_property_utils {

void CC_EXPORT ConcatInverseSurfaceContentsScale(const EffectNode* effect_node,
                                                 gfx::Transform* transform);

// Computes combined (screen space) transforms for every node in the transform
// tree. This must be done prior to calling |ComputeClips|.
void CC_EXPORT
ComputeTransforms(TransformTree* transform_tree,
                  const ViewportPropertyIds& viewport_property_ids);

// Computes screen space opacity for every node in the opacity tree.
void CC_EXPORT ComputeEffects(EffectTree* effect_tree);

void CC_EXPORT UpdatePropertyTrees(LayerTreeHost* layer_tree_host);

void CC_EXPORT
UpdatePropertyTreesAndRenderSurfaces(LayerTreeImpl* layer_tree_impl,
                                     PropertyTrees* property_trees);

void CC_EXPORT FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host,
                                         LayerList* update_layer_list);

void CC_EXPORT
FindLayersThatNeedUpdates(LayerTreeImpl* layer_tree_impl,
                          std::vector<LayerImpl*>* visible_layer_list);

gfx::Transform CC_EXPORT DrawTransform(const LayerImpl* layer,
                                       const TransformTree& transform_tree,
                                       const EffectTree& effect_tree);

gfx::Transform CC_EXPORT ScreenSpaceTransform(const Layer* layer,
                                              const TransformTree& tree);
gfx::Transform CC_EXPORT ScreenSpaceTransform(const LayerImpl* layer,
                                              const TransformTree& tree);

void CC_EXPORT UpdatePageScaleFactor(PropertyTrees* property_trees,
                                     TransformNode* page_scale_node,
                                     float page_scale_factor);

void CC_EXPORT CalculateDrawProperties(
    LayerTreeImpl* layer_tree_impl,
    RenderSurfaceList* output_render_surface_list,
    LayerImplList* output_update_layer_list_for_testing = nullptr);

bool CC_EXPORT LayerShouldBeSkippedForDrawPropertiesComputation(
    LayerImpl* layer,
    const PropertyTrees* property_trees);

bool CC_EXPORT
IsLayerBackFaceVisibleForTesting(const LayerImpl* layer,
                                 const PropertyTrees* property_trees);

// Returns true if the scales are interchangeable when rasterizing the same
// drawings without visual misalignment.
bool CC_EXPORT RasterScalesApproximatelyEqual(gfx::Vector2dF scale1,
                                              gfx::Vector2dF scale2);

// The result will be used to avoid blurriness of rasterized rendering under
// transforms with subpixel translations. If applicable, the offset will be in
// the range of [0, 1) for each component. After this function returns
// - for a RenderSurfaceImpl, the offset should be subtracted from the the draw
//   transform, and be added to the draw transforms of contributing layers and
//   render surfaces.
// - for a PictureLayerImpl, the offset should be converted to a raster
//   translation which will translate rasterization and offset tex_coord_rect
//   of draw quads.
//
// With this offset applied, the drawings will still be rendered at the same
// screen locations, but the rasterized texels will be aligned to the screen
// pixels, to avoid the additional bluriness during compositing.
//
// Returns nullopt if pixel alignment can't be achieved.
std::optional<gfx::Vector2dF> CC_EXPORT
PixelAlignmentOffset(const gfx::Transform& screen_space_transform,
                     const gfx::Transform& original_draw_transform);

#if DCHECK_IS_ON()
// Checks and logs if double background blur exists in any layers. Returns
// true if no double background blur is detected, false otherwise.
bool CC_EXPORT
LogDoubleBackgroundBlur(const LayerTreeImpl& layer_tree_impl,
                        const RenderSurfaceList& render_surface_list);
#endif
}  // namespace draw_property_utils
}  // namespace cc

#endif  // CC_TREES_DRAW_PROPERTY_UTILS_H_