// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/graphics/backends/cairo/surfacecairo.cpp
// Function: smooth::GUI::SurfaceCairo::Gradient(smooth::GUI::Rect const&, smooth::GUI::Color const&, smooth::GUI::Color const&, int)
S::Int S::GUI::SurfaceCairo::Gradient(const Rect &iRect, const Color &color1, const Color &color2, Int style)
{
	if (window == NIL) return Success();

	Rect	 rect = rightToLeft.TranslateRect(iRect);

	/* Setup colors.
	 */
	Color	 c1   = (style == OR_HORZ && rightToLeft.GetRightToLeft()) ? color2 : color1;
	Color	 c2   = (style == OR_HORZ && rightToLeft.GetRightToLeft()) ? color1 : color2;

	/* Setup Cairo objects and draw gradient.
	 */
	cairo_pattern_t	*pattern = cairo_pattern_create_linear(0, 0, style == OR_HORZ ? rect.GetWidth()	 : 0,
								     style == OR_VERT ? rect.GetHeight() : 0);

	cairo_pattern_add_color_stop_rgb(pattern, 0, c1.GetRed() / 255.0, c1.GetGreen() / 255.0, c1.GetBlue() / 255.0);
	cairo_pattern_add_color_stop_rgb(pattern, 1, c2.GetRed() / 255.0, c2.GetGreen() / 255.0, c2.GetBlue() / 255.0);

	if (!painting)
	{
		CreateCairoContext();

		cairo_set_source(context, pattern);
		cairo_rectangle(context, rect.left, rect.top, rect.GetWidth(), rect.GetHeight());
		cairo_fill(context);

		DestroyCairoContext();
	}

	cairo_set_source(paintContextCairo, pattern);
	cairo_rectangle(paintContextCairo, rect.left, rect.top, rect.GetWidth(), rect.GetHeight());
	cairo_fill(paintContextCairo);

	cairo_pattern_destroy(pattern);

	return Success();
}

// Assembly:
cmpq $0x0, 0x50(%rdi)
je 0xc6c7e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebp
movq %rcx, %r13
movq %rdx, %r12
movq %rdi, %rbx
leaq 0x28(%rdi), %r14
movq %r14, %rdi
callq 0x63296
movq %rax, 0x10(%rsp)
cmpl $0x1, %ebp
movq %rdx, 0x8(%rsp)
jne 0xc6a98
movq %r14, %rdi
callq 0x632d8
movq 0x8(%rsp), %rdx
movq %r13, %rcx
testb %al, %al
jne 0xc6a9b
movq %r12, %rcx
movq 0x8(%rcx), %r15
cmpl $0x1, %ebp
jne 0xc6ab5
movq %r14, %rdi
callq 0x632d8
movq 0x8(%rsp), %rdx
testb %al, %al
jne 0xc6ab8
movq %r13, %r12
xorpd %xmm3, %xmm3
cmpl $0x1, %ebp
je 0xc6acc
xorpd %xmm2, %xmm2
movq 0x10(%rsp), %r13
jmp 0xc6ada
movl %edx, %eax
movq 0x10(%rsp), %r13
subl %r13d, %eax
cvtsi2sd %eax, %xmm2
movl 0x8(%r12), %r12d
movq %rdx, %r14
shrq $0x20, %r14
shrq $0x20, %r13
cmpl $0x2, %ebp
jne 0xc6afc
movl %r14d, %eax
subl %r13d, %eax
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x58070
movl $0xff, %ebp
movl %r15d, %ecx
andl %ebp, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movsd 0x2d848(%rip), %xmm0    # 0xf4368
divsd %xmm0, %xmm1
movl %r15d, %ecx
shrl $0x8, %ecx
andl %ebp, %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
divsd %xmm0, %xmm2
shrl $0x10, %r15d
andl %ebp, %r15d
xorps %xmm3, %xmm3
cvtsi2sd %r15d, %xmm3
movq %rax, %r15
divsd %xmm0, %xmm3
xorpd %xmm0, %xmm0
movq %rax, %rdi
callq 0x57f00
movl %r12d, %eax
andl %ebp, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd 0x2d7fb(%rip), %xmm0    # 0xf4368
divsd %xmm0, %xmm1
movl %r12d, %eax
shrl $0x8, %eax
andl %ebp, %eax
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
divsd %xmm0, %xmm2
shrl $0x10, %r12d
andl %ebp, %r12d
xorps %xmm3, %xmm3
cvtsi2sd %r12d, %xmm3
divsd %xmm0, %xmm3
movsd 0x2d7e9(%rip), %xmm0    # 0xf4388
movq %r15, %rdi
callq 0x57f00
cmpw $0x0, 0xa(%rbx)
jne 0xc6c14
movq %rbx, %rdi
callq 0xc508a
movq 0xc0(%rbx), %rdi
movq %r15, %rsi
callq 0x58720
movq 0xc0(%rbx), %rdi
movq 0x10(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
movq 0x8(%rsp), %rax
subl %ecx, %eax
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
movl %r14d, %eax
subl %r13d, %eax
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
callq 0x565a0
movq 0xc0(%rbx), %rdi
callq 0x57d40
movq %rbx, %rdi
callq 0xc50e0
movq 0xd0(%rbx), %rdi
movq %r15, %rsi
callq 0x58720
movq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
movq 0x8(%rsp), %rcx
subl %eax, %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
movq 0xd0(%rbx), %rdi
subl %r13d, %r14d
xorps %xmm3, %xmm3
cvtsi2sd %r14d, %xmm3
callq 0x565a0
movq 0xd0(%rbx), %rdi
callq 0x57d40
movq %r15, %rdi
callq 0x58170
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq
nop