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