Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / cpp / compositor.h
blobc89e26244d94d2f051b139397ed566e26892806e
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 #ifndef PPAPI_CPP_COMPOSITOR_H_
6 #define PPAPI_CPP_COMPOSITOR_H_
8 #include "ppapi/c/ppb_compositor.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/compositor_layer.h"
11 #include "ppapi/cpp/resource.h"
13 /// @file
14 /// This file defines the API to create a compositor in the browser.
15 namespace pp {
17 /// The <code>Compositor</code> interface is used for setting
18 /// <code>CompositorLayer</code> layers to the Chromium compositor for
19 /// compositing. This allows a plugin to combine different sources of visual
20 /// data efficiently, such as <code>ImageData</code> images and OpenGL textures.
21 /// See also <code>CompositorLayer</code> for more information.
22 class Compositor : public Resource {
23 public:
24 /// Default constructor for creating an is_null()
25 /// <code>Compositor</code> object.
26 Compositor();
28 /// A constructor for creating and initializing a compositor.
29 ///
30 /// On failure, the object will be is_null().
31 explicit Compositor(const InstanceHandle& instance);
33 /// The copy constructor for <code>Compositor</code>.
34 ///
35 /// @param[in] other A reference to a <code>Compositor</code>.
36 Compositor(const Compositor& other);
38 /// Constructs a <code>Compositor</code> from a <code>Resource</code>.
39 ///
40 /// @param[in] resource A <code>PPB_Compositor</code> resource.
41 explicit Compositor(const Resource& resource);
43 /// A constructor used when you have received a <code>PP_Resource</code> as a
44 /// return value that has had 1 ref added on behalf of the caller.
45 ///
46 /// @param[in] resource A <code>PPB_Compositor</code> resource.
47 Compositor(PassRef, PP_Resource resource);
49 /// Destructor.
50 ~Compositor();
52 /// Creates a new <code>CompositorLayer</code> and adds it to the end of the
53 /// layer stack. A <code>CompositorLayer</code> containing the layer is
54 /// returned. It is uninitialized, <code>SetColor()</code>,
55 /// <code>SetTexture</code> or <code>SetImage</code> should be used to
56 /// initialize it. The layer will appear above other pre-existing layers.
57 /// If <code>ResetLayers</code> is called or the <code>PPB_Compositor</code>
58 /// is released, the returned layer will be invalidated, and any further calls
59 /// on the layer will return <code>PP_ERROR_BADRESOURCE</code>.
60 ///
61 /// @return A <code>CompositorLayer</code> containing the compositor layer
62 /// resource.
63 CompositorLayer AddLayer();
65 /// Commits layers added by <code>AddLayer()</code> to the chromium
66 /// compositor.
67 ///
68 /// @param[in] cc A <code>CompletionCallback</code> to be called when
69 /// layers have been represented on screen.
70 ///
71 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
72 int32_t CommitLayers(const CompletionCallback& cc);
74 /// Resets layers added by <code>AddLayer()</code>
75 ///
76 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
77 int32_t ResetLayers();
79 /// Checks whether a <code>Resource</code> is a compositor, to test whether
80 /// it is appropriate for use with the <code>Compositor</code> constructor.
81 ///
82 /// @param[in] resource A <code>Resource</code> to test.
83 ///
84 /// @return True if <code>resource</code> is a compositor.
85 static bool IsCompositor(const Resource& resource);
88 } // namespace pp
90 #endif // PPAPI_CPP_COMPOSITOR_H_