Home | History | Annotate | Download | only in thunk
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // From dev/ppb_widget_dev.idl modified Tue Apr 16 11:25:44 2013.
      6 
      7 #include "ppapi/c/dev/ppb_widget_dev.h"
      8 #include "ppapi/c/pp_errors.h"
      9 #include "ppapi/shared_impl/tracked_callback.h"
     10 #include "ppapi/thunk/enter.h"
     11 #include "ppapi/thunk/ppb_instance_api.h"
     12 #include "ppapi/thunk/ppb_widget_api.h"
     13 #include "ppapi/thunk/resource_creation_api.h"
     14 #include "ppapi/thunk/thunk.h"
     15 
     16 namespace ppapi {
     17 namespace thunk {
     18 
     19 namespace {
     20 
     21 PP_Bool IsWidget(PP_Resource resource) {
     22   VLOG(4) << "PPB_Widget_Dev::IsWidget()";
     23   EnterResource<PPB_Widget_API> enter(resource, false);
     24   return PP_FromBool(enter.succeeded());
     25 }
     26 
     27 PP_Bool Paint(PP_Resource widget,
     28               const struct PP_Rect* rect,
     29               PP_Resource image) {
     30   VLOG(4) << "PPB_Widget_Dev::Paint()";
     31   EnterResource<PPB_Widget_API> enter(widget, false);
     32   if (enter.failed())
     33     return PP_FALSE;
     34   return enter.object()->Paint(rect, image);
     35 }
     36 
     37 PP_Bool HandleEvent(PP_Resource widget, PP_Resource input_event) {
     38   VLOG(4) << "PPB_Widget_Dev::HandleEvent()";
     39   EnterResource<PPB_Widget_API> enter(widget, false);
     40   if (enter.failed())
     41     return PP_FALSE;
     42   return enter.object()->HandleEvent(input_event);
     43 }
     44 
     45 PP_Bool GetLocation(PP_Resource widget, struct PP_Rect* location) {
     46   VLOG(4) << "PPB_Widget_Dev::GetLocation()";
     47   EnterResource<PPB_Widget_API> enter(widget, false);
     48   if (enter.failed())
     49     return PP_FALSE;
     50   return enter.object()->GetLocation(location);
     51 }
     52 
     53 void SetLocation(PP_Resource widget, const struct PP_Rect* location) {
     54   VLOG(4) << "PPB_Widget_Dev::SetLocation()";
     55   EnterResource<PPB_Widget_API> enter(widget, false);
     56   if (enter.failed())
     57     return;
     58   enter.object()->SetLocation(location);
     59 }
     60 
     61 void SetScale(PP_Resource widget, float scale) {
     62   VLOG(4) << "PPB_Widget_Dev::SetScale()";
     63   EnterResource<PPB_Widget_API> enter(widget, false);
     64   if (enter.failed())
     65     return;
     66   enter.object()->SetScale(scale);
     67 }
     68 
     69 const PPB_Widget_Dev_0_3 g_ppb_widget_dev_thunk_0_3 = {
     70   &IsWidget,
     71   &Paint,
     72   &HandleEvent,
     73   &GetLocation,
     74   &SetLocation
     75 };
     76 
     77 const PPB_Widget_Dev_0_4 g_ppb_widget_dev_thunk_0_4 = {
     78   &IsWidget,
     79   &Paint,
     80   &HandleEvent,
     81   &GetLocation,
     82   &SetLocation,
     83   &SetScale
     84 };
     85 
     86 }  // namespace
     87 
     88 const PPB_Widget_Dev_0_3* GetPPB_Widget_Dev_0_3_Thunk() {
     89   return &g_ppb_widget_dev_thunk_0_3;
     90 }
     91 
     92 const PPB_Widget_Dev_0_4* GetPPB_Widget_Dev_0_4_Thunk() {
     93   return &g_ppb_widget_dev_thunk_0_4;
     94 }
     95 
     96 }  // namespace thunk
     97 }  // namespace ppapi
     98