Skip to content

Commit

Permalink
Add implementations for Fullscreen and CursorControl interfaces.
Browse files Browse the repository at this point in the history
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/4809002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65856 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Nov 11, 2010
1 parent 933d320 commit 54796ef
Show file tree
Hide file tree
Showing 8 changed files with 344 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ppapi/ppapi.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,12 @@
'proxy/ppb_char_set_proxy.h',
'proxy/ppb_core_proxy.cc',
'proxy/ppb_core_proxy.h',
'proxy/ppb_cursor_control_proxy.cc',
'proxy/ppb_cursor_control_proxy.h',
'proxy/ppb_font_proxy.cc',
'proxy/ppb_font_proxy.h',
'proxy/ppb_fullscreen_proxy.cc',
'proxy/ppb_fullscreen_proxy.h',
'proxy/ppb_graphics_2d_proxy.cc',
'proxy/ppb_graphics_2d_proxy.h',
'proxy/ppb_image_data_proxy.cc',
Expand Down
8 changes: 8 additions & 0 deletions ppapi/proxy/dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "ipc/ipc_sync_channel.h"
#include "ppapi/c/dev/ppb_char_set_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/pp_errors.h"
Expand All @@ -28,7 +30,9 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppb_char_set_proxy.h"
#include "ppapi/proxy/ppb_core_proxy.h"
#include "ppapi/proxy/ppb_cursor_control_proxy.h"
#include "ppapi/proxy/ppb_font_proxy.h"
#include "ppapi/proxy/ppb_fullscreen_proxy.h"
#include "ppapi/proxy/ppb_graphics_2d_proxy.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/proxy/ppb_instance_proxy.h"
Expand Down Expand Up @@ -210,8 +214,12 @@ InterfaceProxy* Dispatcher::CreateProxyForInterface(
return new PPB_CharSet_Proxy(this, interface_functions);
if (interface_name == PPB_CORE_INTERFACE)
return new PPB_Core_Proxy(this, interface_functions);
if (interface_name == PPB_CURSOR_CONTROL_DEV_INTERFACE)
return new PPB_CursorControl_Proxy(this, interface_functions);
if (interface_name == PPB_FONT_DEV_INTERFACE)
return new PPB_Font_Proxy(this, interface_functions);
if (interface_name == PPB_FULLSCREEN_DEV_INTERFACE)
return new PPB_Fullscreen_Proxy(this, interface_functions);
if (interface_name == PPB_GRAPHICS_2D_INTERFACE)
return new PPB_Graphics2D_Proxy(this, interface_functions);
if (interface_name == PPB_IMAGEDATA_INTERFACE)
Expand Down
2 changes: 2 additions & 0 deletions ppapi/proxy/interface_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ enum InterfaceID {
// Zero is reserved for control messages.
INTERFACE_ID_PPB_CHAR_SET = 1,
INTERFACE_ID_PPB_CORE,
INTERFACE_ID_PPB_CURSORCONTROL,
INTERFACE_ID_PPB_FONT,
INTERFACE_ID_PPB_FULLSCREEN,
INTERFACE_ID_PPB_GRAPHICS_2D,
INTERFACE_ID_PPB_IMAGE_DATA,
INTERFACE_ID_PPB_INSTANCE,
Expand Down
28 changes: 28 additions & 0 deletions ppapi/proxy/ppapi_messages_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ IPC_BEGIN_MESSAGES(PpapiHost)
PP_Module /* module */,
pp::proxy::SerializedVar /* result */)

// PPB_CursorControl.
IPC_SYNC_MESSAGE_ROUTED4_1(PpapiHostMsg_PPBCursorControl_SetCursor,
PP_Instance /* instance */,
int32_t /* type */,
PP_Resource /* custom_image */,
PP_Point /* hot_spot */,
PP_Bool /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_LockCursor,
PP_Instance /* instance */,
PP_Bool /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_UnlockCursor,
PP_Instance /* instance */,
PP_Bool /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_HasCursorLock,
PP_Instance /* instance */,
PP_Bool /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_CanLockCursor,
PP_Instance /* instance */,
PP_Bool /* result */)

// PPB_Font.
IPC_SYNC_MESSAGE_ROUTED2_3(
PpapiHostMsg_PPBFont_Create,
Expand Down Expand Up @@ -191,6 +211,14 @@ IPC_BEGIN_MESSAGES(PpapiHost)
uint32_t /* char_offset */,
int32_t /* result */)

// PPB_Fullscreen.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFullscreen_IsFullscreen,
PP_Instance /* instance */,
PP_Bool /* result */)
IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFullscreen_SetFullscreen,
PP_Instance /* instance */,
PP_Bool /* fullscreen */,
PP_Bool /* result */)

// PPB_Graphics2D.
IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics2D_Create,
Expand Down
129 changes: 129 additions & 0 deletions ppapi/proxy/ppb_cursor_control_proxy.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright (c) 2010 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 "ppapi/proxy/ppb_cursor_control_proxy.h"

#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"

namespace pp {
namespace proxy {

namespace {

PP_Bool SetCursor(PP_Instance instance_id,
PP_CursorType_Dev type,
PP_Resource custom_image_id,
const PP_Point* hot_spot) {
PP_Bool result = PP_FALSE;
PP_Point empty_point = { 0, 0 };
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCursorControl_SetCursor(
INTERFACE_ID_PPB_CURSORCONTROL,
instance_id, static_cast<int32_t>(type), custom_image_id,
hot_spot ? *hot_spot : empty_point, &result));
return result;
}

PP_Bool LockCursor(PP_Instance instance_id) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCursorControl_LockCursor(
INTERFACE_ID_PPB_CURSORCONTROL, instance_id, &result));
return result;
}

PP_Bool UnlockCursor(PP_Instance instance_id) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCursorControl_UnlockCursor(
INTERFACE_ID_PPB_CURSORCONTROL, instance_id, &result));
return result;
}

PP_Bool HasCursorLock(PP_Instance instance_id) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCursorControl_HasCursorLock(
INTERFACE_ID_PPB_CURSORCONTROL, instance_id, &result));
return result;
}

PP_Bool CanLockCursor(PP_Instance instance_id) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCursorControl_CanLockCursor(
INTERFACE_ID_PPB_CURSORCONTROL, instance_id, &result));
return result;
}

const PPB_CursorControl_Dev cursor_control_interface = {
&SetCursor,
&LockCursor,
&UnlockCursor,
&HasCursorLock,
&CanLockCursor
};

} // namespace

PPB_CursorControl_Proxy::PPB_CursorControl_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}

PPB_CursorControl_Proxy::~PPB_CursorControl_Proxy() {
}

const void* PPB_CursorControl_Proxy::GetSourceInterface() const {
return &cursor_control_interface;
}

InterfaceID PPB_CursorControl_Proxy::GetInterfaceId() const {
return INTERFACE_ID_PPB_CURSORCONTROL;
}

void PPB_CursorControl_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PPB_CursorControl_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_SetCursor,
OnMsgSetCursor)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_LockCursor,
OnMsgLockCursor)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_UnlockCursor,
OnMsgUnlockCursor)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_HasCursorLock,
OnMsgHasCursorLock)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_CanLockCursor,
OnMsgCanLockCursor)
IPC_END_MESSAGE_MAP()
// TODO(brettw): handle bad messages!
}

void PPB_CursorControl_Proxy::OnMsgSetCursor(PP_Instance instance,
int32_t type,
PP_Resource custom_image,
const PP_Point& hot_spot,
PP_Bool* result) {
*result = ppb_cursor_control_target()->SetCursor(
instance, static_cast<PP_CursorType_Dev>(type), custom_image, &hot_spot);
}

void PPB_CursorControl_Proxy::OnMsgLockCursor(PP_Instance instance,
PP_Bool* result) {
*result = ppb_cursor_control_target()->LockCursor(instance);
}

void PPB_CursorControl_Proxy::OnMsgUnlockCursor(PP_Instance instance,
PP_Bool* result) {
*result = ppb_cursor_control_target()->UnlockCursor(instance);
}

void PPB_CursorControl_Proxy::OnMsgHasCursorLock(PP_Instance instance,
PP_Bool* result) {
*result = ppb_cursor_control_target()->HasCursorLock(instance);
}

void PPB_CursorControl_Proxy::OnMsgCanLockCursor(PP_Instance instance,
PP_Bool* result) {
*result = ppb_cursor_control_target()->CanLockCursor(instance);
}

} // namespace proxy
} // namespace pp
54 changes: 54 additions & 0 deletions ppapi/proxy/ppb_cursor_control_proxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2010 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 PPAPI_PPB_CURSOR_CONTROL_PROXY_H_
#define PPAPI_PPB_CURSOR_CONTROL_PROXY_H_

#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/proxy/interface_proxy.h"

struct PPB_CursorControl_Dev;

namespace pp {
namespace proxy {

class PPB_CursorControl_Proxy : public InterfaceProxy {
public:
PPB_CursorControl_Proxy(Dispatcher* dispatcher, const void* target_interface);
virtual ~PPB_CursorControl_Proxy();

const PPB_CursorControl_Dev* ppb_cursor_control_target() const {
return reinterpret_cast<const PPB_CursorControl_Dev*>(target_interface());
}

// InterfaceProxy implementation.
virtual const void* GetSourceInterface() const;
virtual InterfaceID GetInterfaceId() const;
virtual void OnMessageReceived(const IPC::Message& msg);

private:
// Message handlers.
void OnMsgSetCursor(PP_Instance instance,
int32_t type,
PP_Resource custom_image,
const PP_Point& hot_spot,
PP_Bool* result);
void OnMsgLockCursor(PP_Instance instance,
PP_Bool* result);
void OnMsgUnlockCursor(PP_Instance instance,
PP_Bool* result);
void OnMsgHasCursorLock(PP_Instance instance,
PP_Bool* result);
void OnMsgCanLockCursor(PP_Instance instance,
PP_Bool* result);
};

} // namespace proxy
} // namespace pp

#endif // PPAPI_PPB_CURSOR_CONTROL_PROXY_H_
75 changes: 75 additions & 0 deletions ppapi/proxy/ppb_fullscreen_proxy.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2010 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 "ppapi/proxy/ppb_fullscreen_proxy.h"

#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"

namespace pp {
namespace proxy {

namespace {

PP_Bool IsFullscreen(PP_Instance instance) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFullscreen_IsFullscreen(
INTERFACE_ID_PPB_FULLSCREEN, instance, &result));
return result;
}

PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFullscreen_SetFullscreen(
INTERFACE_ID_PPB_FULLSCREEN, instance, fullscreen, &result));
return result;
}

const PPB_Fullscreen_Dev ppb_fullscreen = {
&IsFullscreen,
&SetFullscreen
};

} // namespace

PPB_Fullscreen_Proxy::PPB_Fullscreen_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}

PPB_Fullscreen_Proxy::~PPB_Fullscreen_Proxy() {
}

const void* PPB_Fullscreen_Proxy::GetSourceInterface() const {
return &ppb_fullscreen;
}

InterfaceID PPB_Fullscreen_Proxy::GetInterfaceId() const {
return INTERFACE_ID_PPB_FULLSCREEN;
}

void PPB_Fullscreen_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PPB_Fullscreen_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFullscreen_IsFullscreen,
OnMsgIsFullscreen)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFullscreen_SetFullscreen,
OnMsgSetFullscreen)
IPC_END_MESSAGE_MAP()
// TODO(brettw): handle bad messages!
}

void PPB_Fullscreen_Proxy::OnMsgIsFullscreen(PP_Instance instance,
PP_Bool* result) {
*result = ppb_fullscreen_target()->IsFullscreen(instance);
}

void PPB_Fullscreen_Proxy::OnMsgSetFullscreen(PP_Instance instance,
PP_Bool fullscreen,
PP_Bool* result) {
*result = ppb_fullscreen_target()->SetFullscreen(instance, fullscreen);
}

} // namespace proxy
} // namespace pp
Loading

0 comments on commit 54796ef

Please sign in to comment.