Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: ppapi/cpp/view.h

Issue 8951014: Change the DidChangeView update to take a new ViewChanged resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 /// @return The rectangle of the instance. The default return value for
37 /// an invalid View is the empty rectangle.
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 bool IsFullscreen() const;
46
47 /// <code>IsVisible()</code> returns true if the instance is plausibly
48 /// visible to the user. You should use this flag to throttle or stop updates
49 /// for invisible plugins.
50 ///
51 /// Thie measure incorporates both whether the instance is scrolled into
52 /// view (whether the clip rect is nonempty) and whether the page is
53 /// plausibly visible to the user (<code>IsPageVisible()</code>).
54 ///
55 /// @return <code>true</code> if the instance is plausibly visible to the
56 /// user, <code>false</code> if it is definitely not visible.
57 bool IsVisible() const;
58
59 /// <code>IsPageVisible()</code> determines if the page that contains the
60 /// instance is visible. The most common cause of invisible pages is that
61 /// the page is in a background tab in the browser.
62 ///
63 /// Most applications should use <code>IsVisible()</code> rather than
64 /// this function since the instance could be scrolled off of a visible
65 /// page, and this function will still return true. However, depending on
66 /// how your plugin interacts with the page, there may be certain updates
67 /// that you may want to perform when the page is visible even if your
68 /// specific instance isn't.
69 ///
70 /// @return <code>true</code> if the instance is plausibly visible to the
71 /// user, <code>false</code> if it is definitely not visible.
72 bool IsPageVisible() const;
73
74 /// <code>GetClip()</code> returns the clip rectangle relative to the upper
75 /// left corner of the instance. This rectangle indicates which parts of the
76 /// instance are scrolled into view.
77 ///
78 /// If the instance is scrolled off the view, the return value will be
79 /// (0, 0, 0, 0). this state. This clip rect does <i>not</i> take into account
80 /// page visibility. This means if the instance is scrolled into view but the
81 /// page itself is in an invisible tab, the return rect will contain the
82 /// visible rect assuming the page was visible. See
83 /// <code>IsPageVisible()</code> and <code>IsVisible()</code> if you want
84 /// to handle this case.
85 ///
86 /// Most applications will not need to worry about the clip. The recommended
87 /// behavior is to do full updates if the instance is visible as determined by
88 /// <code>IsUserVisible()</code> and do no updates if not.
89 ///
90 /// However, if the cost for computing pixels is very high for your
91 /// application or the pages you're targeting frequently have very large
92 /// instances with only portions visible, you may wish to optimize further.
93 /// In this case, the clip rect will tell you which parts of the plugin to
94 /// update.
95 ///
96 /// Note that painting of the page and sending of view changed updates
97 /// happens asynchronously. This means when the user scrolls, for example,
98 /// it is likely that the previous backing store of the instance will be used
99 /// for the first paint, and will be updated later when your application
100 /// generates new content. This may cause flickering at the boundaries when
101 /// scrolling. If you do choose to do partial updates, you may want to think
102 /// about what color the invisible portions of your backing store contain
103 /// (be it transparent or some background color) or to paint a certain
104 /// region outside the clip to reduce the visual distraction when this
105 /// happens.
106 ///
107 /// @return The rectangle representing the visible part of the instance.
108 /// If the resource is invalid, the empty rect is returned.
109 Rect GetClipRect() const;
110 };
111
112 } // namespace pp
113
114 #endif // PPAPI_CPP_VIEW_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/module.cc ('k') | ppapi/cpp/view.cc » ('j') | ppapi/cpp/view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698