Exemplo n.º 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;
}
Exemplo n.º 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();
}
Exemplo n.º 3
0
struct PP_Point
ppb_mouse_input_event_get_position(PP_Resource mouse_event)
{
    struct pp_input_event_s *ie = pp_resource_acquire(mouse_event, PP_RESOURCE_INPUT_EVENT);
    if (!ie) {
        trace_error("%s, bad resource\n", __func__);
        return PP_MakePoint(0, 0);
    }
    if (ie->event_class != PP_INPUTEVENT_CLASS_MOUSE) {
        trace_error("%s, not a mouse event\n", __func__);
        pp_resource_release(mouse_event);
        return PP_MakePoint(0, 0);
    }

    struct PP_Point res = PP_MakePoint(ie->mouse_position.x, ie->mouse_position.y);
    pp_resource_release(mouse_event);
    return res;
}
Exemplo n.º 4
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();
}
Exemplo n.º 5
0
struct PP_Point
ppb_mouse_input_event_get_movement(PP_Resource mouse_event)
{
    return PP_MakePoint(0, 0);
}