MCPcopy Create free account
hub / github.com/google/gapid / encodeDimension

Function encodeDimension

core/os/android/binaryxml/value.go:62–93  ·  view source on GitHub ↗

https://android.googlesource.com/platform/frameworks/base/+/master/libs/androidfw/ResourceTypes.cpp

(w binary.Writer, f float32, unit uint8)

Source from the content-addressed store, hash-verified

60
61// https://android.googlesource.com/platform/frameworks/base/+/master/libs/androidfw/ResourceTypes.cpp
62func encodeDimension(w binary.Writer, f float32, unit uint8) {
63 neg := f < 0
64 if neg {
65 f = -f
66 }
67 bits := uint64(f*(1<<23) + .5)
68 radix := uint32(0)
69 shift := uint32(0)
70 if (bits & 0x7fffff) == 0 {
71 radix = 0
72 shift = 23
73 } else if (bits & 0xffffffffff800000) == 0 {
74 radix = 3
75 shift = 0
76 } else if (bits & 0xffffffff80000000) == 0 {
77 radix = 2
78 shift = 8
79 } else if (bits & 0xffffff8000000000) == 0 {
80 radix = 1
81 shift = 16
82 } else {
83 radix = 0
84 shift = 23
85 }
86 mantissa := (int32)(bits>>shift) & 0xFFFFFF
87 if neg {
88 mantissa = (-mantissa) & 0xFFFFFF
89 }
90
91 e := uint32((radix << 4) | uint32(mantissa<<8) | uint32(unit))
92 w.Uint32(e)
93}
94
95func (v valIntDec) encode(w binary.Writer) {
96 writeTypedValueHeader(w, typeIntDec)

Callers 6

encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85

Calls 1

Uint32Method · 0.65

Tested by

no test coverage detected