* Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen. * * @pre dpi->zoom == ZoomLevel::Min, right >= left, bottom >= top * @param left Minimum X (inclusive) * @param top Minimum Y (inclusive) * @param right Maximum X (inclusive) * @param bottom Maximum Y (inclusive) * @param colour A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER)
| 113 | * FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the rectangle currently on screen |
| 114 | */ |
| 115 | void GfxFillRect(int left, int top, int right, int bottom, const std::variant<PixelColour, PaletteID> &colour, FillRectMode mode) |
| 116 | { |
| 117 | Blitter *blitter = BlitterFactory::GetCurrentBlitter(); |
| 118 | const DrawPixelInfo *dpi = _cur_dpi; |
| 119 | void *dst; |
| 120 | const int otop = top; |
| 121 | const int oleft = left; |
| 122 | |
| 123 | if (dpi->zoom != ZoomLevel::Min) return; |
| 124 | if (left > right || top > bottom) return; |
| 125 | if (right < dpi->left || left >= dpi->left + dpi->width) return; |
| 126 | if (bottom < dpi->top || top >= dpi->top + dpi->height) return; |
| 127 | |
| 128 | if ( (left -= dpi->left) < 0) left = 0; |
| 129 | right = right - dpi->left + 1; |
| 130 | if (right > dpi->width) right = dpi->width; |
| 131 | right -= left; |
| 132 | assert(right > 0); |
| 133 | |
| 134 | if ( (top -= dpi->top) < 0) top = 0; |
| 135 | bottom = bottom - dpi->top + 1; |
| 136 | if (bottom > dpi->height) bottom = dpi->height; |
| 137 | bottom -= top; |
| 138 | assert(bottom > 0); |
| 139 | |
| 140 | dst = blitter->MoveTo(dpi->dst_ptr, left, top); |
| 141 | |
| 142 | switch (mode) { |
| 143 | default: // FILLRECT_OPAQUE |
| 144 | blitter->DrawRect(dst, right, bottom, std::get<PixelColour>(colour)); |
| 145 | break; |
| 146 | |
| 147 | case FILLRECT_RECOLOUR: |
| 148 | blitter->DrawColourMappingRect(dst, right, bottom, GB(std::get<PaletteID>(colour), 0, PALETTE_WIDTH)); |
| 149 | break; |
| 150 | |
| 151 | case FILLRECT_CHECKER: { |
| 152 | uint8_t bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; |
| 153 | PixelColour pc = std::get<PixelColour>(colour); |
| 154 | do { |
| 155 | for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, pc); |
| 156 | dst = blitter->MoveTo(dst, 0, 1); |
| 157 | } while (--bottom > 0); |
| 158 | break; |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | typedef std::pair<Point, Point> LineSegment; |
| 164 |
no test coverage detected