Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkSVGRect.cpp File Reference
#include <tuple>
#include "include/core/SkCanvas.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "modules/svg/include/SkSVGRect.h"
#include "modules/svg/include/SkSVGRenderContext.h"
#include "modules/svg/src/SkSVGRectPriv.h"

Go to the source code of this file.

Functions

std::tuple< float, float > ResolveOptionalRadii (const SkTLazy< SkSVGLength > &opt_rx, const SkTLazy< SkSVGLength > &opt_ry, const SkSVGLengthContext &lctx)
 

Function Documentation

◆ ResolveOptionalRadii()

std::tuple< float, float > ResolveOptionalRadii ( const SkTLazy< SkSVGLength > &  opt_rx,
const SkTLazy< SkSVGLength > &  opt_ry,
const SkSVGLengthContext lctx 
)

Definition at line 17 of file SkSVGRect.cpp.

19 {
20 // https://www.w3.org/TR/SVG2/shapes.html#RectElement
21 //
22 // The used values for rx and ry are determined from the computed values by following these
23 // steps in order:
24 //
25 // 1. If both rx and ry have a computed value of auto (since auto is the initial value for both
26 // properties, this will also occur if neither are specified by the author or if all
27 // author-supplied values are invalid), then the used value of both rx and ry is 0.
28 // (This will result in square corners.)
29 // 2. Otherwise, convert specified values to absolute values as follows:
30 // 1. If rx is set to a length value or a percentage, but ry is auto, calculate an absolute
31 // length equivalent for rx, resolving percentages against the used width of the
32 // rectangle; the absolute value for ry is the same.
33 // 2. If ry is set to a length value or a percentage, but rx is auto, calculate the absolute
34 // length equivalent for ry, resolving percentages against the used height of the
35 // rectangle; the absolute value for rx is the same.
36 // 3. If both rx and ry were set to lengths or percentages, absolute values are generated
37 // individually, resolving rx percentages against the used width, and resolving ry
38 // percentages against the used height.
39 const float rx = opt_rx.isValid()
41 : 0;
42 const float ry = opt_ry.isValid()
44 : 0;
45
46 return std::make_tuple(opt_rx.isValid() ? rx : ry,
47 opt_ry.isValid() ? ry : rx);
48}
SkScalar resolve(const SkSVGLength &, LengthType) const
bool isValid() const
Definition SkTLazy.h:77