Пример #1
0
static void Repaint(struct PepperState *mystate) {
  struct PP_Point topleft = PP_MakePoint(0, 0);
  struct PP_Rect rect = PP_MakeRectFromXYWH(0, 0,
                                            mystate->position.size.width,
                                            mystate->position.size.height);
  int show, render;

  /* Wait for previous rendering (if applicable) to finish */
  Earth_Sync();

  /* Double buffer - show previously rendered image. */
  show = mystate->which_image;
  mystate->graphics_2d_interface->PaintImageData(mystate->device_context,
                                                 mystate->image[show],
                                                 &topleft, &rect);
  int32_t ret;
  ret = mystate->graphics_2d_interface->Flush(mystate->device_context,
      PP_MakeCompletionCallback(&FlushCompletionCallback, mystate));

  /* Start Rendering into the other image while presenting. */
  render = (mystate->which_image + 1) % NUMBER_OF_IMAGES;

  Earth_Draw(mystate->image_data[render],
             mystate->position.size.width,
             mystate->position.size.height);

  /* In next callback, show what was rendered. */
  mystate->which_image = render;
}
Пример #2
0
static mrb_value
scroll(mrb_state *mrb, mrb_value self)
{
  mrb_value clip, amount;
  struct PP_Rect pp_rect;
  struct PP_Point pp_point;

  mrb_get_args(mrb, "oo", &clip, &amount);
  if (mrb_obj_is_instance_of(mrb, clip, mrb_pp_rect_class)) {
    int32_t x = mrb_fixnum(mrb_funcall(mrb, clip, "x", 0));
    int32_t y = mrb_fixnum(mrb_funcall(mrb, clip, "y", 0));
    int32_t w = mrb_fixnum(mrb_funcall(mrb, clip, "width", 0));
    int32_t h = mrb_fixnum(mrb_funcall(mrb, clip, "height", 0));
    pp_rect = PP_MakeRectFromXYWH(x, y, w, h);
  }
  else {
    mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a PP::Rect object", clip);
  }
  if (mrb_obj_is_instance_of(mrb, amount, mrb_pp_point_class)) {
    int32_t x = mrb_fixnum(mrb_funcall(mrb, amount, "x", 0));
    int32_t y = mrb_fixnum(mrb_funcall(mrb, amount, "y", 0));
    pp_point = PP_MakePoint(x, y);
  }
  else {
    mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a PP::Point object", amount);
  }

  PPB(Graphics2D)->Scroll(MRB_PP_RESOURCE(self), &pp_rect, &pp_point);

  return mrb_nil_value();
}
Пример #3
0
static mrb_value
paint_image_data(mrb_state *mrb, mrb_value self)
{
  mrb_value image, top_left, src_rect = mrb_nil_value();
  PP_Resource image_data = 0;
  struct PP_Point pp_point;
  struct PP_Rect pp_rect;

  mrb_get_args(mrb, "oo|o", &image, &top_left, &src_rect);
  if (mrb_obj_is_instance_of(mrb, image, mrb_pp_image_data_class)) {
    image_data = MRB_PP_RESOURCE(image);
  }
  else {
    mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a PP::Image object", image);
  }
  if (mrb_obj_is_instance_of(mrb, top_left, mrb_pp_point_class)) {
    int32_t x = mrb_fixnum(mrb_funcall(mrb, top_left, "x", 0));
    int32_t y = mrb_fixnum(mrb_funcall(mrb, top_left, "y", 0));
    pp_point = PP_MakePoint(x, y);
  }
  else {
    mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a PP::Point object", top_left);
  }
  if (!mrb_nil_p(src_rect)) {
    if (mrb_obj_is_instance_of(mrb, src_rect, mrb_pp_rect_class)) {
      int32_t x = mrb_fixnum(mrb_funcall(mrb, src_rect, "x", 0));
      int32_t y = mrb_fixnum(mrb_funcall(mrb, src_rect, "y", 0));
      int32_t w = mrb_fixnum(mrb_funcall(mrb, src_rect, "width", 0));
      int32_t h = mrb_fixnum(mrb_funcall(mrb, src_rect, "height", 0));
      pp_rect = PP_MakeRectFromXYWH(x, y, w, h);
    }
    else {
      mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a PP::Rect object", src_rect);
    }
  }

  if (mrb_nil_p(src_rect)) {
    PPB(Graphics2D)->
      PaintImageData(MRB_PP_RESOURCE(self), image_data, &pp_point, NULL);
  }
  else {
    PPB(Graphics2D)->
      PaintImageData(MRB_PP_RESOURCE(self), image_data, &pp_point, &pp_rect);
  }

  return mrb_nil_value();
}