// Copyright 2014 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_CPP_COMPOSITOR_H_ #define PPAPI_CPP_COMPOSITOR_H_ #include "ppapi/c/ppb_compositor.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/compositor_layer.h" #include "ppapi/cpp/resource.h" /// @file /// This file defines the API to create a compositor in the browser. namespace pp { /// The Compositor interface is used for setting /// CompositorLayer layers to the Chromium compositor for /// compositing. This allows a plugin to combine different sources of visual /// data efficiently, such as ImageData images and OpenGL textures. /// See also CompositorLayer for more information. class Compositor : public Resource { public: /// Default constructor for creating an is_null() /// Compositor object. Compositor(); /// A constructor for creating and initializing a compositor. /// /// On failure, the object will be is_null(). explicit Compositor(const InstanceHandle& instance); /// The copy constructor for Compositor. /// /// @param[in] other A reference to a Compositor. Compositor(const Compositor& other); /// Constructs a Compositor from a Resource. /// /// @param[in] resource A PPB_Compositor resource. explicit Compositor(const Resource& resource); /// A constructor used when you have received a PP_Resource as a /// return value that has had 1 ref added on behalf of the caller. /// /// @param[in] resource A PPB_Compositor resource. Compositor(PassRef, PP_Resource resource); /// Destructor. ~Compositor(); /// Creates a new CompositorLayer and adds it to the end of the /// layer stack. A CompositorLayer containing the layer is /// returned. It is uninitialized, SetColor(), /// SetTexture or SetImage should be used to /// initialize it. The layer will appear above other pre-existing layers. /// If ResetLayers is called or the PPB_Compositor /// is released, the returned layer will be invalidated, and any further calls /// on the layer will return PP_ERROR_BADRESOURCE. /// /// @return A CompositorLayer containing the compositor layer /// resource. CompositorLayer AddLayer(); /// Commits layers added by AddLayer() to the chromium /// compositor. /// /// @param[in] cc A CompletionCallback to be called when /// layers have been represented on screen. /// /// @return An int32_t containing a result code from pp_errors.h. int32_t CommitLayers(const CompletionCallback& cc); /// Resets layers added by AddLayer() /// /// @return An int32_t containing a result code from pp_errors.h. int32_t ResetLayers(); /// Checks whether a Resource is a compositor, to test whether /// it is appropriate for use with the Compositor constructor. /// /// @param[in] resource A Resource to test. /// /// @return True if resource is a compositor. static bool IsCompositor(const Resource& resource); }; } // namespace pp #endif // PPAPI_CPP_COMPOSITOR_H_