Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
SkSVGLengthContext Class Reference

#include <SkSVGRenderContext.h>

Public Types

enum class  LengthType { kHorizontal , kVertical , kOther }
 

Public Member Functions

 SkSVGLengthContext (const SkSize &viewport, SkScalar dpi=90)
 
const SkSizeviewPort () const
 
void setViewPort (const SkSize &viewport)
 
SkScalar resolve (const SkSVGLength &, LengthType) const
 
SkRect resolveRect (const SkSVGLength &x, const SkSVGLength &y, const SkSVGLength &w, const SkSVGLength &h) const
 

Detailed Description

Definition at line 29 of file SkSVGRenderContext.h.

Member Enumeration Documentation

◆ LengthType

enum class SkSVGLengthContext::LengthType
strong
Enumerator
kHorizontal 
kVertical 
kOther 

Definition at line 34 of file SkSVGRenderContext.h.

Constructor & Destructor Documentation

◆ SkSVGLengthContext()

SkSVGLengthContext::SkSVGLengthContext ( const SkSize viewport,
SkScalar  dpi = 90 
)
inline

Definition at line 31 of file SkSVGRenderContext.h.

32 : fViewport(viewport), fDPI(dpi) {}

Member Function Documentation

◆ resolve()

SkScalar SkSVGLengthContext::resolve ( const SkSVGLength l,
LengthType  t 
) const

Definition at line 54 of file SkSVGRenderContext.cpp.

54 {
55 switch (l.unit()) {
57 // Fall through.
59 return l.value();
61 return l.value() * length_size_for_type(fViewport, t) / 100;
63 return l.value() * fDPI * kCMMultiplier;
65 return l.value() * fDPI * kMMMultiplier;
67 return l.value() * fDPI * kINMultiplier;
69 return l.value() * fDPI * kPTMultiplier;
71 return l.value() * fDPI * kPCMultiplier;
72 default:
73 SkDebugf("unsupported unit type: <%d>\n", (int)l.unit());
74 return 0;
75 }
76}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
const Unit & unit() const
Definition: SkSVGTypes.h:144
const SkScalar & value() const
Definition: SkSVGTypes.h:143

◆ resolveRect()

SkRect SkSVGLengthContext::resolveRect ( const SkSVGLength x,
const SkSVGLength y,
const SkSVGLength w,
const SkSVGLength h 
) const

Definition at line 78 of file SkSVGRenderContext.cpp.

79 {
80 return SkRect::MakeXYWH(
85}
SkScalar resolve(const SkSVGLength &, LengthType) const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ setViewPort()

void SkSVGLengthContext::setViewPort ( const SkSize viewport)
inline

Definition at line 41 of file SkSVGRenderContext.h.

41{ fViewport = viewport; }

◆ viewPort()

const SkSize & SkSVGLengthContext::viewPort ( ) const
inline

Definition at line 40 of file SkSVGRenderContext.h.

40{ return fViewport; }

The documentation for this class was generated from the following files: