| 153 | //========================================================================== |
| 154 | |
| 155 | void FMultiPatchTexture::CopyToBlock(uint8_t *dest, int dwidth, int dheight, FImageSource *source, int xpos, int ypos, int rotate, const uint8_t *translation, int style) |
| 156 | { |
| 157 | auto cimage = source->GetCachedPalettedPixels(style); // should use composition cache |
| 158 | auto &image = cimage.Pixels; |
| 159 | const uint8_t *pixels = image.Data(); |
| 160 | int srcwidth = source->GetWidth(); |
| 161 | int srcheight = source->GetHeight(); |
| 162 | int step_x = source->GetHeight(); |
| 163 | int step_y = 1; |
| 164 | FClipRect cr = { 0, 0, dwidth, dheight }; |
| 165 | if (style) translation = nullptr; // do not apply translations to alpha textures. |
| 166 | |
| 167 | if (ClipCopyPixelRect(&cr, xpos, ypos, pixels, srcwidth, srcheight, step_x, step_y, rotate)) |
| 168 | { |
| 169 | dest += ypos + dheight * xpos; |
| 170 | if (translation == NULL) |
| 171 | { |
| 172 | for (int x = 0; x < srcwidth; x++) |
| 173 | { |
| 174 | int pos = x * dheight; |
| 175 | for (int y = 0; y < srcheight; y++, pos++) |
| 176 | { |
| 177 | // the optimizer is doing a good enough job here so there's no need to optimize this by hand |
| 178 | uint8_t v = pixels[y * step_y + x * step_x]; |
| 179 | if (v != 0) dest[pos] = v; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | for (int x = 0; x < srcwidth; x++) |
| 186 | { |
| 187 | int pos = x * dheight; |
| 188 | for (int y = 0; y < srcheight; y++, pos++) |
| 189 | { |
| 190 | uint8_t v = pixels[y * step_y + x * step_x]; |
| 191 | if (v != 0) dest[pos] = translation[v]; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | //========================================================================== |
| 199 | // |
nothing calls this directly
no test coverage detected