MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / RenderBackground

Method RenderBackground

Xaml/Controls/ColorPickerSlider.cpp:220–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218 }
219
220 fire_and_forget ColorPickerSlider::RenderBackground(weak_ref<wux::Shapes::Rectangle> rect_weak, txmp::HsvColor color, wuxc::Orientation orientation, int32_t width, int32_t height, double renderScale)
221 {
222 // retrieve properties before going to the background
223 const auto representation = ColorRepresentation();
224 const auto channel = ColorChannel();
225 const auto background = CheckerBackgroundColor();
226 const auto alphaMaxForced = IsAlphaMaxForced();
227 const auto saturationMaxForced = IsSaturationValueMaxForced();
228
229 // create the bitmap on this thread
230 wux::Media::Imaging::WriteableBitmap bitmap { width, height };
231 const auto buffer = bitmap.PixelBuffer();
232 const auto bgraPixelData = buffer.data();
233
234 // move to background
235 const auto dispatcher = Windows::System::DispatcherQueue::GetForCurrentThread();
236 co_await resume_background();
237
238 FillChannelBitmap(bgraPixelData, width, height, renderScale, orientation, representation, channel, color, background, alphaMaxForced, saturationMaxForced);
239
240 if (const auto rect = rect_weak.get())
241 {
242 // return to main thread
243 co_await wil::resume_foreground(dispatcher);
244
245 bitmap.Invalidate();
246 wux::Media::ImageBrush brush;
247 brush.ImageSource(bitmap);
248 brush.Stretch(wux::Media::Stretch::Fill);
249 rect.Fill(brush);
250 }
251 }
252}

Callers

nothing calls this directly

Calls 2

FillChannelBitmapFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected