-/**
- * Helper function for handling mirror image blits.
- *
- * If coord0 > coord1, swap them and invert the "mirror" boolean.
- */
-static inline void
-fixup_mirroring(bool &mirror, GLfloat &coord0, GLfloat &coord1)
-{
- if (coord0 > coord1) {
- mirror = !mirror;
- GLfloat tmp = coord0;
- coord0 = coord1;
- coord1 = tmp;
- }
-}
-
-
-/**
- * Adjust {src,dst}_x{0,1} to account for clipping and scissoring of
- * destination coordinates.
- *
- * Return true if there is still blitting to do, false if all pixels got
- * rejected by the clip and/or scissor.
- *
- * For clarity, the nomenclature of this function assumes we are clipping and
- * scissoring the X coordinate; the exact same logic applies for Y
- * coordinates.
- *
- * Note: this function may also be used to account for clipping of source
- * coordinates, by swapping the roles of src and dst.
- */
-static inline bool
-clip_or_scissor(bool mirror, GLfloat &src_x0, GLfloat &src_x1, GLfloat &dst_x0,
- GLfloat &dst_x1, GLfloat fb_xmin, GLfloat fb_xmax)
-{
- float scale = (float) (src_x1 - src_x0) / (dst_x1 - dst_x0);
- /* If we are going to scissor everything away, stop. */
- if (!(fb_xmin < fb_xmax &&
- dst_x0 < fb_xmax &&
- fb_xmin < dst_x1 &&
- dst_x0 < dst_x1)) {
- return false;
- }
-
- /* Clip the destination rectangle, and keep track of how many pixels we
- * clipped off of the left and right sides of it.
- */
- GLint pixels_clipped_left = 0;
- GLint pixels_clipped_right = 0;
- if (dst_x0 < fb_xmin) {
- pixels_clipped_left = fb_xmin - dst_x0;
- dst_x0 = fb_xmin;
- }
- if (fb_xmax < dst_x1) {
- pixels_clipped_right = dst_x1 - fb_xmax;
- dst_x1 = fb_xmax;
- }
-
- /* If we are mirrored, then before applying pixels_clipped_{left,right} to
- * the source coordinates, we need to flip them to account for the
- * mirroring.
- */
- if (mirror) {
- GLint tmp = pixels_clipped_left;
- pixels_clipped_left = pixels_clipped_right;
- pixels_clipped_right = tmp;
- }
-
- /* Adjust the source rectangle to remove the pixels corresponding to those
- * that were clipped/scissored out of the destination rectangle.
- */
- src_x0 += pixels_clipped_left * scale;
- src_x1 -= pixels_clipped_right * scale;
-
- return true;
-}
-
-