summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/interfaces_ppb_public_stable.h1
-rw-r--r--ppapi/thunk/ppb_audio_api.h6
-rw-r--r--ppapi/thunk/ppb_fullscreen_thunk.cc6
-rw-r--r--ppapi/thunk/ppb_instance_api.h7
-rw-r--r--ppapi/thunk/ppb_view_api.h31
-rw-r--r--ppapi/thunk/ppb_view_thunk.cc96
-rw-r--r--ppapi/thunk/thunk.h2
7 files changed, 142 insertions, 7 deletions
diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h
index f4d5ec3..56498d8 100644
--- a/ppapi/thunk/interfaces_ppb_public_stable.h
+++ b/ppapi/thunk/interfaces_ppb_public_stable.h
@@ -74,5 +74,6 @@ PROXIED_IFACE(NoAPIName, PPB_URLREQUESTINFO_INTERFACE_1_0, PPB_URLRequestInfo)
PROXIED_IFACE(PPB_URLResponseInfo, PPB_URLRESPONSEINFO_INTERFACE_1_0,
PPB_URLResponseInfo)
// Note: PPB_Var is special and registered manually.
+PROXIED_IFACE(NoAPIName, PPB_VIEW_INTERFACE_1_0, PPB_View)
#include "ppapi/thunk/interfaces_postamble.h"
diff --git a/ppapi/thunk/ppb_audio_api.h b/ppapi/thunk/ppb_audio_api.h
index 8d3a0b8..3c9c274 100644
--- a/ppapi/thunk/ppb_audio_api.h
+++ b/ppapi/thunk/ppb_audio_api.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PPAPI_THUNK_AUDIO_API_H_
-#define PPAPI_THUNK_AUDIO_API_H_
+#ifndef PPAPI_THUNK_PPB_AUDIO_API_H_
+#define PPAPI_THUNK_PPB_AUDIO_API_H_
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/ppb_audio.h"
@@ -30,4 +30,4 @@ class PPAPI_THUNK_EXPORT PPB_Audio_API {
} // namespace thunk
} // namespace ppapi
-#endif // PPAPI_THUNK_AUDIO_API_H_
+#endif // PPAPI_THUNK_PPB_AUDIO_API_H_
diff --git a/ppapi/thunk/ppb_fullscreen_thunk.cc b/ppapi/thunk/ppb_fullscreen_thunk.cc
index 4c5626e..5f2a0e0 100644
--- a/ppapi/thunk/ppb_fullscreen_thunk.cc
+++ b/ppapi/thunk/ppb_fullscreen_thunk.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ppapi/c/ppb_fullscreen.h"
+#include "ppapi/shared_impl/ppb_view_shared.h"
#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_instance_api.h"
@@ -17,7 +18,10 @@ PP_Bool IsFullscreen(PP_Instance instance) {
EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true);
if (enter.failed())
return PP_FALSE;
- return enter.functions()->IsFullscreen(instance);
+ const ViewData* view = enter.functions()->GetViewData(instance);
+ if (!view)
+ return PP_FALSE;
+ return PP_FromBool(view->is_fullscreen);
}
PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) {
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h
index 21187c4..8151479 100644
--- a/ppapi/thunk/ppb_instance_api.h
+++ b/ppapi/thunk/ppb_instance_api.h
@@ -19,6 +19,9 @@
#endif
namespace ppapi {
+
+struct ViewData;
+
namespace thunk {
class PPB_Instance_FunctionAPI {
@@ -28,6 +31,9 @@ class PPB_Instance_FunctionAPI {
virtual PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) = 0;
virtual PP_Bool IsFullFrame(PP_Instance instance) = 0;
+ // Not an exposed PPAPI function, this returns the internal view data struct.
+ virtual const ViewData* GetViewData(PP_Instance instance) = 0;
+
// InstancePrivate.
virtual PP_Var GetWindowObject(PP_Instance instance) = 0;
virtual PP_Var GetOwnerElementObject(PP_Instance instance) = 0;
@@ -55,7 +61,6 @@ class PPB_Instance_FunctionAPI {
int32_t index) = 0;
// Fullscreen.
- virtual PP_Bool IsFullscreen(PP_Instance instance) = 0;
virtual PP_Bool SetFullscreen(PP_Instance instance,
PP_Bool fullscreen) = 0;
virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) = 0;
diff --git a/ppapi/thunk/ppb_view_api.h b/ppapi/thunk/ppb_view_api.h
new file mode 100644
index 0000000..377658a
--- /dev/null
+++ b/ppapi/thunk/ppb_view_api.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_THUNK_PPB_VIEW_API_H_
+#define PPAPI_THUNK_PPB_VIEW_API_H_
+
+#include "ppapi/thunk/ppapi_thunk_export.h"
+
+namespace ppapi {
+
+struct ViewData;
+
+namespace thunk {
+
+class PPAPI_THUNK_EXPORT PPB_View_API {
+ public:
+ virtual ~PPB_View_API() {}
+
+ // Returns the view data struct. We could have virtual functions here for
+ // each PPAPI function, but that would be more boilerplate for these simple
+ // getters so the logic is implemented in the thunk layer. If we start
+ // autogenerating the thunk layer and need this to be more regular, adding
+ // the API functions here should be fine.
+ virtual const ViewData& GetData() const = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_VIEW_API_H_
diff --git a/ppapi/thunk/ppb_view_thunk.cc b/ppapi/thunk/ppb_view_thunk.cc
new file mode 100644
index 0000000..2615fea
--- /dev/null
+++ b/ppapi/thunk/ppb_view_thunk.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/c/ppb_view.h"
+#include "ppapi/shared_impl/ppb_view_shared.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_view_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+typedef EnterResource<PPB_View_API> EnterView;
+
+bool IsRectVisible(const PP_Rect& rect) {
+ return rect.size.width > 0 && rect.size.height > 0;
+}
+
+PP_Bool IsView(PP_Resource resource) {
+ EnterView enter(resource, false);
+ return enter.succeeded() ? PP_TRUE : PP_FALSE;
+}
+
+PP_Bool GetSize(PP_Resource resource, PP_Size* size) {
+ EnterView enter(resource, true);
+ if (enter.failed() || !size)
+ return PP_FALSE;
+ *size = enter.object()->GetData().rect.size;
+ return PP_TRUE;
+}
+
+PP_Bool GetRect(PP_Resource resource, PP_Rect* viewport) {
+ EnterView enter(resource, true);
+ if (enter.failed() || !viewport)
+ return PP_FALSE;
+ *viewport = enter.object()->GetData().rect;
+ return PP_TRUE;
+}
+
+PP_Bool IsFullscreen(PP_Resource resource) {
+ EnterView enter(resource, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PP_FromBool(enter.object()->GetData().is_fullscreen);
+}
+
+PP_Bool IsUserVisible(PP_Resource resource) {
+ EnterView enter(resource, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PP_FromBool(enter.object()->GetData().is_page_visible &&
+ IsRectVisible(enter.object()->GetData().clip_rect));
+}
+
+PP_Bool IsPageVisible(PP_Resource resource) {
+ EnterView enter(resource, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PP_FromBool(enter.object()->GetData().is_page_visible);
+}
+
+PP_Bool IsClipVisible(PP_Resource resource) {
+ EnterView enter(resource, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PP_FromBool(IsRectVisible(enter.object()->GetData().clip_rect));
+}
+
+PP_Bool GetClipRect(PP_Resource resource, PP_Rect* clip) {
+ EnterView enter(resource, true);
+ if (enter.failed() || !clip)
+ return PP_FALSE;
+ *clip = enter.object()->GetData().clip_rect;
+ return PP_TRUE;
+}
+
+const PPB_View g_ppb_view_thunk = {
+ &IsView,
+ &GetRect,
+ &IsFullscreen,
+ &IsUserVisible,
+ &IsPageVisible,
+ &GetClipRect
+};
+
+} // namespace
+
+const PPB_View* GetPPB_View_Thunk() {
+ return &g_ppb_view_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h
index 00773f3..a6a6ebb 100644
--- a/ppapi/thunk/thunk.h
+++ b/ppapi/thunk/thunk.h
@@ -43,8 +43,6 @@ struct PPB_TCPSocket_Private;
struct PPB_UDPSocket_Private;
struct PPB_URLLoaderTrusted;
-typedef PPB_Instance PPB_Instance_1_0;
-
namespace ppapi {
namespace thunk {