| 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 "native_client/src/shared/ppapi_proxy/plugin_ppb_view.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_view.h" |
| 6 | 6 |
| 7 #include "native_client/src/include/portability.h" | 7 #include "native_client/src/include/portability.h" |
| 8 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 8 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
| 9 #include "native_client/src/shared/ppapi_proxy/plugin_upcall.h" | 9 #include "native_client/src/shared/ppapi_proxy/plugin_upcall.h" |
| 10 #include "native_client/src/shared/ppapi_proxy/utility.h" | 10 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 11 #include "native_client/src/shared/srpc/nacl_srpc.h" | 11 #include "native_client/src/shared/srpc/nacl_srpc.h" |
| 12 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
| 13 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
| 14 #include "ppapi/c/pp_rect.h" | 14 #include "ppapi/c/pp_rect.h" |
| 15 #include "ppapi/c/pp_size.h" | 15 #include "ppapi/c/pp_size.h" |
| 16 #include "srpcgen/ppb_rpc.h" | 16 #include "srpcgen/ppb_rpc.h" |
| 17 #include "srpcgen/upcall.h" | 17 #include "srpcgen/upcall.h" |
| 18 | 18 |
| 19 namespace ppapi_proxy { | 19 namespace ppapi_proxy { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class ViewGetter { | 23 class ViewGetter { |
| 24 public: | 24 public: |
| 25 ViewGetter(PP_Resource resource, const char* function_name) { | 25 ViewGetter(PP_Resource resource, const char* function_name) { |
| 26 DebugPrintf("PPB_View::%s: resource=%"NACL_PRIu32"\n", | 26 DebugPrintf("PPB_View::%s: resource=%"NACL_PRId32"\n", |
| 27 function_name, | 27 function_name, |
| 28 resource); | 28 resource); |
| 29 view_ = PluginResource::GetAs<PluginView>(resource); | 29 view_ = PluginResource::GetAs<PluginView>(resource); |
| 30 } | 30 } |
| 31 | 31 |
| 32 PluginView* get() { return view_.get(); } | 32 PluginView* get() { return view_.get(); } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 NACL_DISALLOW_COPY_AND_ASSIGN(ViewGetter); | 35 NACL_DISALLOW_COPY_AND_ASSIGN(ViewGetter); |
| 36 scoped_refptr<PluginView> view_; | 36 scoped_refptr<PluginView> view_; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // This macro is for starting a resource function. It makes sure resource_arg | 39 // This macro is for starting a resource function. It makes sure resource_arg |
| 40 // is of type PluginView, and returns error_return if it's not. | 40 // is of type PluginView, and returns error_return if it's not. |
| 41 #define BEGIN_RESOURCE_THUNK(function_name, resource_arg, error_return) \ | 41 #define BEGIN_RESOURCE_THUNK(function_name, resource_arg, error_return) \ |
| 42 ViewGetter view(resource_arg, function_name); \ | 42 ViewGetter view(resource_arg, function_name); \ |
| 43 if (!view.get()) { \ | 43 if (!view.get()) { \ |
| 44 return error_return; \ | 44 return error_return; \ |
| 45 } | 45 } |
| 46 | 46 |
| 47 PP_Bool IsView(PP_Resource resource) { | 47 PP_Bool IsView(PP_Resource resource) { |
| 48 DebugPrintf("PPB_View::IsView: resource=%"NACL_PRIu32"\n", | 48 DebugPrintf("PPB_View::IsView: resource=%"NACL_PRId32"\n", |
| 49 resource); | 49 resource); |
| 50 return PluginResource::GetAs<PluginView>(resource).get() | 50 return PP_FromBool(PluginResource::GetAs<PluginView>(resource).get()); |
| 51 ? PP_TRUE : PP_FALSE; | |
| 52 } | 51 } |
| 53 | 52 |
| 54 PP_Bool GetRect(PP_Resource resource, PP_Rect* viewport) { | 53 PP_Bool GetRect(PP_Resource resource, PP_Rect* viewport) { |
| 55 BEGIN_RESOURCE_THUNK("GetRect", resource, PP_FALSE); | 54 BEGIN_RESOURCE_THUNK("GetRect", resource, PP_FALSE); |
| 56 *viewport = view.get()->view_data().viewport_rect; | 55 *viewport = view.get()->view_data().viewport_rect; |
| 57 return PP_TRUE; | 56 return PP_TRUE; |
| 58 } | 57 } |
| 59 | 58 |
| 60 PP_Bool IsFullscreen(PP_Resource resource) { | 59 PP_Bool IsFullscreen(PP_Resource resource) { |
| 61 BEGIN_RESOURCE_THUNK("IsFullscreen", resource, PP_FALSE); | 60 BEGIN_RESOURCE_THUNK("IsFullscreen", resource, PP_FALSE); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 &GetRect, | 98 &GetRect, |
| 100 &IsFullscreen, | 99 &IsFullscreen, |
| 101 &IsUserVisible, | 100 &IsUserVisible, |
| 102 &IsPageVisible, | 101 &IsPageVisible, |
| 103 &GetClipRect | 102 &GetClipRect |
| 104 }; | 103 }; |
| 105 return &view_interface; | 104 return &view_interface; |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace ppapi_proxy | 107 } // namespace ppapi_proxy |
| OLD | NEW |