OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/cpp/compositor_layer.h" | 5 #include "ppapi/cpp/compositor_layer.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/cpp/completion_callback.h" | 8 #include "ppapi/cpp/completion_callback.h" |
9 #include "ppapi/cpp/module_impl.h" | 9 #include "ppapi/cpp/module_impl.h" |
10 #include "ppapi/cpp/var.h" | 10 #include "ppapi/cpp/var.h" |
11 | 11 |
12 namespace pp { | 12 namespace pp { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 template <> const char* interface_name<PPB_CompositorLayer_0_1>() { | 16 template <> const char* interface_name<PPB_CompositorLayer_0_1>() { |
17 return PPB_COMPOSITORLAYER_INTERFACE_0_1; | 17 return PPB_COMPOSITORLAYER_INTERFACE_0_1; |
18 } | 18 } |
19 | 19 |
20 template <> const char* interface_name<PPB_CompositorLayer_0_2>() { | |
21 return PPB_COMPOSITORLAYER_INTERFACE_0_2; | |
22 } | |
23 | |
20 } // namespace | 24 } // namespace |
21 | 25 |
22 CompositorLayer::CompositorLayer() { | 26 CompositorLayer::CompositorLayer() { |
23 } | 27 } |
24 | 28 |
25 CompositorLayer::CompositorLayer( | 29 CompositorLayer::CompositorLayer( |
26 const CompositorLayer& other) : Resource(other) { | 30 const CompositorLayer& other) : Resource(other) { |
27 } | 31 } |
28 | 32 |
29 CompositorLayer::CompositorLayer(const Resource& resource) | 33 CompositorLayer::CompositorLayer(const Resource& resource) |
(...skipping 14 matching lines...) Expand all Loading... | |
44 float alpha, | 48 float alpha, |
45 const Size& size) { | 49 const Size& size) { |
46 if (has_interface<PPB_CompositorLayer_0_1>()) { | 50 if (has_interface<PPB_CompositorLayer_0_1>()) { |
47 return get_interface<PPB_CompositorLayer_0_1>()->SetColor( | 51 return get_interface<PPB_CompositorLayer_0_1>()->SetColor( |
48 pp_resource(), red, green, blue, alpha, &size.pp_size()); | 52 pp_resource(), red, green, blue, alpha, &size.pp_size()); |
49 } | 53 } |
50 return PP_ERROR_NOINTERFACE; | 54 return PP_ERROR_NOINTERFACE; |
51 } | 55 } |
52 | 56 |
53 int32_t CompositorLayer::SetTexture(const Graphics3D& context, | 57 int32_t CompositorLayer::SetTexture(const Graphics3D& context, |
58 uint32_t target, | |
54 uint32_t texture, | 59 uint32_t texture, |
55 const Size& size, | 60 const Size& size, |
56 const CompletionCallback& cc) { | 61 const CompletionCallback& cc) { |
62 if (has_interface<PPB_CompositorLayer_0_2>()) { | |
63 return get_interface<PPB_CompositorLayer_0_2>()->SetTexture( | |
64 pp_resource(), context.pp_resource(), target, texture, &size.pp_size(), | |
65 cc.pp_completion_callback()); | |
66 } | |
57 if (has_interface<PPB_CompositorLayer_0_1>()) { | 67 if (has_interface<PPB_CompositorLayer_0_1>()) { |
68 if (target != 0x0DE1) // 0x0DE1 GL_TEXTURE_2D | |
69 return cc.MayForce(PP_ERROR_BADARGUMENT); | |
bbudge
2014/08/15 17:10:11
I think PP_ERROR_NOTSUPPORTED is more appropriate
Peng
2014/08/15 17:58:44
Done.
| |
58 return get_interface<PPB_CompositorLayer_0_1>()->SetTexture( | 70 return get_interface<PPB_CompositorLayer_0_1>()->SetTexture( |
59 pp_resource(), context.pp_resource(), texture, &size.pp_size(), | 71 pp_resource(), context.pp_resource(), texture, &size.pp_size(), |
60 cc.pp_completion_callback()); | 72 cc.pp_completion_callback()); |
61 } | 73 } |
62 return cc.MayForce(PP_ERROR_NOINTERFACE); | 74 return cc.MayForce(PP_ERROR_NOINTERFACE); |
63 } | 75 } |
64 | 76 |
65 int32_t CompositorLayer::SetImage(const ImageData& image, | 77 int32_t CompositorLayer::SetImage(const ImageData& image, |
66 const CompletionCallback& cc) { | 78 const CompletionCallback& cc) { |
67 if (has_interface<PPB_CompositorLayer_0_1>()) { | 79 if (has_interface<PPB_CompositorLayer_0_1>()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 145 |
134 bool CompositorLayer::IsCompositorLayer(const Resource& resource) { | 146 bool CompositorLayer::IsCompositorLayer(const Resource& resource) { |
135 if (has_interface<PPB_CompositorLayer_0_1>()) { | 147 if (has_interface<PPB_CompositorLayer_0_1>()) { |
136 return PP_ToBool(get_interface<PPB_CompositorLayer_0_1>()-> | 148 return PP_ToBool(get_interface<PPB_CompositorLayer_0_1>()-> |
137 IsCompositorLayer(resource.pp_resource())); | 149 IsCompositorLayer(resource.pp_resource())); |
138 } | 150 } |
139 return false; | 151 return false; |
140 } | 152 } |
141 | 153 |
142 } // namespace pp | 154 } // namespace pp |
OLD | NEW |