QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / ppapi / cpp / compositor.cc
blob163a241ed536c970767227853ebac8a067ccc8e0
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.
5 #include "ppapi/cpp/compositor.h"
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"
12 namespace pp {
14 namespace {
16 template <> const char* interface_name<PPB_Compositor_0_1>() {
17 return PPB_COMPOSITOR_INTERFACE_0_1;
20 } // namespace
22 Compositor::Compositor() {
25 Compositor::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()));
32 Compositor::Compositor(
33 const Compositor& other) : Resource(other) {
36 Compositor::Compositor(const Resource& resource)
37 : Resource(resource) {
38 PP_DCHECK(IsCompositor(resource));
41 Compositor::Compositor(PassRef, PP_Resource resource)
42 : Resource(PASS_REF, resource) {
45 Compositor::~Compositor() {
48 CompositorLayer 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());
53 return CompositorLayer(PASS_REF, layer);
56 int32_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());
61 return cc.MayForce(PP_ERROR_NOINTERFACE);
64 int32_t Compositor::ResetLayers() {
65 if (has_interface<PPB_Compositor_0_1>()) {
66 return get_interface<PPB_Compositor_0_1>()->ResetLayers(pp_resource());
68 return PP_ERROR_NOINTERFACE;
71 bool 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()));
76 return false;
79 } // namespace pp