blob: 50f7fe56a566a41c40c13e91b04e5643ac601a97 [file] [log] [blame]
[email protected]4c41d3f2012-02-15 01:44:471// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8c3bd1d2011-04-12 20:01:422// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ppapi/proxy/ppp_graphics_3d_proxy.h"
6
avie029c4132015-12-23 06:45:227#include "build/build_config.h"
[email protected]fae0e942011-09-07 17:10:468#include "ppapi/c/ppp_graphics_3d.h"
[email protected]8c3bd1d2011-04-12 20:01:429#include "ppapi/proxy/host_dispatcher.h"
10#include "ppapi/proxy/plugin_dispatcher.h"
11#include "ppapi/proxy/ppapi_messages.h"
[email protected]4c41d3f2012-02-15 01:44:4712#include "ppapi/shared_impl/proxy_lock.h"
[email protected]8c3bd1d2011-04-12 20:01:4213
[email protected]4d2efd22011-08-18 21:58:0214namespace ppapi {
[email protected]8c3bd1d2011-04-12 20:01:4215namespace proxy {
16
17namespace {
18
[email protected]24d70dea32012-11-19 22:18:2019#if !defined(OS_NACL)
[email protected]8c3bd1d2011-04-12 20:01:4220void ContextLost(PP_Instance instance) {
21 HostDispatcher::GetForInstance(instance)->Send(
[email protected]ac4b54d2011-10-20 23:09:2822 new PpapiMsg_PPPGraphics3D_ContextLost(API_ID_PPP_GRAPHICS_3D, instance));
[email protected]8c3bd1d2011-04-12 20:01:4223}
24
[email protected]fae0e942011-09-07 17:10:4625static const PPP_Graphics3D graphics_3d_interface = {
[email protected]8c3bd1d2011-04-12 20:01:4226 &ContextLost
27};
[email protected]24d70dea32012-11-19 22:18:2028#else
29// The NaCl plugin doesn't need the host side interface - stub it out.
30static const PPP_Graphics3D graphics_3d_interface = {};
31#endif // !defined(OS_NACL)
[email protected]8c3bd1d2011-04-12 20:01:4232
[email protected]8c3bd1d2011-04-12 20:01:4233} // namespace
34
[email protected]5c966022011-09-13 18:09:3735PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher)
36 : InterfaceProxy(dispatcher),
37 ppp_graphics_3d_impl_(NULL) {
38 if (dispatcher->IsPlugin()) {
39 ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>(
40 dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE));
41 }
[email protected]8c3bd1d2011-04-12 20:01:4242}
43
44PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() {
45}
46
47// static
[email protected]6642ebf2013-12-17 20:49:3048const PPP_Graphics3D* PPP_Graphics3D_Proxy::GetProxyInterface() {
49 return &graphics_3d_interface;
[email protected]8c3bd1d2011-04-12 20:01:4250}
51
52bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
[email protected]d5f5dc12013-01-22 23:05:0353 if (!dispatcher()->IsPlugin())
54 return false;
55
[email protected]8c3bd1d2011-04-12 20:01:4256 bool handled = true;
57 IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg)
58 IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost,
59 OnMsgContextLost)
60 IPC_MESSAGE_UNHANDLED(handled = false)
61 IPC_END_MESSAGE_MAP()
62 return handled;
63}
64
65void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) {
[email protected]5c966022011-09-13 18:09:3766 if (ppp_graphics_3d_impl_)
[email protected]4c41d3f2012-02-15 01:44:4767 CallWhileUnlocked(ppp_graphics_3d_impl_->Graphics3DContextLost, instance);
[email protected]8c3bd1d2011-04-12 20:01:4268}
69
70} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0271} // namespace ppapi