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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// Copyright 2014 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/cpp/compositor_layer.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/var.h"
namespace pp {
namespace {
template <> const char* interface_name<PPB_CompositorLayer_0_1>() {
return PPB_COMPOSITORLAYER_INTERFACE_0_1;
}
} // namespace
CompositorLayer::CompositorLayer() {
}
CompositorLayer::CompositorLayer(
const CompositorLayer& other) : Resource(other) {
}
CompositorLayer::CompositorLayer(const Resource& resource)
: Resource(resource) {
PP_DCHECK(IsCompositorLayer(resource));
}
CompositorLayer::CompositorLayer(PassRef, PP_Resource resource)
: Resource(PASS_REF, resource) {
}
CompositorLayer::~CompositorLayer() {
}
int32_t CompositorLayer::SetColor(float red,
float green,
float blue,
float alpha,
const Size& size) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetColor(
pp_resource(), red, green, blue, alpha, &size.pp_size());
}
return PP_ERROR_NOINTERFACE;
}
int32_t CompositorLayer::SetTexture(const Graphics3D& context,
uint32_t texture,
const Size& size,
const CompletionCallback& cc) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetTexture(
pp_resource(), context.pp_resource(), texture, &size.pp_size(),
cc.pp_completion_callback());
}
return cc.MayForce(PP_ERROR_NOINTERFACE);
}
int32_t CompositorLayer::SetImage(const ImageData& image,
const CompletionCallback& cc) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetImage(
pp_resource(), image.pp_resource(), NULL,
cc.pp_completion_callback());
}
return cc.MayForce(PP_ERROR_NOINTERFACE);
}
int32_t CompositorLayer::SetImage(const ImageData& image,
const Size& size,
const CompletionCallback& cc) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetImage(
pp_resource(), image.pp_resource(), &size.pp_size(),
cc.pp_completion_callback());
}
return cc.MayForce(PP_ERROR_NOINTERFACE);
}
int32_t CompositorLayer::SetClipRect(const Rect& rect) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetClipRect(
pp_resource(), &rect.pp_rect());
}
return PP_ERROR_NOINTERFACE;
}
int32_t CompositorLayer::SetTransform(const float matrix[16]) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetTransform(
pp_resource(), matrix);
}
return PP_ERROR_NOINTERFACE;
}
int32_t CompositorLayer::SetOpacity(float opacity) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetOpacity(
pp_resource(), opacity);
}
return PP_ERROR_NOINTERFACE;
}
int32_t CompositorLayer::SetBlendMode(PP_BlendMode mode) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetBlendMode(
pp_resource(), mode);
}
return PP_ERROR_NOINTERFACE;
}
int32_t CompositorLayer::SetSourceRect(const FloatRect& rect) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetSourceRect(
pp_resource(), &rect.pp_float_rect());
}
return PP_ERROR_NOINTERFACE;
}
int32_t CompositorLayer::SetPremultipliedAlpha(bool premult) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return get_interface<PPB_CompositorLayer_0_1>()->SetPremultipliedAlpha(
pp_resource(), PP_FromBool(premult));
}
return PP_ERROR_NOINTERFACE;
}
bool CompositorLayer::IsCompositorLayer(const Resource& resource) {
if (has_interface<PPB_CompositorLayer_0_1>()) {
return PP_ToBool(get_interface<PPB_CompositorLayer_0_1>()->
IsCompositorLayer(resource.pp_resource()));
}
return false;
}
} // namespace pp
|