1 // Copyright (c) 2012 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.
5 #include "ppapi/cpp/view.h"
7 #include "ppapi/c/ppb_view.h"
8 #include "ppapi/cpp/module_impl.h"
14 template <> const char* interface_name
<PPB_View_1_0
>() {
15 return PPB_VIEW_INTERFACE_1_0
;
18 template <> const char* interface_name
<PPB_View_1_1
>() {
19 return PPB_VIEW_INTERFACE_1_1
;
24 View::View() : Resource() {
27 View::View(PP_Resource view_resource
) : Resource(view_resource
) {
30 Rect
View::GetRect() const {
32 if (has_interface
<PPB_View_1_1
>()) {
33 if (PP_ToBool(get_interface
<PPB_View_1_1
>()->GetRect(pp_resource(), &out
)))
35 } else if (has_interface
<PPB_View_1_0
>()) {
36 if (PP_ToBool(get_interface
<PPB_View_1_0
>()->GetRect(pp_resource(), &out
)))
42 bool View::IsFullscreen() const {
43 if (has_interface
<PPB_View_1_1
>()) {
44 return PP_ToBool(get_interface
<PPB_View_1_1
>()->IsFullscreen(
46 } else if (has_interface
<PPB_View_1_0
>()) {
47 return PP_ToBool(get_interface
<PPB_View_1_0
>()->IsFullscreen(
53 bool View::IsVisible() const {
54 if (has_interface
<PPB_View_1_1
>())
55 return PP_ToBool(get_interface
<PPB_View_1_1
>()->IsVisible(pp_resource()));
56 else if (has_interface
<PPB_View_1_0
>())
57 return PP_ToBool(get_interface
<PPB_View_1_0
>()->IsVisible(pp_resource()));
61 bool View::IsPageVisible() const {
62 if (has_interface
<PPB_View_1_1
>()) {
63 return PP_ToBool(get_interface
<PPB_View_1_1
>()->IsPageVisible(
65 } else if (has_interface
<PPB_View_1_0
>()) {
66 return PP_ToBool(get_interface
<PPB_View_1_0
>()->IsPageVisible(
72 Rect
View::GetClipRect() const {
74 if (has_interface
<PPB_View_1_1
>()) {
75 if (PP_ToBool(get_interface
<PPB_View_1_1
>()->GetClipRect(pp_resource(),
78 } else if (has_interface
<PPB_View_1_0
>()) {
79 if (PP_ToBool(get_interface
<PPB_View_1_0
>()->GetClipRect(pp_resource(),
86 float View::GetDeviceScale() const {
87 if (has_interface
<PPB_View_1_1
>())
88 return get_interface
<PPB_View_1_1
>()->GetDeviceScale(pp_resource());
92 float View::GetCSSScale() const {
93 if (has_interface
<PPB_View_1_1
>())
94 return get_interface
<PPB_View_1_1
>()->GetCSSScale(pp_resource());