Builds the fixed set of mock buffers used by chrome development/tests: a 64x64 RGB8 gradient, a 32x32 RGBA8 checkerboard, and a 16x16 single-channel Float32 ramp. All three are generated purely from pixel index -- no randomness -- so the result is reproducible across runs.
| 163 | // single-channel Float32 ramp. All three are generated purely from pixel |
| 164 | // index -- no randomness -- so the result is reproducible across runs. |
| 165 | inline MockBufferModel make_default_mock_model() { |
| 166 | std::vector<std::unique_ptr<BufferRecord>> records; |
| 167 | |
| 168 | // 64x64 RGB8 gradient: R ramps with x, G ramps with y, B constant. |
| 169 | { |
| 170 | constexpr int w = 64; |
| 171 | constexpr int h = 64; |
| 172 | constexpr int channels = 3; |
| 173 | std::vector<std::byte> pixels( |
| 174 | static_cast<std::size_t>(w * h * channels)); |
| 175 | for (int y = 0; y < h; ++y) { |
| 176 | for (int x = 0; x < w; ++x) { |
| 177 | auto* p = |
| 178 | &pixels[static_cast<std::size_t>((y * w + x) * channels)]; |
| 179 | p[0] = std::byte(x * 4); |
| 180 | p[1] = std::byte(y * 4); |
| 181 | p[2] = std::byte(128); |
| 182 | } |
| 183 | } |
| 184 | records.push_back(std::make_unique<BufferRecord>(BufferRecord{ |
| 185 | .variable_name = "gradient_rgb8", |
| 186 | .display_name = "gradient (64x64 rgb8)", |
| 187 | .pixel_layout = "rgb", |
| 188 | .transpose = false, |
| 189 | .width = w, |
| 190 | .height = h, |
| 191 | .channels = channels, |
| 192 | .step = w, |
| 193 | .type = oid::BufferType::UnsignedByte, |
| 194 | .bytes = std::move(pixels), |
| 195 | })); |
| 196 | } |
| 197 | |
| 198 | // 32x32 RGBA8 checkerboard, 4x4-pixel cells. |
| 199 | { |
| 200 | constexpr int w = 32; |
| 201 | constexpr int h = 32; |
| 202 | constexpr int channels = 4; |
| 203 | constexpr int cell = 4; |
| 204 | std::vector<std::byte> pixels( |
| 205 | static_cast<std::size_t>(w * h * channels)); |
| 206 | for (int y = 0; y < h; ++y) { |
| 207 | for (int x = 0; x < w; ++x) { |
| 208 | const bool light = ((x / cell) + (y / cell)) % 2 == 0; |
| 209 | const auto v = static_cast<std::uint8_t>(light ? 220 : 40); |
| 210 | auto* p = |
| 211 | &pixels[static_cast<std::size_t>((y * w + x) * channels)]; |
| 212 | p[0] = std::byte(v); |
| 213 | p[1] = std::byte(v); |
| 214 | p[2] = std::byte(v); |
| 215 | p[3] = std::byte(255); |
| 216 | } |
| 217 | } |
| 218 | records.push_back(std::make_unique<BufferRecord>(BufferRecord{ |
| 219 | .variable_name = "checker_rgba8", |
| 220 | .display_name = "checker (32x32 rgba8)", |
| 221 | .pixel_layout = "rgba", |
| 222 | .transpose = false, |