MCPcopy Create free account
hub / github.com/FastLED/FastLED / upscale

Function upscale

src/fl/gfx/upscale.h:56–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55//
56inline void upscale(const CRGB *input, CRGB *output, u16 inputWidth,
57 u16 inputHeight, const fl::XYMap& xyMap) {
58 u16 outputWidth = xyMap.getWidth();
59 u16 outputHeight = xyMap.getHeight();
60 const bool wontFit =
61 (outputWidth != xyMap.getWidth() || outputHeight != xyMap.getHeight());
62
63 // Check if we can use the optimized rectangular version
64 const bool isRectangular = (xyMap.getType() == XYMap::kLineByLine);
65
66 if (isRectangular) {
67 // Use optimized rectangular version that bypasses XY mapping
68 if (wontFit || (inputWidth & (inputWidth - 1)) ||
69 (inputHeight & (inputHeight - 1))) {
70 upscaleRectangular(input, output, inputWidth, inputHeight,
71 outputWidth, outputHeight);
72 } else {
73 upscaleRectangularPowerOf2(input, output, inputWidth, inputHeight,
74 outputWidth, outputHeight);
75 }
76 } else {
77 // Use the original XY-mapped versions
78 if (wontFit || (inputWidth & (inputWidth - 1)) ||
79 (inputHeight & (inputHeight - 1))) {
80 upscaleArbitrary(input, output, inputWidth, inputHeight, xyMap);
81 } else {
82 upscalePowerOf2(input, output, inputWidth, inputHeight, xyMap);
83 }
84 }
85}
86
87// These are here for testing purposes and are slow. Their primary use
88// is to test against the fixed integer version above.

Callers 2

upscaleMethod · 0.85
expandMethod · 0.85

Calls 7

upscaleRectangularFunction · 0.85
upscaleArbitraryFunction · 0.85
upscalePowerOf2Function · 0.85
getWidthMethod · 0.45
getHeightMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected