summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 18:17:58 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 18:17:58 +0000
commit12b6f612c91c63cfeb9c7ef530e3a007b0366802 (patch)
tree3debc3b47e9515d1f08b715bfb75e1a63cc8f45e
parent634f69c80e80c0f80d8eaf2e29a7a88710d2236b (diff)
downloadchromium_src-12b6f612c91c63cfeb9c7ef530e3a007b0366802.zip
chromium_src-12b6f612c91c63cfeb9c7ef530e3a007b0366802.tar.gz
chromium_src-12b6f612c91c63cfeb9c7ef530e3a007b0366802.tar.bz2
IDL: Autogenerate thunk .cc file for PPB_View
BUG= Review URL: https://chromiumcodereview.appspot.com/12220082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182253 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/api/dev/ppb_view_dev.idl3
-rw-r--r--ppapi/api/ppb_view.idl2
-rwxr-xr-xppapi/generators/idl_thunk.py1
-rw-r--r--ppapi/ppapi_shared.gypi1
-rw-r--r--ppapi/shared_impl/ppb_view_shared.cc42
-rw-r--r--ppapi/shared_impl/ppb_view_shared.h8
-rw-r--r--ppapi/thunk/ppb_view_api.h14
-rw-r--r--ppapi/thunk/ppb_view_dev_thunk.cc47
-rw-r--r--ppapi/thunk/ppb_view_thunk.cc82
9 files changed, 140 insertions, 60 deletions
diff --git a/ppapi/api/dev/ppb_view_dev.idl b/ppapi/api/dev/ppb_view_dev.idl
index b72014e..0846bd8 100644
--- a/ppapi/api/dev/ppb_view_dev.idl
+++ b/ppapi/api/dev/ppb_view_dev.idl
@@ -4,6 +4,9 @@
*/
/* This file contains the <code>PPB_View_Dev</code> interface. */
+
+[generate_thunk]
+
label Chrome {
M22 = 0.1
};
diff --git a/ppapi/api/ppb_view.idl b/ppapi/api/ppb_view.idl
index b51756c..cc61ed2 100644
--- a/ppapi/api/ppb_view.idl
+++ b/ppapi/api/ppb_view.idl
@@ -8,6 +8,8 @@
* of the view of an instance.
*/
+[generate_thunk]
+
label Chrome {
M18 = 1.0
};
diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py
index b3f59d1..117f54a 100755
--- a/ppapi/generators/idl_thunk.py
+++ b/ppapi/generators/idl_thunk.py
@@ -143,6 +143,7 @@ def _GetDefaultFailureValue(t):
'PP_Bool': 'PP_FALSE',
'PP_Resource': '0',
'struct PP_Var': 'PP_MakeUndefined()',
+ 'float': '0.0f',
'int32_t': 'enter.retval()',
'uint16_t': '0',
'uint32_t': '0',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index e18ea34..36b2a6f 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -231,6 +231,7 @@
'thunk/ppb_video_decoder_api.h',
'thunk/ppb_video_decoder_thunk.cc',
'thunk/ppb_view_api.h',
+ 'thunk/ppb_view_dev_thunk.cc',
'thunk/ppb_view_thunk.cc',
'thunk/ppb_websocket_api.h',
'thunk/ppb_websocket_thunk.cc',
diff --git a/ppapi/shared_impl/ppb_view_shared.cc b/ppapi/shared_impl/ppb_view_shared.cc
index 9e15655..f11fe1f 100644
--- a/ppapi/shared_impl/ppb_view_shared.cc
+++ b/ppapi/shared_impl/ppb_view_shared.cc
@@ -4,6 +4,14 @@
#include "ppapi/shared_impl/ppb_view_shared.h"
+namespace {
+
+bool IsRectNonempty(const PP_Rect& rect) {
+ return rect.size.width > 0 && rect.size.height > 0;
+}
+
+} // namespace
+
namespace ppapi {
ViewData::ViewData() {
@@ -50,4 +58,38 @@ const ViewData& PPB_View_Shared::GetData() const {
return data_;
}
+PP_Bool PPB_View_Shared::GetRect(PP_Rect* viewport) const {
+ if (!viewport)
+ return PP_FALSE;
+ *viewport = data_.rect;
+ return PP_TRUE;
+}
+
+PP_Bool PPB_View_Shared::IsFullscreen() const {
+ return PP_FromBool(data_.is_fullscreen);
+}
+
+PP_Bool PPB_View_Shared::IsVisible() const {
+ return PP_FromBool(data_.is_page_visible && IsRectNonempty(data_.clip_rect));
+}
+
+PP_Bool PPB_View_Shared::IsPageVisible() const {
+ return PP_FromBool(data_.is_page_visible);
+}
+
+PP_Bool PPB_View_Shared::GetClipRect(PP_Rect* clip) const {
+ if (!clip)
+ return PP_FALSE;
+ *clip = data_.clip_rect;
+ return PP_TRUE;
+}
+
+float PPB_View_Shared::GetDeviceScale() const {
+ return data_.device_scale;
+}
+
+float PPB_View_Shared::GetCSSScale() const {
+ return data_.css_scale;
+}
+
} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_view_shared.h b/ppapi/shared_impl/ppb_view_shared.h
index e3d41ac..77bf8f2 100644
--- a/ppapi/shared_impl/ppb_view_shared.h
+++ b/ppapi/shared_impl/ppb_view_shared.h
@@ -43,6 +43,14 @@ class PPAPI_SHARED_EXPORT PPB_View_Shared
// PPB_View_API implementation.
virtual const ViewData& GetData() const OVERRIDE;
+ virtual PP_Bool GetRect(PP_Rect* viewport) const OVERRIDE;
+ virtual PP_Bool IsFullscreen() const OVERRIDE;
+ virtual PP_Bool IsVisible() const OVERRIDE;
+ virtual PP_Bool IsPageVisible() const OVERRIDE;
+ virtual PP_Bool GetClipRect(PP_Rect* clip) const
+ OVERRIDE;
+ virtual float GetDeviceScale() const OVERRIDE;
+ virtual float GetCSSScale() const OVERRIDE;
private:
ViewData data_;
diff --git a/ppapi/thunk/ppb_view_api.h b/ppapi/thunk/ppb_view_api.h
index 50e256e..7561344 100644
--- a/ppapi/thunk/ppb_view_api.h
+++ b/ppapi/thunk/ppb_view_api.h
@@ -17,12 +17,16 @@ 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.
+ // Returns the view data struct.
virtual const ViewData& GetData() const = 0;
+
+ virtual PP_Bool GetRect(PP_Rect* viewport) const = 0;
+ virtual PP_Bool IsFullscreen() const = 0;
+ virtual PP_Bool IsVisible() const = 0;
+ virtual PP_Bool IsPageVisible() const = 0;
+ virtual PP_Bool GetClipRect(PP_Rect* clip) const = 0;
+ virtual float GetDeviceScale() const = 0;
+ virtual float GetCSSScale() const = 0;
};
} // namespace thunk
diff --git a/ppapi/thunk/ppb_view_dev_thunk.cc b/ppapi/thunk/ppb_view_dev_thunk.cc
new file mode 100644
index 0000000..188c807
--- /dev/null
+++ b/ppapi/thunk/ppb_view_dev_thunk.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 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.
+
+// From dev/ppb_view_dev.idl modified Fri Feb 8 14:28:54 2013.
+
+#include "ppapi/c/dev/ppb_view_dev.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_view_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+float GetDeviceScale(PP_Resource resource) {
+ EnterResource<PPB_View_API> enter(resource, true);
+ if (enter.failed())
+ return 0.0f;
+ return enter.object()->GetDeviceScale();
+}
+
+float GetCSSScale(PP_Resource resource) {
+ EnterResource<PPB_View_API> enter(resource, true);
+ if (enter.failed())
+ return 0.0f;
+ return enter.object()->GetCSSScale();
+}
+
+const PPB_View_Dev_0_1 g_ppb_view_dev_thunk_0_1 = {
+ &GetDeviceScale,
+ &GetCSSScale
+};
+
+} // namespace
+
+const PPB_View_Dev_0_1* GetPPB_View_Dev_0_1_Thunk() {
+ return &g_ppb_view_dev_thunk_0_1;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_view_thunk.cc b/ppapi/thunk/ppb_view_thunk.cc
index c9a88b7..1aa16e6 100644
--- a/ppapi/thunk/ppb_view_thunk.cc
+++ b/ppapi/thunk/ppb_view_thunk.cc
@@ -2,11 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ppapi/c/dev/ppb_view_dev.h"
+// From ppb_view.idl modified Fri Feb 8 14:28:54 2013.
+
+#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_view.h"
-#include "ppapi/shared_impl/ppb_view_shared.h"
+#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/ppb_view_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
@@ -14,91 +18,59 @@ 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;
+ EnterResource<PPB_View_API> enter(resource, false);
+ return PP_FromBool(enter.succeeded());
}
-PP_Bool GetRect(PP_Resource resource, PP_Rect* viewport) {
- EnterView enter(resource, true);
- if (enter.failed() || !viewport)
+PP_Bool GetRect(PP_Resource resource, struct PP_Rect* rect) {
+ EnterResource<PPB_View_API> enter(resource, true);
+ if (enter.failed())
return PP_FALSE;
- *viewport = enter.object()->GetData().rect;
- return PP_TRUE;
+ return enter.object()->GetRect(rect);
}
PP_Bool IsFullscreen(PP_Resource resource) {
- EnterView enter(resource, true);
+ EnterResource<PPB_View_API> enter(resource, true);
if (enter.failed())
return PP_FALSE;
- return PP_FromBool(enter.object()->GetData().is_fullscreen);
+ return enter.object()->IsFullscreen();
}
-PP_Bool IsUserVisible(PP_Resource resource) {
- EnterView enter(resource, true);
+PP_Bool IsVisible(PP_Resource resource) {
+ EnterResource<PPB_View_API> enter(resource, true);
if (enter.failed())
return PP_FALSE;
- return PP_FromBool(enter.object()->GetData().is_page_visible &&
- IsRectVisible(enter.object()->GetData().clip_rect));
+ return enter.object()->IsVisible();
}
PP_Bool IsPageVisible(PP_Resource resource) {
- EnterView enter(resource, true);
+ EnterResource<PPB_View_API> enter(resource, true);
if (enter.failed())
return PP_FALSE;
- return PP_FromBool(enter.object()->GetData().is_page_visible);
-}
-
-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;
+ return enter.object()->IsPageVisible();
}
-float GetDeviceScale(PP_Resource resource) {
- EnterView enter(resource, true);
+PP_Bool GetClipRect(PP_Resource resource, struct PP_Rect* clip) {
+ EnterResource<PPB_View_API> enter(resource, true);
if (enter.failed())
- return 0.0f;
- return enter.object()->GetData().device_scale;
-}
-
-float GetCSSScale(PP_Resource resource) {
- EnterView enter(resource, true);
- if (enter.failed())
- return 0.0f;
- return enter.object()->GetData().css_scale;
+ return PP_FALSE;
+ return enter.object()->GetClipRect(clip);
}
-const PPB_View g_ppb_view_thunk = {
+const PPB_View_1_0 g_ppb_view_thunk_1_0 = {
&IsView,
&GetRect,
&IsFullscreen,
- &IsUserVisible,
+ &IsVisible,
&IsPageVisible,
&GetClipRect
};
-const PPB_View_Dev g_ppb_view_dev_thunk = {
- &GetDeviceScale,
- &GetCSSScale
-};
-
} // namespace
-const PPB_View* GetPPB_View_1_0_Thunk() {
- return &g_ppb_view_thunk;
-}
-
-const PPB_View_Dev* GetPPB_View_Dev_0_1_Thunk() {
- return &g_ppb_view_dev_thunk;
+const PPB_View_1_0* GetPPB_View_1_0_Thunk() {
+ return &g_ppb_view_thunk_1_0;
}
} // namespace thunk