| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/instance.h" | 5 #include "ppapi/cpp/instance.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_input_event.h" | 8 #include "ppapi/c/ppb_input_event.h" |
| 9 #include "ppapi/c/ppb_instance.h" | 9 #include "ppapi/c/ppb_instance.h" |
| 10 #include "ppapi/c/ppb_messaging.h" | 10 #include "ppapi/c/ppb_messaging.h" |
| 11 #include "ppapi/cpp/graphics_2d.h" | 11 #include "ppapi/cpp/graphics_2d.h" |
| 12 #include "ppapi/cpp/graphics_3d.h" | 12 #include "ppapi/cpp/graphics_3d.h" |
| 13 #include "ppapi/cpp/image_data.h" | 13 #include "ppapi/cpp/image_data.h" |
| 14 #include "ppapi/cpp/instance_handle.h" | 14 #include "ppapi/cpp/instance_handle.h" |
| 15 #include "ppapi/cpp/logging.h" | 15 #include "ppapi/cpp/logging.h" |
| 16 #include "ppapi/cpp/module.h" | 16 #include "ppapi/cpp/module.h" |
| 17 #include "ppapi/cpp/module_impl.h" | 17 #include "ppapi/cpp/module_impl.h" |
| 18 #include "ppapi/cpp/point.h" | 18 #include "ppapi/cpp/point.h" |
| 19 #include "ppapi/cpp/resource.h" | 19 #include "ppapi/cpp/resource.h" |
| 20 #include "ppapi/cpp/var.h" | 20 #include "ppapi/cpp/var.h" |
| 21 #include "ppapi/cpp/view.h" | 21 #include "ppapi/cpp/view.h" |
| 22 | 22 |
| 23 namespace pp { | 23 namespace pp { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 template <> const char* interface_name<PPB_InputEvent>() { | 27 template <> const char* interface_name<PPB_InputEvent_1_0>() { |
| 28 return PPB_INPUT_EVENT_INTERFACE; | 28 return PPB_INPUT_EVENT_INTERFACE_1_0; |
| 29 } | 29 } |
| 30 | 30 |
| 31 template <> const char* interface_name<PPB_Instance>() { | 31 template <> const char* interface_name<PPB_Instance_1_0>() { |
| 32 return PPB_INSTANCE_INTERFACE; | 32 return PPB_INSTANCE_INTERFACE_1_0; |
| 33 } | 33 } |
| 34 | 34 |
| 35 template <> const char* interface_name<PPB_Messaging>() { | 35 template <> const char* interface_name<PPB_Messaging_1_0>() { |
| 36 return PPB_MESSAGING_INTERFACE; | 36 return PPB_MESSAGING_INTERFACE_1_0; |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 Instance::Instance(PP_Instance instance) : pp_instance_(instance) { | 41 Instance::Instance(PP_Instance instance) : pp_instance_(instance) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 Instance::~Instance() { | 44 Instance::~Instance() { |
| 45 } | 45 } |
| 46 | 46 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 | 68 |
| 69 bool Instance::HandleInputEvent(const InputEvent& /*event*/) { | 69 bool Instance::HandleInputEvent(const InputEvent& /*event*/) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void Instance::HandleMessage(const Var& /*message*/) { | 73 void Instance::HandleMessage(const Var& /*message*/) { |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool Instance::BindGraphics(const Graphics2D& graphics) { | 77 bool Instance::BindGraphics(const Graphics2D& graphics) { |
| 78 if (!has_interface<PPB_Instance>()) | 78 if (!has_interface<PPB_Instance_1_0>()) |
| 79 return false; | 79 return false; |
| 80 return PP_ToBool(get_interface<PPB_Instance>()->BindGraphics( | 80 return PP_ToBool(get_interface<PPB_Instance_1_0>()->BindGraphics( |
| 81 pp_instance(), graphics.pp_resource())); | 81 pp_instance(), graphics.pp_resource())); |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool Instance::BindGraphics(const Graphics3D& graphics) { | 84 bool Instance::BindGraphics(const Graphics3D& graphics) { |
| 85 if (!has_interface<PPB_Instance>()) | 85 if (!has_interface<PPB_Instance_1_0>()) |
| 86 return false; | 86 return false; |
| 87 return PP_ToBool(get_interface<PPB_Instance>()->BindGraphics( | 87 return PP_ToBool(get_interface<PPB_Instance_1_0>()->BindGraphics( |
| 88 pp_instance(), graphics.pp_resource())); | 88 pp_instance(), graphics.pp_resource())); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool Instance::IsFullFrame() { | 91 bool Instance::IsFullFrame() { |
| 92 if (!has_interface<PPB_Instance>()) | 92 if (!has_interface<PPB_Instance_1_0>()) |
| 93 return false; | 93 return false; |
| 94 return PP_ToBool(get_interface<PPB_Instance>()->IsFullFrame(pp_instance())); | 94 return PP_ToBool(get_interface<PPB_Instance_1_0>()->IsFullFrame( |
| 95 pp_instance())); |
| 95 } | 96 } |
| 96 | 97 |
| 97 int32_t Instance::RequestInputEvents(uint32_t event_classes) { | 98 int32_t Instance::RequestInputEvents(uint32_t event_classes) { |
| 98 if (!has_interface<PPB_InputEvent>()) | 99 if (!has_interface<PPB_InputEvent_1_0>()) |
| 99 return PP_ERROR_NOINTERFACE; | 100 return PP_ERROR_NOINTERFACE; |
| 100 return get_interface<PPB_InputEvent>()->RequestInputEvents(pp_instance(), | 101 return get_interface<PPB_InputEvent_1_0>()->RequestInputEvents(pp_instance(), |
| 101 event_classes); | 102 event_classes); |
| 102 } | 103 } |
| 103 | 104 |
| 104 int32_t Instance::RequestFilteringInputEvents(uint32_t event_classes) { | 105 int32_t Instance::RequestFilteringInputEvents(uint32_t event_classes) { |
| 105 if (!has_interface<PPB_InputEvent>()) | 106 if (!has_interface<PPB_InputEvent_1_0>()) |
| 106 return PP_ERROR_NOINTERFACE; | 107 return PP_ERROR_NOINTERFACE; |
| 107 return get_interface<PPB_InputEvent>()->RequestFilteringInputEvents( | 108 return get_interface<PPB_InputEvent_1_0>()->RequestFilteringInputEvents( |
| 108 pp_instance(), event_classes); | 109 pp_instance(), event_classes); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void Instance::ClearInputEventRequest(uint32_t event_classes) { | 112 void Instance::ClearInputEventRequest(uint32_t event_classes) { |
| 112 if (!has_interface<PPB_InputEvent>()) | 113 if (!has_interface<PPB_InputEvent_1_0>()) |
| 113 return; | 114 return; |
| 114 get_interface<PPB_InputEvent>()->ClearInputEventRequest(pp_instance(), | 115 get_interface<PPB_InputEvent_1_0>()->ClearInputEventRequest(pp_instance(), |
| 115 event_classes); | 116 event_classes); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void Instance::PostMessage(const Var& message) { | 119 void Instance::PostMessage(const Var& message) { |
| 119 if (!has_interface<PPB_Messaging>()) | 120 if (!has_interface<PPB_Messaging_1_0>()) |
| 120 return; | 121 return; |
| 121 get_interface<PPB_Messaging>()->PostMessage(pp_instance(), | 122 get_interface<PPB_Messaging_1_0>()->PostMessage(pp_instance(), |
| 122 message.pp_var()); | 123 message.pp_var()); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void Instance::AddPerInstanceObject(const std::string& interface_name, | 126 void Instance::AddPerInstanceObject(const std::string& interface_name, |
| 126 void* object) { | 127 void* object) { |
| 127 // Ensure we're not trying to register more than one object per interface | 128 // Ensure we're not trying to register more than one object per interface |
| 128 // type. Otherwise, we'll get confused in GetPerInstanceObject. | 129 // type. Otherwise, we'll get confused in GetPerInstanceObject. |
| 129 PP_DCHECK(interface_name_to_objects_.find(interface_name) == | 130 PP_DCHECK(interface_name_to_objects_.find(interface_name) == |
| 130 interface_name_to_objects_.end()); | 131 interface_name_to_objects_.end()); |
| 131 interface_name_to_objects_[interface_name] = object; | 132 interface_name_to_objects_[interface_name] = object; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (!that) | 168 if (!that) |
| 168 return NULL; | 169 return NULL; |
| 169 InterfaceNameToObjectMap::iterator found = | 170 InterfaceNameToObjectMap::iterator found = |
| 170 that->interface_name_to_objects_.find(interface_name); | 171 that->interface_name_to_objects_.find(interface_name); |
| 171 if (found == that->interface_name_to_objects_.end()) | 172 if (found == that->interface_name_to_objects_.end()) |
| 172 return NULL; | 173 return NULL; |
| 173 return found->second; | 174 return found->second; |
| 174 } | 175 } |
| 175 | 176 |
| 176 } // namespace pp | 177 } // namespace pp |
| OLD | NEW |