| 153 | } |
| 154 | |
| 155 | void downscale(const CRGB *src, const XYMap &srcXY, CRGB *dst, |
| 156 | const XYMap &dstXY) { |
| 157 | fl::u16 srcWidth = srcXY.getWidth(); |
| 158 | fl::u16 srcHeight = srcXY.getHeight(); |
| 159 | fl::u16 dstWidth = dstXY.getWidth(); |
| 160 | fl::u16 dstHeight = dstXY.getHeight(); |
| 161 | |
| 162 | FASTLED_ASSERT(dstWidth <= srcWidth, |
| 163 | "Destination width must be <= source width"); |
| 164 | FASTLED_ASSERT(dstHeight <= srcHeight, |
| 165 | "Destination height must be <= source height"); |
| 166 | const bool destination_is_half_of_source = |
| 167 | (dstWidth * 2 == srcWidth) && (dstHeight * 2 == srcHeight); |
| 168 | // Attempt to use the downscaleHalf function if the destination is half the |
| 169 | // size of the source. |
| 170 | if (destination_is_half_of_source) { |
| 171 | const bool both_rectangles = (srcXY.getType() == XYMap::kLineByLine) && |
| 172 | (dstXY.getType() == XYMap::kLineByLine); |
| 173 | if (both_rectangles) { |
| 174 | // If both source and destination are rectangular, we can use the |
| 175 | // optimized version |
| 176 | downscaleHalf(src, srcWidth, srcHeight, dst); |
| 177 | } else { |
| 178 | // Otherwise, we need to use the mapped version |
| 179 | downscaleHalf(src, srcXY, dst, dstXY); |
| 180 | } |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | downscaleArbitrary(src, srcXY, dst, dstXY); |
| 185 | } |
| 186 | |
| 187 | } // namespace fl |
| 188 |
no test coverage detected