| 677 | } |
| 678 | |
| 679 | static 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 | |
| 701 | template <> |
| 702 | void ImageBaseKnob<CairoImage>::onDisplay() |
no test coverage detected