diff options
author | polina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-25 20:05:57 +0000 |
---|---|---|
committer | polina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-25 20:05:57 +0000 |
commit | 7809f208ae61ca3fb91e258a7d4700bd3a128656 (patch) | |
tree | c032bcd4d3f12e15eee1b23a27f621ae63fc4e67 /ppapi | |
parent | 973a79e520041d386ab4554c97ef80f537650c55 (diff) | |
download | chromium_src-7809f208ae61ca3fb91e258a7d4700bd3a128656.zip chromium_src-7809f208ae61ca3fb91e258a7d4700bd3a128656.tar.gz chromium_src-7809f208ae61ca3fb91e258a7d4700bd3a128656.tar.bz2 |
PPAPI NaCl Proxy: optimize PPB_Fullscreen::IsFullscreen.
Given the intended usage of the Fullscreen API, IsFullscreen is likely to be
called by the user within each DidChangeView to handle fullscreen mode changes.
Use DidChangeView RPC to keep track of the fullscreen state to avoid extra RPCs.
Implement IsFullscreen locally to just query that state.
BUG=101433
TEST=scons run_ppapi_ppb_fullscreen_browser_test
Review URL: http://codereview.chromium.org/8351023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
16 files changed, 47 insertions, 95 deletions
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_fullscreen_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_fullscreen_rpc_server.cc index 6a97097..4920606 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_fullscreen_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_fullscreen_rpc_server.cc @@ -13,23 +13,7 @@ using ppapi_proxy::DebugPrintf; using ppapi_proxy::PPBFullscreenInterface; -void PpbFullscreenRpcServer::PPB_Fullscreen_IsFullscreen( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - // inputs - PP_Instance instance, - // outputs - int32_t* success) { - NaClSrpcClosureRunner runner(done); - rpc->result = NACL_SRPC_RESULT_APP_ERROR; - - PP_Bool pp_success = PPBFullscreenInterface()->IsFullscreen(instance); - DebugPrintf("PPB_Fullscreen::IsFullscreen: pp_success=%d\n", pp_success); - - *success = (pp_success == PP_TRUE); - rpc->result = NACL_SRPC_RESULT_OK; -} - +// IsFullscreen is implemented via an extra flag to the DidChangeView proxy. void PpbFullscreenRpcServer::PPB_Fullscreen_SetFullscreen( NaClSrpcRpc* rpc, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_instance.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_instance.cc index 1b7b26d..933b973 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_instance.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_instance.cc @@ -123,7 +123,8 @@ void DidChangeView(PP_Instance instance, kPositionArraySize, position_array, kClipArraySize, - clip_array); + clip_array, + static_cast<int32_t>(PPBFullscreenInterface()->IsFullscreen(instance))); DebugPrintf("PPP_Instance::DidChangeView: %s\n", NaClSrpcErrorString(srpc_result)); } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.cc index d06d452..71e3241 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.cc @@ -1,7 +1,7 @@ /* - * Copyright 2011 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can - * be found in the LICENSE file. + * Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "native_client/src/shared/ppapi_proxy/plugin_instance_data.h" @@ -45,11 +45,21 @@ void PluginInstanceData::DidDestroy(PP_Instance id) { // static void PluginInstanceData::DidChangeView(PP_Instance id, PP_Rect position, - PP_Rect clip) { + PP_Rect clip, + bool is_fullscreen) { PluginInstanceData* instance = FromPP(id); if (instance) { - instance->set_position(position); + instance->position_ = position; + instance->is_fullscreen_ = is_fullscreen; } } +// static +bool PluginInstanceData::IsFullscreen(PP_Instance id) { + PluginInstanceData* instance = FromPP(id); + if (instance) + return instance->is_fullscreen_; + return false; +} + } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.h index c5e2288..412bccc 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_instance_data.h @@ -1,7 +1,7 @@ /* - * Copyright 2011 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can - * be found in the LICENSE file. + * Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_INSTANCE_DATA_H_ @@ -19,7 +19,9 @@ class PluginInstanceData { static PluginInstanceData* FromPP(PP_Instance id); static void DidCreate(PP_Instance id); static void DidDestroy(PP_Instance id); - static void DidChangeView(PP_Instance id, PP_Rect position, PP_Rect clip); + static void DidChangeView(PP_Instance id, PP_Rect position, PP_Rect clip, + bool is_fullscreen); + static bool IsFullscreen(PP_Instance id); PluginInstanceData(PP_Instance id) : id_(id), position_(PP_MakeRectFromXYWH(0, 0, 0, 0)) { @@ -28,13 +30,14 @@ class PluginInstanceData { PP_Instance id() { return id_; } PP_Rect position() { return position_; } - void set_position(PP_Rect position) { position_ = position; } + bool is_fullscreen() { return is_fullscreen_; } private: NACL_DISALLOW_COPY_AND_ASSIGN(PluginInstanceData); PP_Instance id_; PP_Rect position_; + bool is_fullscreen_; }; } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_fullscreen.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_fullscreen.cc index 478817f..7188ddd2 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_fullscreen.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_fullscreen.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "native_client/src/shared/ppapi_proxy/plugin_instance_data.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_fullscreen.h" #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" #include "native_client/src/shared/ppapi_proxy/utility.h" @@ -16,17 +17,7 @@ namespace { PP_Bool IsFullscreen(PP_Instance instance) { DebugPrintf("PPB_Fullscreen::IsFullscreen: instance=%"NACL_PRIu32"\n", instance); - - int32_t success; - NaClSrpcError srpc_result = - PpbFullscreenRpcClient::PPB_Fullscreen_IsFullscreen( - GetMainSrpcChannel(), instance, &success); - DebugPrintf("PPB_Fullscreen::IsFullscreen: %s\n", - NaClSrpcErrorString(srpc_result)); - - if (srpc_result == NACL_SRPC_RESULT_OK && success) - return PP_TRUE; - return PP_FALSE; + return PluginInstanceData::IsFullscreen(instance) ? PP_TRUE : PP_FALSE; } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_instance_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_instance_rpc_server.cc index 07fc8c6..3c443bf 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_instance_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_instance_rpc_server.cc @@ -115,7 +115,8 @@ void PppInstanceRpcServer::PPP_Instance_DidChangeView( // inputs PP_Instance instance_id, uint32_t position_count, int32_t* position, - uint32_t clip_count, int32_t* clip) { + uint32_t clip_count, int32_t* clip, + int32_t is_fullscreen) { const PP_Rect position_rect = PP_MakeRectFromXYWH(position[0], position[1], position[2], position[3]); const PP_Rect clip_rect = @@ -123,7 +124,8 @@ void PppInstanceRpcServer::PPP_Instance_DidChangeView( ppapi_proxy::PluginInstanceData::DidChangeView(instance_id, position_rect, - clip_rect); + clip_rect, + is_fullscreen); rpc->result = NACL_SRPC_RESULT_APP_ERROR; NaClSrpcClosureRunner runner(done); if (position_count != 4 || clip_count != 4) { diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_fullscreen.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_fullscreen.srpc index beb0e62..19ac4aa 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_fullscreen.srpc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_fullscreen.srpc @@ -7,12 +7,6 @@ { 'name': 'PpbFullscreenRpc', 'rpcs': [ - {'name': 'PPB_Fullscreen_IsFullscreen', - 'inputs': [['instance', 'PP_Instance'], # PP_Instance - ], - 'outputs': [['success', 'int32_t'], # PP_Bool - ] - }, {'name': 'PPB_Fullscreen_SetFullscreen', 'inputs': [['instance', 'PP_Instance'], # PP_Instance ['fullscreen', 'int32_t'], # PP_Bool diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc index a5b0c93..f4f0490 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc @@ -1120,23 +1120,6 @@ NaClSrpcError PpbFontRpcClient::PPB_Font_PixelOffsetForCharacter( return retval; } -NaClSrpcError PpbFullscreenRpcClient::PPB_Fullscreen_IsFullscreen( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success) { - VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), - ("%s: PPAPI calls are not supported off the main thread\n", - __FUNCTION__)); - NaClSrpcError retval; - retval = NaClSrpcInvokeBySignature( - channel, - "PPB_Fullscreen_IsFullscreen:i:i", - instance, - success - ); - return retval; -} - NaClSrpcError PpbFullscreenRpcClient::PPB_Fullscreen_SetFullscreen( NaClSrpcChannel* channel, PP_Instance instance, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc index abf8010..bdbb00e 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc @@ -903,20 +903,6 @@ static void PPB_Font_PixelOffsetForCharacterDispatcher( ); } -static void PPB_Fullscreen_IsFullscreenDispatcher( - NaClSrpcRpc* rpc, - NaClSrpcArg** inputs, - NaClSrpcArg** outputs, - NaClSrpcClosure* done -) { - PpbFullscreenRpcServer::PPB_Fullscreen_IsFullscreen( - rpc, - done, - inputs[0]->u.ival, - &(outputs[0]->u.ival) - ); -} - static void PPB_Fullscreen_SetFullscreenDispatcher( NaClSrpcRpc* rpc, NaClSrpcArg** inputs, @@ -2353,7 +2339,6 @@ NaClSrpcHandlerDesc PpbRpcs::srpc_methods[] = { { "PPB_Font_MeasureText:iCC:i", PPB_Font_MeasureTextDispatcher }, { "PPB_Font_CharacterOffsetForPixel:iCCi:i", PPB_Font_CharacterOffsetForPixelDispatcher }, { "PPB_Font_PixelOffsetForCharacter:iCCi:i", PPB_Font_PixelOffsetForCharacterDispatcher }, - { "PPB_Fullscreen_IsFullscreen:i:i", PPB_Fullscreen_IsFullscreenDispatcher }, { "PPB_Fullscreen_SetFullscreen:ii:i", PPB_Fullscreen_SetFullscreenDispatcher }, { "PPB_Fullscreen_GetScreenSize:i:Ci", PPB_Fullscreen_GetScreenSizeDispatcher }, { "PPB_Graphics2D_Create:iCi:i", PPB_Graphics2D_CreateDispatcher }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppp_instance.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppp_instance.srpc index f398643..1d54c92d 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppp_instance.srpc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppp_instance.srpc @@ -31,6 +31,9 @@ 'inputs': [['instance', 'PP_Instance'], # PP_Instance ['position', 'int32_t[]'], # PP_Rect* ['clip', 'int32_t[]'], # PP_Rect* + # This arg is not part of the API, but will help us + # avoid unnecessary PPB_Fullscreen::IsFullscreen RPCs. + ['is_fullscreen', 'int32_t' ] # PP_Bool ], 'outputs': [] }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc index 65ecfcf..8b0daac 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc @@ -216,14 +216,16 @@ NaClSrpcError PppInstanceRpcClient::PPP_Instance_DidChangeView( NaClSrpcChannel* channel, PP_Instance instance, nacl_abi_size_t position_bytes, int32_t* position, - nacl_abi_size_t clip_bytes, int32_t* clip) { + nacl_abi_size_t clip_bytes, int32_t* clip, + int32_t is_fullscreen) { NaClSrpcError retval; retval = NaClSrpcInvokeBySignature( channel, - "PPP_Instance_DidChangeView:iII:", + "PPP_Instance_DidChangeView:iIIi:", instance, position_bytes, position, - clip_bytes, clip + clip_bytes, clip, + is_fullscreen ); if (retval == NACL_SRPC_RESULT_INTERNAL) ppapi_proxy::CleanUpAfterDeadNexe(instance); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc index 3254aa7..4d0f962 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc @@ -207,7 +207,8 @@ static void PPP_Instance_DidChangeViewDispatcher( done, inputs[0]->u.ival, inputs[1]->u.count, inputs[1]->arrays.iarr, - inputs[2]->u.count, inputs[2]->arrays.iarr + inputs[2]->u.count, inputs[2]->arrays.iarr, + inputs[3]->u.ival ); } @@ -436,7 +437,7 @@ NaClSrpcHandlerDesc PppRpcs::srpc_methods[] = { { "PPP_InputEvent_HandleInputEvent:iiCC:i", PPP_InputEvent_HandleInputEventDispatcher }, { "PPP_Instance_DidCreate:iiCC:i", PPP_Instance_DidCreateDispatcher }, { "PPP_Instance_DidDestroy:i:", PPP_Instance_DidDestroyDispatcher }, - { "PPP_Instance_DidChangeView:iII:", PPP_Instance_DidChangeViewDispatcher }, + { "PPP_Instance_DidChangeView:iIIi:", PPP_Instance_DidChangeViewDispatcher }, { "PPP_Instance_DidChangeFocus:ib:", PPP_Instance_DidChangeFocusDispatcher }, { "PPP_Instance_HandleDocumentLoad:ii:i", PPP_Instance_HandleDocumentLoadDispatcher }, { "PPP_Messaging_HandleMessage:iC:", PPP_Messaging_HandleMessageDispatcher }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h index 4cb598b..46f80d1 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h @@ -468,11 +468,6 @@ class PpbFontRpcServer { class PpbFullscreenRpcServer { public: - static void PPB_Fullscreen_IsFullscreen( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success); static void PPB_Fullscreen_SetFullscreen( NaClSrpcRpc* rpc, NaClSrpcClosure* done, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h index c11c969..20782a8 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h @@ -125,7 +125,8 @@ class PppInstanceRpcClient { NaClSrpcChannel* channel, PP_Instance instance, nacl_abi_size_t position_bytes, int32_t* position, - nacl_abi_size_t clip_bytes, int32_t* clip); + nacl_abi_size_t clip_bytes, int32_t* clip, + int32_t is_fullscreen); static NaClSrpcError PPP_Instance_DidChangeFocus( NaClSrpcChannel* channel, PP_Instance instance, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h index 3446a97..aedb2da 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h @@ -410,10 +410,6 @@ class PpbFontRpcClient { class PpbFullscreenRpcClient { public: - static NaClSrpcError PPB_Fullscreen_IsFullscreen( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success); static NaClSrpcError PPB_Fullscreen_SetFullscreen( NaClSrpcChannel* channel, PP_Instance instance, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h index c6f6994..770447f 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h @@ -137,7 +137,8 @@ class PppInstanceRpcServer { NaClSrpcClosure* done, PP_Instance instance, nacl_abi_size_t position_bytes, int32_t* position, - nacl_abi_size_t clip_bytes, int32_t* clip); + nacl_abi_size_t clip_bytes, int32_t* clip, + int32_t is_fullscreen); static void PPP_Instance_DidChangeFocus( NaClSrpcRpc* rpc, NaClSrpcClosure* done, |