Change a bug reference in a comment.
[chromium-blink-merge.git] / ppapi / thunk / ppb_compositor_layer_thunk.cc
blob03afa5fbcdb8ea74102543a91ec4876d75f820ac
1 // Copyright 2014 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 // From ppb_compositor_layer.idl modified Thu Jan 29 16:28:15 2015.
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_compositor_layer.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppapi_thunk_export.h"
13 #include "ppapi/thunk/ppb_compositor_layer_api.h"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
20 PP_Bool IsCompositorLayer(PP_Resource resource) {
21 VLOG(4) << "PPB_CompositorLayer::IsCompositorLayer()";
22 EnterResource<PPB_CompositorLayer_API> enter(resource, false);
23 return PP_FromBool(enter.succeeded());
26 int32_t SetColor(PP_Resource layer,
27 float red,
28 float green,
29 float blue,
30 float alpha,
31 const struct PP_Size* size) {
32 VLOG(4) << "PPB_CompositorLayer::SetColor()";
33 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
34 if (enter.failed())
35 return enter.retval();
36 return enter.object()->SetColor(red, green, blue, alpha, size);
39 int32_t SetTexture_0_1(PP_Resource layer,
40 PP_Resource context,
41 uint32_t texture,
42 const struct PP_Size* size,
43 struct PP_CompletionCallback cc) {
44 VLOG(4) << "PPB_CompositorLayer::SetTexture_0_1()";
45 EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true);
46 if (enter.failed())
47 return enter.retval();
48 return enter.SetResult(
49 enter.object()->SetTexture0_1(context, texture, size, enter.callback()));
52 int32_t SetTexture(PP_Resource layer,
53 PP_Resource context,
54 uint32_t target,
55 uint32_t texture,
56 const struct PP_Size* size,
57 struct PP_CompletionCallback cc) {
58 VLOG(4) << "PPB_CompositorLayer::SetTexture()";
59 EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true);
60 if (enter.failed())
61 return enter.retval();
62 return enter.SetResult(enter.object()->SetTexture(context, target, texture,
63 size, enter.callback()));
66 int32_t SetImage(PP_Resource layer,
67 PP_Resource image_data,
68 const struct PP_Size* size,
69 struct PP_CompletionCallback cc) {
70 VLOG(4) << "PPB_CompositorLayer::SetImage()";
71 EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true);
72 if (enter.failed())
73 return enter.retval();
74 return enter.SetResult(
75 enter.object()->SetImage(image_data, size, enter.callback()));
78 int32_t SetClipRect(PP_Resource layer, const struct PP_Rect* rect) {
79 VLOG(4) << "PPB_CompositorLayer::SetClipRect()";
80 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
81 if (enter.failed())
82 return enter.retval();
83 return enter.object()->SetClipRect(rect);
86 int32_t SetTransform(PP_Resource layer, const float matrix[16]) {
87 VLOG(4) << "PPB_CompositorLayer::SetTransform()";
88 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
89 if (enter.failed())
90 return enter.retval();
91 return enter.object()->SetTransform(matrix);
94 int32_t SetOpacity(PP_Resource layer, float opacity) {
95 VLOG(4) << "PPB_CompositorLayer::SetOpacity()";
96 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
97 if (enter.failed())
98 return enter.retval();
99 return enter.object()->SetOpacity(opacity);
102 int32_t SetBlendMode(PP_Resource layer, PP_BlendMode mode) {
103 VLOG(4) << "PPB_CompositorLayer::SetBlendMode()";
104 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
105 if (enter.failed())
106 return enter.retval();
107 return enter.object()->SetBlendMode(mode);
110 int32_t SetSourceRect(PP_Resource layer, const struct PP_FloatRect* rect) {
111 VLOG(4) << "PPB_CompositorLayer::SetSourceRect()";
112 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
113 if (enter.failed())
114 return enter.retval();
115 return enter.object()->SetSourceRect(rect);
118 int32_t SetPremultipliedAlpha(PP_Resource layer, PP_Bool premult) {
119 VLOG(4) << "PPB_CompositorLayer::SetPremultipliedAlpha()";
120 EnterResource<PPB_CompositorLayer_API> enter(layer, true);
121 if (enter.failed())
122 return enter.retval();
123 return enter.object()->SetPremultipliedAlpha(premult);
126 const PPB_CompositorLayer_0_1 g_ppb_compositorlayer_thunk_0_1 = {
127 &IsCompositorLayer,
128 &SetColor,
129 &SetTexture_0_1,
130 &SetImage,
131 &SetClipRect,
132 &SetTransform,
133 &SetOpacity,
134 &SetBlendMode,
135 &SetSourceRect,
136 &SetPremultipliedAlpha};
138 const PPB_CompositorLayer_0_2 g_ppb_compositorlayer_thunk_0_2 = {
139 &IsCompositorLayer,
140 &SetColor,
141 &SetTexture,
142 &SetImage,
143 &SetClipRect,
144 &SetTransform,
145 &SetOpacity,
146 &SetBlendMode,
147 &SetSourceRect,
148 &SetPremultipliedAlpha};
150 } // namespace
152 PPAPI_THUNK_EXPORT const PPB_CompositorLayer_0_1*
153 GetPPB_CompositorLayer_0_1_Thunk() {
154 return &g_ppb_compositorlayer_thunk_0_1;
157 PPAPI_THUNK_EXPORT const PPB_CompositorLayer_0_2*
158 GetPPB_CompositorLayer_0_2_Thunk() {
159 return &g_ppb_compositorlayer_thunk_0_2;
162 } // namespace thunk
163 } // namespace ppapi