| 765 | // ----------------------------------------------------------------------- |
| 766 | |
| 767 | void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) |
| 768 | { |
| 769 | cairo_t* const handle = static_cast<const CairoGraphicsContext&>(self->getGraphicsContext()).handle; |
| 770 | |
| 771 | bool needsResetClip = false; |
| 772 | |
| 773 | cairo_matrix_t matrix; |
| 774 | cairo_get_matrix(handle, &matrix); |
| 775 | |
| 776 | if (needsViewportScaling) |
| 777 | { |
| 778 | // limit viewport to widget bounds |
| 779 | // NOTE only used for nanovg for now, which is not relevant here |
| 780 | } |
| 781 | else if (needsFullViewportForDrawing || (absolutePos.isZero() && self->getSize() == Size<uint>(width, height))) |
| 782 | { |
| 783 | // full viewport size |
| 784 | cairo_translate(handle, 0, 0); |
| 785 | cairo_scale(handle, autoScaleFactor, autoScaleFactor); |
| 786 | } |
| 787 | else |
| 788 | { |
| 789 | // set viewport pos |
| 790 | cairo_translate(handle, absolutePos.getX() * autoScaleFactor, absolutePos.getY() * autoScaleFactor); |
| 791 | |
| 792 | // then cut the outer bounds |
| 793 | cairo_rectangle(handle, |
| 794 | 0, |
| 795 | 0, |
| 796 | std::round(self->getWidth() * autoScaleFactor), |
| 797 | std::round(self->getHeight() * autoScaleFactor)); |
| 798 | |
| 799 | cairo_clip(handle); |
| 800 | needsResetClip = true; |
| 801 | |
| 802 | // set viewport scaling |
| 803 | cairo_scale(handle, autoScaleFactor, autoScaleFactor); |
| 804 | } |
| 805 | |
| 806 | // display widget |
| 807 | self->onDisplay(); |
| 808 | |
| 809 | if (needsResetClip) |
| 810 | cairo_reset_clip(handle); |
| 811 | |
| 812 | cairo_set_matrix(handle, &matrix); |
| 813 | |
| 814 | selfw->pData->displaySubWidgets(width, height, autoScaleFactor); |
| 815 | } |
| 816 | |
| 817 | // ----------------------------------------------------------------------- |
| 818 | |