Example #1
0
static octree_node_t* find_leaf(octree_node_t* root, 
                                bbox_t* bounding_box, 
                                point_t* x)
{
  if (!bbox_contains(bounding_box, x)) 
    return NULL;

  return NULL;
}
Example #2
0
/**
 * bd_blockReader is called repeatedly after bd_readerNext to read the contents
 * of a backdrop block.  It returns a bounded area with color and info, or null
 * indicating the block has been read.
 */
const dbbox_t *bd_blockReader(CompositeContext *context,
                              const Backdrop *backdrop,
                              uint8 **color8, COLORVALUE **color,
                              COLORINFO **info)
{
  BackdropReader *reader = &context->reader;
  dbbox_t *bounds = &reader->bounds;
  uint8 slot;

  HQASSERT(reader->block != NULL, "Must have a block to read");
  HQASSERT(!bd_isPurgeable(reader->block) && reader->block->lines != NULL &&
           (bd_isUniform(reader->block) || reader->block->data != NULL),
           "Block is not suitable for reading");

  if ( reader->blockFinish ) {
    return NULL;
  } else if ( reader->blockStart ) {
    reader->blockStart = FALSE;

    /* Calculate the read bounds for this block. */
    bbox_store(&reader->readBoundsForBlock, reader->xTopLeft, reader->yTopLeft,
               reader->xTopLeft + bd_blockWidth(reader->block) - 1,
               reader->yTopLeft + bd_blockHeight(reader->block) - 1);
    bbox_intersection(&reader->readBoundsForBlock, &reader->readBounds,
                      &reader->readBoundsForBlock);
    HQASSERT(!bbox_is_empty(&reader->readBoundsForBlock) &&
             bbox_contains(&reader->readBounds, &reader->readBoundsForBlock),
             "readBoundsForBlock is invalid");

    /* Check for a uniform block. */
    if ( bd_isUniform(reader->block) ) {
      bdt_getOutput(bd_uniformTable(reader->block), backdrop->outComps, 0,
                    color, color8, info);
      reader->blockFinish = TRUE;
      return &reader->readBoundsForBlock;
    }

    /* Initialise bounds for the first read from this block (x1/x2 are set to
       xTopLeft rather than readBoundsForBlock.x1 to handle the RLE case below). */
    bounds->x1 = bounds->x2 = reader->xTopLeft;
    bounds->y1 = bounds->y2 = reader->readBoundsForBlock.y1;
  } else {
    /* Already reading from the block so just advance to the next pixel. */
    bounds->x1 = bounds->x2 = bounds->x2 + 1;

    if ( bounds->x1 > reader->readBoundsForBlock.x2 ) {
      /* Reached end of line; go to the next. */
      bounds->x1 = bounds->x2 = reader->xTopLeft;
      bounds->y1 = bounds->y2 = bounds->y2 + 1;

      if ( bounds->y1 > reader->readBoundsForBlock.y2 ) {
        /* No more lines in this block; get the next block. */
        reader->blockFinish = TRUE;
        return NULL;
      }
    }
  }

  /* Check for a start of a line. */
  if ( bounds->x1 == reader->xTopLeft ) {
    int32 xSkip = reader->readBoundsForBlock.x1 - reader->xTopLeft;

    bd_lineAndDataRepeatSrc(reader->block, bounds->y1 - reader->yTopLeft,
                            &reader->line, &reader->data);

    /* Skip pixels before readBoundsForBlock.x1. */
    if ( xSkip > 0 ) {
      if ( bd_isRLE(reader->line) ) {
        while ( (bounds->x1 + readRunLen(reader->data[0]) - 1)
                < reader->readBoundsForBlock.x1 ) {
          bounds->x1 += readRunLen(reader->data[0]);
          reader->data += 2;
        }
      } else {
        bounds->x1 += xSkip;
        reader->data += xSkip;
      }
      bounds->x2 = bounds->x1;
    }

    /* Count repeated lines. */
    for ( ; bounds->y2 < reader->readBoundsForBlock.y2 &&
            reader->block->lines[bounds->y2 + 1 - reader->yTopLeft].repeat;
          ++bounds->y2 ) {
      EMPTY_STATEMENT();
    }
  }

  HQASSERT(bounds->x1 == bounds->x2, "x1 and x2 should be the same");
  if ( bd_isRLE(reader->line) ) {
    /* Already got RLE; just read the next run. */
    slot = reader->data[1];
    bounds->x2 += readRunLen(reader->data[0]) - 1;
    bbox_clip_x(&reader->readBoundsForBlock, bounds->x1, bounds->x2);
    reader->data += 2;
  } else {
    /* Got a map, but check for runs. */
    slot = reader->data[0];
    ++reader->data;
    while ( bounds->x2 < reader->readBoundsForBlock.x2 &&
            reader->data[0] == slot ) {
      ++bounds->x2;
      ++reader->data;
    }
  }

  HQASSERT(!bbox_is_empty(bounds) &&
           bbox_contains(&reader->readBoundsForBlock, bounds), "Invalid bounds");
  bdt_getOutput(reader->line->table, backdrop->outComps, slot,
                color, color8, info);
  return bounds;
}