OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/graphics_2d.h" | 5 #include "ppapi/cpp/graphics_2d.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/ppb_graphics_2d.h" | 8 #include "ppapi/c/ppb_graphics_2d.h" |
9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
11 #include "ppapi/cpp/instance_handle.h" | 11 #include "ppapi/cpp/instance_handle.h" |
12 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
13 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
14 #include "ppapi/cpp/point.h" | 14 #include "ppapi/cpp/point.h" |
15 #include "ppapi/cpp/rect.h" | 15 #include "ppapi/cpp/rect.h" |
16 | 16 |
17 namespace pp { | 17 namespace pp { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 template <> const char* interface_name<PPB_Graphics2D_1_0>() { | 21 template <> const char* interface_name<PPB_Graphics2D_1_0>() { |
22 return PPB_GRAPHICS_2D_INTERFACE_1_0; | 22 return PPB_GRAPHICS_2D_INTERFACE_1_0; |
23 } | 23 } |
24 | 24 |
25 template <> const char* interface_name<PPB_Graphics2D_1_1>() { | 25 template <> const char* interface_name<PPB_Graphics2D_1_1>() { |
26 return PPB_GRAPHICS_2D_INTERFACE_1_1; | 26 return PPB_GRAPHICS_2D_INTERFACE_1_1; |
27 } | 27 } |
28 | 28 |
| 29 template <> const char* interface_name<PPB_Graphics2D_1_2>() { |
| 30 return PPB_GRAPHICS_2D_INTERFACE_1_2; |
| 31 } |
| 32 |
| 33 |
29 } // namespace | 34 } // namespace |
30 | 35 |
31 Graphics2D::Graphics2D() : Resource() { | 36 Graphics2D::Graphics2D() : Resource() { |
32 } | 37 } |
33 | 38 |
34 Graphics2D::Graphics2D(const Graphics2D& other) | 39 Graphics2D::Graphics2D(const Graphics2D& other) |
35 : Resource(other), | 40 : Resource(other), |
36 size_(other.size_) { | 41 size_(other.size_) { |
37 } | 42 } |
38 | 43 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return PP_ToBool(get_interface<PPB_Graphics2D_1_1>()->SetScale(pp_resource(), | 150 return PP_ToBool(get_interface<PPB_Graphics2D_1_1>()->SetScale(pp_resource(), |
146 scale)); | 151 scale)); |
147 } | 152 } |
148 | 153 |
149 float Graphics2D::GetScale() { | 154 float Graphics2D::GetScale() { |
150 if (!has_interface<PPB_Graphics2D_1_1>()) | 155 if (!has_interface<PPB_Graphics2D_1_1>()) |
151 return 1.0f; | 156 return 1.0f; |
152 return get_interface<PPB_Graphics2D_1_1>()->GetScale(pp_resource()); | 157 return get_interface<PPB_Graphics2D_1_1>()->GetScale(pp_resource()); |
153 } | 158 } |
154 | 159 |
| 160 bool Graphics2D::SetLayerTransform(float scale, |
| 161 const Point& origin, |
| 162 const Point& translate) { |
| 163 if (!has_interface<PPB_Graphics2D_1_2>()) |
| 164 return false; |
| 165 return PP_ToBool(get_interface<PPB_Graphics2D_1_2>()->SetLayerTransform( |
| 166 pp_resource(), scale, &origin.pp_point(), &translate.pp_point())); |
| 167 } |
| 168 |
| 169 |
155 } // namespace pp | 170 } // namespace pp |
OLD | NEW |