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 #ifndef PPAPI_CPP_VIEW_H_ | |
6 #define PPAPI_CPP_VIEW_H_ | |
7 | |
8 #include "ppapi/cpp/resource.h" | |
9 #include "ppapi/cpp/rect.h" | |
10 #include "ppapi/cpp/size.h" | |
11 | |
12 namespace pp { | |
13 | |
14 class View : public Resource { | |
15 public: | |
16 /// Default constructor for creating an is_null() <code>View</code> object. | |
17 View(); | |
18 | |
19 /// Creates a View resource, taking and holding an additional reference to | |
20 /// the given resource handle. | |
21 View(PP_Resource view_resource); | |
22 | |
23 /// <code>GetRect()</code> returns the rectangle of the instance | |
24 /// associated with the view changed notification relative to the upper left | |
25 /// of the browser viewport. This position changes when the page is scrolled. | |
26 /// | |
27 /// The returned rectangle may not be inside the visible portion of the | |
28 /// viewport if the instance is scrolled off the page. Therefore, the | |
29 /// position may be negative or larger than the size of the page. The size | |
30 /// will always reflect the size of the plugin were it to be scrolled | |
31 /// entirely into view. | |
32 /// | |
33 /// In general, most plugins will not need to worry about the position of the | |
34 /// instance in the viewport, and only need to use the size. | |
35 /// | |
36 /// | |
37 /// @return The rectangle of the instance. | |
dmichael (off chromium)
2011/12/20 19:01:34
or a default rectangle if the View is null?
| |
38 Rect GetRect() const; | |
39 | |
40 /// <code>IsFullscreen()</code> returns whether the instance is currently | |
41 /// displaying in fullscreen mode. | |
42 /// | |
43 /// @return <code>true</code> if the instance is in full screen mode, | |
44 /// or <code>false</code> if it's not or the resource is invalid. | |
45 // | |
46 bool IsFullscreen() const; | |
47 | |
48 /// <code>IsVisible()</code> returns true if the instance is plausibly | |
49 /// visible to the user. You should use this flag to throttle or stop updates | |
50 /// for invisible plugins. | |
51 /// | |
52 /// Thie measure incorporates both whether the instance is scrolled into | |
53 /// view (whether the clip rect is nonempty) and whether the page is | |
54 /// plausibly visible to the user (<code>IsPageVisible()</code>). | |
55 /// | |
56 /// @return <code>true</code> if the instance is plausibly visible to the | |
57 /// user, <code>false</code> if it is definitely not visible. | |
58 bool IsVisible() const; | |
59 | |
60 /// <code>IsPageVisible()</code> determines if the page that contains the | |
61 /// instance is visible. The most common cause of invisible pages is that | |
62 /// the page is in a background tab in the browser. | |
63 /// | |
64 /// Most applications should use <code>IsVisible()</code> rather than | |
65 /// this function since the instance could be scrolled off of a visible | |
66 /// page, and this function will still return true. However, depending on | |
67 /// how your plugin interacts with the page, there may be certain updates | |
68 /// that you may want to perform when the page is visible even if your | |
69 /// specific instance isn't. | |
70 /// | |
71 /// @return <code>true</code> if the instance is plausibly visible to the | |
72 /// user, <code>false</code> if it is definitely not visible. | |
73 bool IsPageVisible() const; | |
74 | |
75 /// <code>GetClip()</code> returns the clip rectangle relative to the upper | |
76 /// left corner of the instance. This rectangle indicates which parts of the | |
77 /// instance are scrolled into view. | |
78 /// | |
79 /// If the instance is scrolled off the view, the return value will be | |
80 /// (0, 0, 0, 0). this state. This clip rect does <i>not</i> take into account | |
81 /// page visibility. This means if the instance is scrolled into view but the | |
82 /// page itself is in an invisible tab, the return rect will contain the | |
83 /// visible rect assuming the page was visible. See | |
84 /// <code>IsPageVisible()</code> and <code>IsVisible()</code> if you want | |
85 /// to handle this case. | |
86 /// | |
87 /// Most applications will not need to worry about the clip. The recommended | |
88 /// behavior is to do full updates if the instance is visible as determined by | |
89 /// <code>IsUserVisible()</code> and do no updates if not. | |
90 /// | |
91 /// However, if the cost for computing pixels is very high for your | |
92 /// application or the pages you're targeting frequently have very large | |
93 /// instances with only portions visible, you may wish to optimize further. | |
94 /// In this case, the clip rect will tell you which parts of the plugin to | |
95 /// update. | |
96 /// | |
97 /// Note that painting of the page and sending of view changed updates | |
98 /// happens asynchronously. This means when the user scrolls, for example, | |
99 /// it is likely that the previous backing store of the instance will be used | |
100 /// for the first paint, and will be updated later when your application | |
101 /// generates new content. This may cause flickering at the boundaries when | |
102 /// scrolling. If you do choose to do partial updates, you may want to think | |
103 /// about what color the invisible portions of your backing store contain | |
104 /// (be it transparent or some background color) or to paint a certain | |
105 /// region outside the clip to reduce the visual distraction when this | |
106 /// happens. | |
107 /// | |
108 /// @return The rectangle representing the visible part of the instance. | |
109 /// If the resource is invalid, the empty rect is returned. | |
110 Rect GetClipRect() const; | |
111 }; | |
112 | |
113 } // namespace pp | |
114 | |
115 #endif // PPAPI_CPP_VIEW_H_ | |
OLD | NEW |