Fix build break
[chromium-blink-merge.git] / ppapi / c / ppb_view.h
blob8b82c78a3b8d3776fa07071a61908a20188d03ce
1 /* Copyright (c) 2012 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 */
6 /* From ppb_view.idl modified Fri Mar 29 11:55:32 2013. */
8 #ifndef PPAPI_C_PPB_VIEW_H_
9 #define PPAPI_C_PPB_VIEW_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_macros.h"
13 #include "ppapi/c/pp_point.h"
14 #include "ppapi/c/pp_rect.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_size.h"
17 #include "ppapi/c/pp_stdint.h"
19 #define PPB_VIEW_INTERFACE_1_0 "PPB_View;1.0"
20 #define PPB_VIEW_INTERFACE_1_1 "PPB_View;1.1"
21 #define PPB_VIEW_INTERFACE PPB_VIEW_INTERFACE_1_1
23 /**
24 * @file
25 * This file defines the <code>PPB_View</code> struct representing the state
26 * of the view of an instance.
30 /**
31 * @addtogroup Interfaces
32 * @{
34 /**
35 * <code>PPB_View</code> represents the state of the view of an instance.
36 * You will receive new view information using
37 * <code>PPP_Instance.DidChangeView</code>.
39 struct PPB_View_1_1 {
40 /**
41 * IsView() determines if the given resource is a valid
42 * <code>PPB_View</code> resource. Note that <code>PPB_ViewChanged</code>
43 * resources derive from <code>PPB_View</code> and will return true here
44 * as well.
46 * @param resource A <code>PP_Resource</code> corresponding to a
47 * <code>PPB_View</code> resource.
49 * @return <code>PP_TRUE</code> if the given resource supports
50 * <code>PPB_View</code> or <code>PP_FALSE</code> if it is an invalid
51 * resource or is a resource of another type.
53 PP_Bool (*IsView)(PP_Resource resource);
54 /**
55 * GetRect() retrieves the rectangle of the module instance associated
56 * with a view changed notification relative to the upper-left of the browser
57 * viewport. This position changes when the page is scrolled.
59 * The returned rectangle may not be inside the visible portion of the
60 * viewport if the module instance is scrolled off the page. Therefore, the
61 * position may be negative or larger than the size of the page. The size will
62 * always reflect the size of the module were it to be scrolled entirely into
63 * view.
65 * In general, most modules will not need to worry about the position of the
66 * module instance in the viewport, and only need to use the size.
68 * @param resource A <code>PP_Resource</code> corresponding to a
69 * <code>PPB_View</code> resource.
71 * @param rect A <code>PP_Rect</code> receiving the rectangle on success.
73 * @return Returns <code>PP_TRUE</code> if the resource was valid and the
74 * viewport rectangle was filled in, <code>PP_FALSE</code> if not.
76 PP_Bool (*GetRect)(PP_Resource resource, struct PP_Rect* rect);
77 /**
78 * IsFullscreen() returns whether the instance is currently
79 * displaying in fullscreen mode.
81 * @param resource A <code>PP_Resource</code> corresponding to a
82 * <code>PPB_View</code> resource.
84 * @return <code>PP_TRUE</code> if the instance is in full screen mode,
85 * or <code>PP_FALSE</code> if it's not or the resource is invalid.
87 PP_Bool (*IsFullscreen)(PP_Resource resource);
88 /**
89 * IsVisible() determines whether the module instance might be visible to
90 * the user. For example, the Chrome window could be minimized or another
91 * window could be over it. In both of these cases, the module instance
92 * would not be visible to the user, but IsVisible() will return true.
94 * Use the result to speed up or stop updates for invisible module
95 * instances.
97 * This function performs the duties of GetRect() (determining whether the
98 * module instance is scrolled into view and the clip rectangle is nonempty)
99 * and IsPageVisible() (whether the page is visible to the user).
101 * @param resource A <code>PP_Resource</code> corresponding to a
102 * <code>PPB_View</code> resource.
104 * @return <code>PP_TRUE</code> if the instance might be visible to the
105 * user, <code>PP_FALSE</code> if it is definitely not visible.
107 PP_Bool (*IsVisible)(PP_Resource resource);
109 * IsPageVisible() determines if the page that contains the module instance
110 * is visible. The most common cause of invisible pages is that
111 * the page is in a background tab in the browser.
113 * Most applications should use IsVisible() instead of this function since
114 * the module instance could be scrolled off of a visible page, and this
115 * function will still return true. However, depending on how your module
116 * interacts with the page, there may be certain updates that you may want to
117 * perform when the page is visible even if your specific module instance is
118 * not visible.
120 * @param resource A <code>PP_Resource</code> corresponding to a
121 * <code>PPB_View</code> resource.
123 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the
124 * user, <code>PP_FALSE</code> if it is definitely not visible.
126 PP_Bool (*IsPageVisible)(PP_Resource resource);
128 * GetClipRect() returns the clip rectangle relative to the upper-left corner
129 * of the module instance. This rectangle indicates the portions of the module
130 * instance that are scrolled into view.
132 * If the module instance is scrolled off the view, the return value will be
133 * (0, 0, 0, 0). This clip rectangle does <i>not</i> take into account page
134 * visibility. Therefore, if the module instance is scrolled into view, but
135 * the page itself is on a tab that is not visible, the return rectangle will
136 * contain the visible rectangle as though the page were visible. Refer to
137 * IsPageVisible() and IsVisible() if you want to account for page
138 * visibility.
140 * Most applications will not need to worry about the clip rectangle. The
141 * recommended behavior is to do full updates if the module instance is
142 * visible, as determined by IsVisible(), and do no updates if it is not
143 * visible.
145 * However, if the cost for computing pixels is very high for your
146 * application, or the pages you're targeting frequently have very large
147 * module instances with small visible portions, you may wish to optimize
148 * further. In this case, the clip rectangle will tell you which parts of
149 * the module to update.
151 * Note that painting of the page and sending of view changed updates
152 * happens asynchronously. This means when the user scrolls, for example,
153 * it is likely that the previous backing store of the module instance will
154 * be used for the first paint, and will be updated later when your
155 * application generates new content with the new clip. This may cause
156 * flickering at the boundaries when scrolling. If you do choose to do
157 * partial updates, you may want to think about what color the invisible
158 * portions of your backing store contain (be it transparent or some
159 * background color) or to paint a certain region outside the clip to reduce
160 * the visual distraction when this happens.
162 * @param resource A <code>PP_Resource</code> corresponding to a
163 * <code>PPB_View</code> resource.
165 * @param clip Output argument receiving the clip rect on success.
167 * @return Returns <code>PP_TRUE</code> if the resource was valid and the
168 * clip rect was filled in, <code>PP_FALSE</code> if not.
170 PP_Bool (*GetClipRect)(PP_Resource resource, struct PP_Rect* clip);
172 * GetDeviceScale returns the scale factor between device pixels and Density
173 * Independent Pixels (DIPs, also known as logical pixels or UI pixels on
174 * some platforms). This allows the developer to render their contents at
175 * device resolution, even as coordinates / sizes are given in DIPs through
176 * the API.
178 * Note that the coordinate system for Pepper APIs is DIPs. Also note that
179 * one DIP might not equal one CSS pixel - when page scale/zoom is in effect.
181 * @param[in] resource A <code>PP_Resource</code> corresponding to a
182 * <code>PPB_View</code> resource.
184 * @return A <code>float</code> value representing the number of device pixels
185 * per DIP. If the resource is invalid, the value will be 0.0.
187 float (*GetDeviceScale)(PP_Resource resource);
189 * GetCSSScale returns the scale factor between DIPs and CSS pixels. This
190 * allows proper scaling between DIPs - as sent via the Pepper API - and CSS
191 * pixel coordinates used for Web content.
193 * @param[in] resource A <code>PP_Resource</code> corresponding to a
194 * <code>PPB_View</code> resource.
196 * @return css_scale A <code>float</code> value representing the number of
197 * DIPs per CSS pixel. If the resource is invalid, the value will be 0.0.
199 float (*GetCSSScale)(PP_Resource resource);
202 typedef struct PPB_View_1_1 PPB_View;
204 struct PPB_View_1_0 {
205 PP_Bool (*IsView)(PP_Resource resource);
206 PP_Bool (*GetRect)(PP_Resource resource, struct PP_Rect* rect);
207 PP_Bool (*IsFullscreen)(PP_Resource resource);
208 PP_Bool (*IsVisible)(PP_Resource resource);
209 PP_Bool (*IsPageVisible)(PP_Resource resource);
210 PP_Bool (*GetClipRect)(PP_Resource resource, struct PP_Rect* clip);
213 * @}
216 #endif /* PPAPI_C_PPB_VIEW_H_ */