summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk/ppb_view_thunk.cc
blob: 3014099dda8280df0a497d71ff612964823439d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// 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 ppb_view.idl modified Wed Apr 10 14:15:15 2013.

#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_view.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 {

PP_Bool IsView(PP_Resource resource) {
  VLOG(4) << "PPB_View::IsView()";
  EnterResource<PPB_View_API> enter(resource, false);
  return PP_FromBool(enter.succeeded());
}

PP_Bool GetRect(PP_Resource resource, struct PP_Rect* rect) {
  VLOG(4) << "PPB_View::GetRect()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.object()->GetRect(rect);
}

PP_Bool IsFullscreen(PP_Resource resource) {
  VLOG(4) << "PPB_View::IsFullscreen()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.object()->IsFullscreen();
}

PP_Bool IsVisible(PP_Resource resource) {
  VLOG(4) << "PPB_View::IsVisible()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.object()->IsVisible();
}

PP_Bool IsPageVisible(PP_Resource resource) {
  VLOG(4) << "PPB_View::IsPageVisible()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.object()->IsPageVisible();
}

PP_Bool GetClipRect(PP_Resource resource, struct PP_Rect* clip) {
  VLOG(4) << "PPB_View::GetClipRect()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.object()->GetClipRect(clip);
}

float GetDeviceScale(PP_Resource resource) {
  VLOG(4) << "PPB_View::GetDeviceScale()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return 0.0f;
  return enter.object()->GetDeviceScale();
}

float GetCSSScale(PP_Resource resource) {
  VLOG(4) << "PPB_View::GetCSSScale()";
  EnterResource<PPB_View_API> enter(resource, true);
  if (enter.failed())
    return 0.0f;
  return enter.object()->GetCSSScale();
}

const PPB_View_1_0 g_ppb_view_thunk_1_0 = {
  &IsView,
  &GetRect,
  &IsFullscreen,
  &IsVisible,
  &IsPageVisible,
  &GetClipRect
};

const PPB_View_1_1 g_ppb_view_thunk_1_1 = {
  &IsView,
  &GetRect,
  &IsFullscreen,
  &IsVisible,
  &IsPageVisible,
  &GetClipRect,
  &GetDeviceScale,
  &GetCSSScale
};

}  // namespace

const PPB_View_1_0* GetPPB_View_1_0_Thunk() {
  return &g_ppb_view_thunk_1_0;
}

const PPB_View_1_1* GetPPB_View_1_1_Thunk() {
  return &g_ppb_view_thunk_1_1;
}

}  // namespace thunk
}  // namespace ppapi