drawFrameBuffer method
Draw another buffer onto this buffer (compositing).
The source rectangle (srcX, srcY, srcWidth, srcHeight) is copied to
(destX, destY) on this buffer. Both buffers must be valid (not yet
invalidated by their renderer); zero source values select the native
full-extent default. After both lifecycle checks, srcX, srcY,
srcWidth, and srcHeight must fit unsigned 32-bit values and destX
and destY signed 32-bit values; violations throw a pre-invocation
RangeError.
Clipped views intersect the copy rectangle with their clip. The pinned native implementation can still expand a copied wide grapheme or clear an overwritten destination grapheme across that edge. Keep wide grapheme spans wholly inside or outside the clip in both buffers when exact clipping is required.
Implementation
void drawFrameBuffer(
Buffer sourceBuffer,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int destX,
int destY,
) {
_checkValid();
sourceBuffer._checkValid();
_checkUnsignedAbi(srcX, 0xFFFFFFFF, 'srcX');
_checkUnsignedAbi(srcY, 0xFFFFFFFF, 'srcY');
_checkUnsignedAbi(srcWidth, 0xFFFFFFFF, 'srcWidth');
_checkUnsignedAbi(srcHeight, 0xFFFFFFFF, 'srcHeight');
_checkSigned32Abi(destX, 'destX');
_checkSigned32Abi(destY, 'destY');
final clip = _clip;
if (clip != null) {
final sourceWidth = sourceBuffer.width;
final sourceHeight = sourceBuffer.height;
if (srcX >= sourceWidth || srcY >= sourceHeight) return;
final drawWidth = math.min(
srcWidth == 0 ? sourceWidth : srcWidth,
sourceWidth - srcX,
);
final drawHeight = math.min(
srcHeight == 0 ? sourceHeight : srcHeight,
sourceHeight - srcY,
);
final visible = _intersectClips(
_intersectClips((
x: destX,
y: destY,
width: drawWidth,
height: drawHeight,
), clip),
(x: 0, y: 0, width: width, height: height),
);
if (visible.width == 0 || visible.height == 0) return;
_bindings.drawFrameBuffer(
_ptr,
visible.x,
visible.y,
sourceBuffer._ptr,
srcX + visible.x - destX,
srcY + visible.y - destY,
visible.width,
visible.height,
);
return;
}
_bindings.drawFrameBuffer(
_ptr,
destX,
destY,
sourceBuffer._ptr,
srcX,
srcY,
srcWidth,
srcHeight,
);
}