MCPcopy Create free account
hub / github.com/DISTRHO/DPF / getRegion

Function getRegion

dgl/src/Cairo.cpp:679–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677}
678
679static cairo_surface_t* getRegion(cairo_surface_t* origsurface, int x, int y, int width, int height) noexcept
680{
681 const cairo_format_t format = cairo_image_surface_get_format(origsurface);
682 DISTRHO_SAFE_ASSERT_RETURN(format != CAIRO_FORMAT_INVALID, nullptr);
683
684 const int bpp = getBytesPerPixel(format);
685 DISTRHO_SAFE_ASSERT_RETURN(bpp != 0, nullptr);
686
687 const int fullWidth = cairo_image_surface_get_width(origsurface);
688 const int fullHeight = cairo_image_surface_get_height(origsurface);
689 const int stride = cairo_image_surface_get_stride(origsurface);
690 uchar* const fullData = cairo_image_surface_get_data(origsurface);
691
692 x = (x < fullWidth) ? x : fullWidth;
693 y = (y < fullHeight) ? y : fullHeight;
694 width = (x + width < fullWidth) ? width : (fullWidth - x);
695 height = (x + height < fullHeight) ? height : (fullHeight - x);
696
697 uchar* const data = fullData + (x * bpp + y * stride);
698 return cairo_image_surface_create_for_data(data, format, width, height, stride);
699}
700
701template <>
702void ImageBaseKnob<CairoImage>::onDisplay()

Callers 1

onDisplayMethod · 0.85

Calls 1

getBytesPerPixelFunction · 0.85

Tested by

no test coverage detected