1 // Copyright 2014 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/compositor.h" 6 7 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/module_impl.h" 10 #include "ppapi/cpp/var.h" 11 12 namespace pp { 13 14 namespace { 15 interface_name()16template <> const char* interface_name<PPB_Compositor_0_1>() { 17 return PPB_COMPOSITOR_INTERFACE_0_1; 18 } 19 20 } // namespace 21 Compositor()22Compositor::Compositor() { 23 } 24 Compositor(const InstanceHandle & instance)25Compositor::Compositor(const InstanceHandle& instance) { 26 if (has_interface<PPB_Compositor_0_1>()) { 27 PassRefFromConstructor(get_interface<PPB_Compositor_0_1>()->Create( 28 instance.pp_instance())); 29 } 30 } 31 Compositor(const Compositor & other)32Compositor::Compositor( 33 const Compositor& other) : Resource(other) { 34 } 35 Compositor(const Resource & resource)36Compositor::Compositor(const Resource& resource) 37 : Resource(resource) { 38 PP_DCHECK(IsCompositor(resource)); 39 } 40 Compositor(PassRef,PP_Resource resource)41Compositor::Compositor(PassRef, PP_Resource resource) 42 : Resource(PASS_REF, resource) { 43 } 44 ~Compositor()45Compositor::~Compositor() { 46 } 47 AddLayer()48CompositorLayer Compositor::AddLayer() { 49 PP_Resource layer = 0; 50 if (has_interface<PPB_Compositor_0_1>()) { 51 layer = get_interface<PPB_Compositor_0_1>()->AddLayer(pp_resource()); 52 } 53 return CompositorLayer(PASS_REF, layer); 54 } 55 CommitLayers(const CompletionCallback & cc)56int32_t Compositor::CommitLayers(const CompletionCallback& cc) { 57 if (has_interface<PPB_Compositor_0_1>()) { 58 return get_interface<PPB_Compositor_0_1>()->CommitLayers( 59 pp_resource(), cc.pp_completion_callback()); 60 } 61 return cc.MayForce(PP_ERROR_NOINTERFACE); 62 } 63 ResetLayers()64int32_t Compositor::ResetLayers() { 65 if (has_interface<PPB_Compositor_0_1>()) { 66 return get_interface<PPB_Compositor_0_1>()->ResetLayers(pp_resource()); 67 } 68 return PP_ERROR_NOINTERFACE; 69 } 70 IsCompositor(const Resource & resource)71bool Compositor::IsCompositor(const Resource& resource) { 72 if (has_interface<PPB_Compositor_0_1>()) { 73 return PP_ToBool(get_interface<PPB_Compositor_0_1>()-> 74 IsCompositor(resource.pp_resource())); 75 } 76 return false; 77 } 78 79 } // namespace pp 80