// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::CreateColorChannels(gaps::R2Image const&)
int RGBDSurface::
CreateColorChannels(const R2Image& image)
{
  // Check/update read count
  if (color_resident_count++ > 0) return 1;

  // Create color channels
  while (channels.NEntries() <= RGBD_BLUE_CHANNEL) channels.Insert(NULL);
  if (!channels[RGBD_RED_CHANNEL]) channels[RGBD_RED_CHANNEL] = new R2Grid(image.Width(), image.Height());
  if (!channels[RGBD_GREEN_CHANNEL]) channels[RGBD_GREEN_CHANNEL] = new R2Grid(image.Width(), image.Height());
  if (!channels[RGBD_BLUE_CHANNEL]) channels[RGBD_BLUE_CHANNEL] = new R2Grid(image.Width(), image.Height());

  // Initialize color channels
  SetColorChannels(image);

  // Set width and height
  this->width = image.Width();
  this->height = image.Height();

  // Return success
  return 1;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x58(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movl 0x70(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x70(%rcx)
cmpl $0x0, %eax
jle 0x26885
movl $0x1, 0x64(%rsp)
jmp 0x26aba
jmp 0x26887
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
callq 0x19e00
cmpl $0x2, %eax
jg 0x268ae
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x27fb0
jmp 0x26887
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
callq 0x277c0
cmpq $0x0, (%rax)
jne 0x26943
movl $0xd0, %edi
callq 0x126d0
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %rdi
callq 0x22940
movl %eax, 0x34(%rsp)
jmp 0x268e3
movq 0x50(%rsp), %rdi
callq 0x22950
movl %eax, 0x24(%rsp)
jmp 0x268f3
movl 0x24(%rsp), %edx
movl 0x34(%rsp), %esi
movq 0x28(%rsp), %rdi
callq 0xb1ee0
jmp 0x26907
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
callq 0x277c0
movq 0x28(%rsp), %rcx
movq %rcx, (%rax)
jmp 0x26943
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
movl $0xd0, %esi
callq 0x126e0
jmp 0x26ac3
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
movl $0x1, %esi
callq 0x277c0
cmpq $0x0, (%rax)
jne 0x269e2
movl $0xd0, %edi
callq 0x126d0
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rdi
callq 0x22940
movl %eax, 0x20(%rsp)
jmp 0x2697f
movq 0x50(%rsp), %rdi
callq 0x22950
movl %eax, 0x14(%rsp)
jmp 0x2698f
movl 0x14(%rsp), %edx
movl 0x20(%rsp), %esi
movq 0x18(%rsp), %rdi
callq 0xb1ee0
jmp 0x269a3
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
movl $0x1, %esi
callq 0x277c0
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
jmp 0x269e2
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
movl $0xd0, %esi
callq 0x126e0
jmp 0x26ac3
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
movl $0x2, %esi
callq 0x277c0
cmpq $0x0, (%rax)
jne 0x26a7a
movl $0xd0, %edi
callq 0x126d0
movq %rax, 0x8(%rsp)
movq 0x50(%rsp), %rdi
callq 0x22940
movl %eax, 0x10(%rsp)
jmp 0x26a1a
movq 0x50(%rsp), %rdi
callq 0x22950
movl %eax, 0x4(%rsp)
jmp 0x26a2a
movl 0x4(%rsp), %edx
movl 0x10(%rsp), %esi
movq 0x8(%rsp), %rdi
callq 0xb1ee0
jmp 0x26a3e
movq 0x38(%rsp), %rdi
addq $0x18, %rdi
movl $0x2, %esi
callq 0x277c0
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
jmp 0x26a7a
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
movl $0xd0, %esi
callq 0x126e0
jmp 0x26ac3
movq 0x38(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x50(%rsp), %rdi
callq 0x22940
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x50(%rsp), %rdi
callq 0x22950
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x2c(%rax)
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x12c20
nopl (%rax)