void BasicObject::stretchObject(int width, int height, bool scale)
{
    x_scale = width / static_cast<double>(i_width);
    y_scale = height / static_cast<double>(i_height);
    
    i_width = width;
    i_height = height;
    frame_width = i_width / TOTAL_NUM_FRAMES;
    this->width = width;
    this->height = height;
    
    if(scale)
    {
        prepareSprites(frame_width);
    }
}
Пример #2
0
void BenchCairo::bench(BenchOutput& output, const BenchParams& params)
{
  if (screen.create(params.screenSize, params.format) != Fog::ERR_OK)
    return;

  switch (params.type)
  {
    case BENCH_TYPE_BLIT_IMAGE_I:
    case BENCH_TYPE_BLIT_IMAGE_F:
    case BENCH_TYPE_BLIT_IMAGE_ROTATE:
      prepareSprites(params.shapeSize);
      break;
  }

  screenCairo = cairo_image_surface_create_for_data(
    (unsigned char*)screen.getFirstX(),
    BenchCairo_getCairoFormat(params.format),
    screen.getWidth(),
    screen.getHeight(),
    (int)screen.getStride());

  if (screenCairo == NULL)
    return;

  screen.clear(Fog::Color(Fog::Argb32(0x00000000)));
  Fog::Time start(Fog::Time::now());

  switch (params.type)
  {
    case BENCH_TYPE_CREATE_DESTROY:
      runCreateDestroy(output, params);
      break;

    case BENCH_TYPE_FILL_RECT_I:
      runFillRectI(output, params);
      break;

    case BENCH_TYPE_FILL_RECT_F:
      runFillRectF(output, params);
      break;

    case BENCH_TYPE_FILL_RECT_ROTATE:
      runFillRectRotate(output, params);
      break;

    case BENCH_TYPE_FILL_ROUND:
      runFillRound(output, params);
      break;

    case BENCH_TYPE_FILL_POLYGON:
      runFillPolygon(output, params, 10);
      break;

    case BENCH_TYPE_FILL_COMPLEX:
      runFillPolygon(output, params, 100);
      break;

    case BENCH_TYPE_BLIT_IMAGE_I:
      runBlitImageI(output, params);
      break;

    case BENCH_TYPE_BLIT_IMAGE_F:
      runBlitImageF(output, params);
      break;

    case BENCH_TYPE_BLIT_IMAGE_ROTATE:
      runBlitImageRotate(output, params);
      break;
  }

  output.time = Fog::Time::now() - start;

  cairo_surface_destroy(screenCairo);
  screenCairo = NULL;

  freeSprites();
}