Home | History | Annotate | Download | only in cpp
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // 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/cpp/graphics_3d_client.h"
      6 
      7 #include "ppapi/c/ppp_graphics_3d.h"
      8 #include "ppapi/cpp/instance.h"
      9 #include "ppapi/cpp/instance_handle.h"
     10 #include "ppapi/cpp/module.h"
     11 #include "ppapi/cpp/module_impl.h"
     12 
     13 namespace pp {
     14 
     15 namespace {
     16 
     17 const char kPPPGraphics3DInterface[] = PPP_GRAPHICS_3D_INTERFACE;
     18 
     19 void Graphics3D_ContextLost(PP_Instance instance) {
     20   void* object =
     21       Instance::GetPerInstanceObject(instance, kPPPGraphics3DInterface);
     22   if (!object)
     23     return;
     24   return static_cast<Graphics3DClient*>(object)->Graphics3DContextLost();
     25 }
     26 
     27 static PPP_Graphics3D graphics3d_interface = {
     28   &Graphics3D_ContextLost,
     29 };
     30 
     31 }  // namespace
     32 
     33 Graphics3DClient::Graphics3DClient(Instance* instance)
     34     : associated_instance_(instance) {
     35   Module::Get()->AddPluginInterface(kPPPGraphics3DInterface,
     36                                     &graphics3d_interface);
     37   instance->AddPerInstanceObject(kPPPGraphics3DInterface, this);
     38 }
     39 
     40 Graphics3DClient::~Graphics3DClient() {
     41   Instance::RemovePerInstanceObject(associated_instance_,
     42                                     kPPPGraphics3DInterface, this);
     43 }
     44 
     45 }  // namespace pp
     46