| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/cpp/dev/widget_dev.h" | 5 #include "ppapi/cpp/dev/widget_dev.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_widget_dev.h" | 7 #include "ppapi/c/dev/ppb_widget_dev.h" |
| 8 #include "ppapi/cpp/image_data.h" | 8 #include "ppapi/cpp/image_data.h" |
| 9 #include "ppapi/cpp/input_event.h" | 9 #include "ppapi/cpp/input_event.h" |
| 10 #include "ppapi/cpp/instance.h" | 10 #include "ppapi/cpp/instance.h" |
| 11 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
| 12 #include "ppapi/cpp/rect.h" | 12 #include "ppapi/cpp/rect.h" |
| 13 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
| 14 | 14 |
| 15 namespace pp { | 15 namespace pp { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 template <> const char* interface_name<PPB_Widget_Dev>() { | 19 template <> const char* interface_name<PPB_Widget_Dev_0_3>() { |
| 20 return PPB_WIDGET_DEV_INTERFACE; | 20 return PPB_WIDGET_DEV_INTERFACE_0_3; |
| 21 } |
| 22 |
| 23 template <> const char* interface_name<PPB_Widget_Dev_0_4>() { |
| 24 return PPB_WIDGET_DEV_INTERFACE_0_4; |
| 21 } | 25 } |
| 22 | 26 |
| 23 } // namespace | 27 } // namespace |
| 24 | 28 |
| 25 Widget_Dev::Widget_Dev(PP_Resource resource) : Resource(resource) { | 29 Widget_Dev::Widget_Dev(PP_Resource resource) : Resource(resource) { |
| 26 } | 30 } |
| 27 | 31 |
| 28 Widget_Dev::Widget_Dev(const Widget_Dev& other) : Resource(other) { | 32 Widget_Dev::Widget_Dev(const Widget_Dev& other) : Resource(other) { |
| 29 } | 33 } |
| 30 | 34 |
| 31 bool Widget_Dev::Paint(const Rect& rect, ImageData* image) { | 35 bool Widget_Dev::Paint(const Rect& rect, ImageData* image) { |
| 32 if (!has_interface<PPB_Widget_Dev>()) | 36 if (has_interface<PPB_Widget_Dev_0_4>()) { |
| 33 return false; | 37 return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->Paint( |
| 34 return PP_ToBool(get_interface<PPB_Widget_Dev>()->Paint( | 38 pp_resource(), &rect.pp_rect(), image->pp_resource())); |
| 35 pp_resource(), &rect.pp_rect(), image->pp_resource())); | 39 } else if (has_interface<PPB_Widget_Dev_0_3>()) { |
| 40 return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->Paint( |
| 41 pp_resource(), &rect.pp_rect(), image->pp_resource())); |
| 42 } |
| 43 return false; |
| 36 } | 44 } |
| 37 | 45 |
| 38 bool Widget_Dev::HandleEvent(const InputEvent& event) { | 46 bool Widget_Dev::HandleEvent(const InputEvent& event) { |
| 39 if (!has_interface<PPB_Widget_Dev>()) | 47 if (has_interface<PPB_Widget_Dev_0_4>()) { |
| 40 return false; | 48 return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->HandleEvent( |
| 41 return PP_ToBool(get_interface<PPB_Widget_Dev>()->HandleEvent( | 49 pp_resource(), event.pp_resource())); |
| 42 pp_resource(), event.pp_resource())); | 50 } else if (has_interface<PPB_Widget_Dev_0_3>()) { |
| 51 return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->HandleEvent( |
| 52 pp_resource(), event.pp_resource())); |
| 53 } |
| 54 return false; |
| 43 } | 55 } |
| 44 | 56 |
| 45 bool Widget_Dev::GetLocation(Rect* location) { | 57 bool Widget_Dev::GetLocation(Rect* location) { |
| 46 if (!has_interface<PPB_Widget_Dev>()) | 58 if (has_interface<PPB_Widget_Dev_0_4>()) { |
| 47 return false; | 59 return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->GetLocation( |
| 48 return PP_ToBool(get_interface<PPB_Widget_Dev>()->GetLocation( | 60 pp_resource(), &location->pp_rect())); |
| 49 pp_resource(), &location->pp_rect())); | 61 } else if (has_interface<PPB_Widget_Dev_0_3>()) { |
| 62 return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->GetLocation( |
| 63 pp_resource(), &location->pp_rect())); |
| 64 } |
| 65 return false; |
| 50 } | 66 } |
| 51 | 67 |
| 52 void Widget_Dev::SetLocation(const Rect& location) { | 68 void Widget_Dev::SetLocation(const Rect& location) { |
| 53 if (has_interface<PPB_Widget_Dev>()) | 69 if (has_interface<PPB_Widget_Dev_0_4>()) { |
| 54 get_interface<PPB_Widget_Dev>()->SetLocation(pp_resource(), | 70 get_interface<PPB_Widget_Dev_0_4>()->SetLocation(pp_resource(), |
| 55 &location.pp_rect()); | 71 &location.pp_rect()); |
| 72 } else if (has_interface<PPB_Widget_Dev_0_3>()) { |
| 73 get_interface<PPB_Widget_Dev_0_3>()->SetLocation(pp_resource(), |
| 74 &location.pp_rect()); |
| 75 } |
| 76 } |
| 77 |
| 78 void Widget_Dev::SetScale(float scale) { |
| 79 if (has_interface<PPB_Widget_Dev_0_4>()) |
| 80 get_interface<PPB_Widget_Dev_0_4>()->SetScale(pp_resource(), scale); |
| 56 } | 81 } |
| 57 | 82 |
| 58 } // namespace pp | 83 } // namespace pp |
| OLD | NEW |