OLD | NEW |
(Empty) | |
| 1 /* Copyright (c) 2011 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 |
| 6 /* From ppb_view.idl modified Thu Dec 15 10:22:28 2011. */ |
| 7 |
| 8 #ifndef PPAPI_C_PPB_VIEW_H_ |
| 9 #define PPAPI_C_PPB_VIEW_H_ |
| 10 |
| 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" |
| 18 |
| 19 #define PPB_VIEW_INTERFACE_1_0 "PPB_View;1.0" |
| 20 #define PPB_VIEW_INTERFACE PPB_VIEW_INTERFACE_1_0 |
| 21 |
| 22 /** |
| 23 * @file |
| 24 * Defines the <code>PPB_View</code> struct representing the state of the |
| 25 * view of an instance. |
| 26 */ |
| 27 |
| 28 |
| 29 /** |
| 30 * @addtogroup Interfaces |
| 31 * @{ |
| 32 */ |
| 33 /** |
| 34 * <code>PPB_View</code> represents the state of the view of an instance. |
| 35 * You can get a View object with the <code>PPB_Instance.GetView()</code> |
| 36 * function. Additionally, all </code>PPB_ViewChanged</code> objects are also |
| 37 * <code>PPB_View</code> objects so you will receive new view information via |
| 38 * <code>PPP_Instance.DidChangeView</code>. |
| 39 */ |
| 40 struct PPB_View { |
| 41 /** |
| 42 * <code>IsView()</code> determines if the given resource is a valid |
| 43 * <code>PPB_View</code> resource. Note that <code>PPB_ViewChanged</code> |
| 44 * resources derive from <code>PPB_View</code> and will return true here |
| 45 * as well. |
| 46 * |
| 47 * @return <code>PP_TRUE</code> if the given resource supports |
| 48 * <code>PPB_View</code> or <code>PP_FALSE</code> if it is an invalid |
| 49 * resource or is a resource of another type. |
| 50 */ |
| 51 PP_Bool (*IsView)(PP_Resource resource); |
| 52 /** |
| 53 * <code>GetRect()</code> retrieves the rectangle of the instance |
| 54 * associated with the view changed notification relative to the upper left |
| 55 * of the browser viewport. This position changes when the page is scrolled. |
| 56 * |
| 57 * The returned rectangle may not be inside the visible portion of the |
| 58 * viewport if the instance is scrolled off the page. Therefore, the position |
| 59 * may be negative or larger than the size of the page. The size will always |
| 60 * reflect the size of the plugin were it to be scrolled entirely into view. |
| 61 * |
| 62 * In general, most plugins will not need to worry about the position of the |
| 63 * instance in the viewport, and only need to use the size. |
| 64 * |
| 65 * @param rect Output argument receiving the rectangle on success. |
| 66 * |
| 67 * @return Returns <code>PP_TRUE</code> if the resource was valid and the |
| 68 * viewport rect was filled in, <code>PP_FALSE</code> if not. |
| 69 */ |
| 70 PP_Bool (*GetRect)(PP_Resource resource, struct PP_Rect* rect); |
| 71 /** |
| 72 * <code>IsFullscreen()</code> returns whether the instance is currently |
| 73 * displaying in fullscreen mode. |
| 74 * |
| 75 * @return <code>PP_TRUE</code> if the instance is in full screen mode, |
| 76 * or <code>PP_FALSE</code> if it's not or the resource is invalid. |
| 77 */ |
| 78 PP_Bool (*IsFullscreen)(PP_Resource resource); |
| 79 /** |
| 80 * <code>IsVisible()</code> returns whether the instance is plausibly |
| 81 * visible to the user. You should use this flag to throttle or stop updates |
| 82 * for invisible plugins. |
| 83 * |
| 84 * Thie measure incorporates both whether the instance is scrolled into |
| 85 * view (whether the clip rect is nonempty) and whether the page is plausibly |
| 86 * visible to the user (<code>IsPageVisible()</code>). |
| 87 * |
| 88 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the |
| 89 * user, <code>PP_FALSE</code> if it is definitely not visible. |
| 90 */ |
| 91 PP_Bool (*IsVisible)(PP_Resource resource); |
| 92 /** |
| 93 * <code>IsPageVisible()</code> determines if the page that contains the |
| 94 * instance is visible. The most common cause of invisible pages is that |
| 95 * the page is in a background tab in the browser. |
| 96 * |
| 97 * Most applications should use <code>IsVisible()</code> rather than |
| 98 * this function since the instance could be scrolled off of a visible |
| 99 * page, and this function will still return true. However, depending on |
| 100 * how your plugin interacts with the page, there may be certain updates |
| 101 * that you may want to perform when the page is visible even if your |
| 102 * specific instance isn't. |
| 103 * |
| 104 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the |
| 105 * user, <code>PP_FALSE</code> if it is definitely not visible. |
| 106 */ |
| 107 PP_Bool (*IsPageVisible)(PP_Resource resource); |
| 108 /** |
| 109 * <code>GetClipRect()</code> returns the clip rectangle relative to the |
| 110 * upper left corner of the instance. This rectangle indicates which parts of |
| 111 * the instance are scrolled into view. |
| 112 * |
| 113 * If the instance is scrolled off the view, the return value will be |
| 114 * (0, 0, 0, 0). this state. This clip rect does <i>not</i> take into account |
| 115 * page visibility. This means if the instance is scrolled into view but the |
| 116 * page itself is in an invisible tab, the return rect will contain the |
| 117 * visible rect assuming the page was visible. See |
| 118 * <code>IsPageVisible()</code> and <code>IsVisible()</code> if you want to |
| 119 * handle this case. |
| 120 * |
| 121 * Most applications will not need to worry about the clip. The recommended |
| 122 * behavior is to do full updates if the instance is visible as determined by |
| 123 * <code>IsVisible()</code> and do no updates if not. |
| 124 * |
| 125 * However, if the cost for computing pixels is very high for your |
| 126 * application or the pages you're targeting frequently have very large |
| 127 * instances with small visible portions, you may wish to optimize further. |
| 128 * In this case, the clip rect will tell you which parts of the plugin to |
| 129 * update. |
| 130 * |
| 131 * Note that painting of the page and sending of view changed updates |
| 132 * happens asynchronously. This means when the user scrolls, for example, |
| 133 * it is likely that the previous backing store of the instance will be used |
| 134 * for the first paint, and will be updated later when your application |
| 135 * generates new content with the new clip. This may cause flickering at the |
| 136 * boundaries when scrolling. If you do choose to do partial updates, you may |
| 137 * want to think about what color the invisible portions of your backing |
| 138 * store contain (be it transparent or some background color) or to paint |
| 139 * a certain region outside the clip to reduce the visual distraction when |
| 140 * this happens. |
| 141 * |
| 142 * @param clip Output argument receiving the clip rect on success. |
| 143 * |
| 144 * @return Returns <code>PP_TRUE</code> if the resource was valid and the |
| 145 * clip rect was filled in, <code>PP_FALSE</code> if not. |
| 146 */ |
| 147 PP_Bool (*GetClipRect)(PP_Resource resource, struct PP_Rect* clip); |
| 148 }; |
| 149 /** |
| 150 * @} |
| 151 */ |
| 152 |
| 153 #endif /* PPAPI_C_PPB_VIEW_H_ */ |
| 154 |
OLD | NEW |