Pepper_31_C_interfaces
Public Attributes | List of all members
PPB_View_1_1 Struct Reference

#include <ppb_view.h>

Collaboration diagram for PPB_View_1_1:
Collaboration graph

Public Attributes

PP_Bool(* IsView )(PP_Resource resource)
 
PP_Bool(* GetRect )(PP_Resource resource, struct PP_Rect *rect)
 
PP_Bool(* IsFullscreen )(PP_Resource resource)
 
PP_Bool(* IsVisible )(PP_Resource resource)
 
PP_Bool(* IsPageVisible )(PP_Resource resource)
 
PP_Bool(* GetClipRect )(PP_Resource resource, struct PP_Rect *clip)
 
float(* GetDeviceScale )(PP_Resource resource)
 
float(* GetCSSScale )(PP_Resource resource)
 

Detailed Description

PPB_View represents the state of the view of an instance. You will receive new view information using PPP_Instance.DidChangeView.

Definition at line 39 of file ppb_view.h.

Member Data Documentation

PP_Bool(* PPB_View_1_1::GetClipRect)(PP_Resource resource, struct PP_Rect *clip)

GetClipRect() returns the clip rectangle relative to the upper-left corner of the module instance. This rectangle indicates the portions of the module instance that are scrolled into view.

If the module instance is scrolled off the view, the return value will be (0, 0, 0, 0). This clip rectangle does not take into account page visibility. Therefore, if the module instance is scrolled into view, but the page itself is on a tab that is not visible, the return rectangle will contain the visible rectangle as though the page were visible. Refer to IsPageVisible() and IsVisible() if you want to account for page visibility.

Most applications will not need to worry about the clip rectangle. The recommended behavior is to do full updates if the module instance is visible, as determined by IsVisible(), and do no updates if it is not visible.

However, if the cost for computing pixels is very high for your application, or the pages you're targeting frequently have very large module instances with small visible portions, you may wish to optimize further. In this case, the clip rectangle will tell you which parts of the module to update.

Note that painting of the page and sending of view changed updates happens asynchronously. This means when the user scrolls, for example, it is likely that the previous backing store of the module instance will be used for the first paint, and will be updated later when your application generates new content with the new clip. This may cause flickering at the boundaries when scrolling. If you do choose to do partial updates, you may want to think about what color the invisible portions of your backing store contain (be it transparent or some background color) or to paint a certain region outside the clip to reduce the visual distraction when this happens.

Parameters
resourceA PP_Resource corresponding to a PPB_View resource.
clipOutput argument receiving the clip rect on success.
Returns
Returns PP_TRUE if the resource was valid and the clip rect was filled in, PP_FALSE if not.

Definition at line 170 of file ppb_view.h.

float(* PPB_View_1_1::GetCSSScale)(PP_Resource resource)

GetCSSScale returns the scale factor between DIPs and CSS pixels. This allows proper scaling between DIPs - as sent via the Pepper API - and CSS pixel coordinates used for Web content.

Parameters
[in]resourceA PP_Resource corresponding to a PPB_View resource.
Returns
css_scale A float value representing the number of DIPs per CSS pixel. If the resource is invalid, the value will be 0.0.

Definition at line 199 of file ppb_view.h.

float(* PPB_View_1_1::GetDeviceScale)(PP_Resource resource)

GetDeviceScale returns the scale factor between device pixels and Density Independent Pixels (DIPs, also known as logical pixels or UI pixels on some platforms). This allows the developer to render their contents at device resolution, even as coordinates / sizes are given in DIPs through the API.

Note that the coordinate system for Pepper APIs is DIPs. Also note that one DIP might not equal one CSS pixel - when page scale/zoom is in effect.

Parameters
[in]resourceA PP_Resource corresponding to a PPB_View resource.
Returns
A float value representing the number of device pixels per DIP. If the resource is invalid, the value will be 0.0.

Definition at line 187 of file ppb_view.h.

PP_Bool(* PPB_View_1_1::GetRect)(PP_Resource resource, struct PP_Rect *rect)

GetRect() retrieves the rectangle of the module instance associated with a view changed notification relative to the upper-left of the browser viewport. This position changes when the page is scrolled.

The returned rectangle may not be inside the visible portion of the viewport if the module instance is scrolled off the page. Therefore, the position may be negative or larger than the size of the page. The size will always reflect the size of the module were it to be scrolled entirely into view.

In general, most modules will not need to worry about the position of the module instance in the viewport, and only need to use the size.

Parameters
resourceA PP_Resource corresponding to a PPB_View resource.
rectA PP_Rect receiving the rectangle on success.
Returns
Returns PP_TRUE if the resource was valid and the viewport rectangle was filled in, PP_FALSE if not.

Definition at line 76 of file ppb_view.h.

PP_Bool(* PPB_View_1_1::IsFullscreen)(PP_Resource resource)

IsFullscreen() returns whether the instance is currently displaying in fullscreen mode.

Parameters
resourceA PP_Resource corresponding to a PPB_View resource.
Returns
PP_TRUE if the instance is in full screen mode, or PP_FALSE if it's not or the resource is invalid.

Definition at line 87 of file ppb_view.h.

PP_Bool(* PPB_View_1_1::IsPageVisible)(PP_Resource resource)

IsPageVisible() determines if the page that contains the module instance is visible. The most common cause of invisible pages is that the page is in a background tab in the browser.

Most applications should use IsVisible() instead of this function since the module instance could be scrolled off of a visible page, and this function will still return true. However, depending on how your module interacts with the page, there may be certain updates that you may want to perform when the page is visible even if your specific module instance is not visible.

Parameters
resourceA PP_Resource corresponding to a PPB_View resource.
Returns
PP_TRUE if the instance is plausibly visible to the user, PP_FALSE if it is definitely not visible.

Definition at line 126 of file ppb_view.h.

PP_Bool(* PPB_View_1_1::IsView)(PP_Resource resource)

IsView() determines if the given resource is a valid PPB_View resource. Note that PPB_ViewChanged resources derive from PPB_View and will return true here as well.

Parameters
resourceA PP_Resource corresponding to a PPB_View resource.
Returns
PP_TRUE if the given resource supports PPB_View or PP_FALSE if it is an invalid resource or is a resource of another type.

Definition at line 53 of file ppb_view.h.

PP_Bool(* PPB_View_1_1::IsVisible)(PP_Resource resource)

IsVisible() determines whether the module instance might be visible to the user. For example, the Chrome window could be minimized or another window could be over it. In both of these cases, the module instance would not be visible to the user, but IsVisible() will return true.

Use the result to speed up or stop updates for invisible module instances.

This function performs the duties of GetRect() (determining whether the module instance is scrolled into view and the clip rectangle is nonempty) and IsPageVisible() (whether the page is visible to the user).

Parameters
resourceA PP_Resource corresponding to a PPB_View resource.
Returns
PP_TRUE if the instance might be visible to the user, PP_FALSE if it is definitely not visible.

Definition at line 107 of file ppb_view.h.


The documentation for this struct was generated from the following file: