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>() { |
| 26 return PPB_GRAPHICS_2D_INTERFACE_1_1; |
| 27 } |
| 28 |
25 } // namespace | 29 } // namespace |
26 | 30 |
27 Graphics2D::Graphics2D() : Resource() { | 31 Graphics2D::Graphics2D() : Resource() { |
28 } | 32 } |
29 | 33 |
30 Graphics2D::Graphics2D(const Graphics2D& other) | 34 Graphics2D::Graphics2D(const Graphics2D& other) |
31 : Resource(other), | 35 : Resource(other), |
32 size_(other.size_) { | 36 size_(other.size_) { |
33 } | 37 } |
34 | 38 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 *image = ImageData(); | 101 *image = ImageData(); |
98 } | 102 } |
99 | 103 |
100 int32_t Graphics2D::Flush(const CompletionCallback& cc) { | 104 int32_t Graphics2D::Flush(const CompletionCallback& cc) { |
101 if (!has_interface<PPB_Graphics2D_1_0>()) | 105 if (!has_interface<PPB_Graphics2D_1_0>()) |
102 return cc.MayForce(PP_ERROR_NOINTERFACE); | 106 return cc.MayForce(PP_ERROR_NOINTERFACE); |
103 return get_interface<PPB_Graphics2D_1_0>()->Flush( | 107 return get_interface<PPB_Graphics2D_1_0>()->Flush( |
104 pp_resource(), cc.pp_completion_callback()); | 108 pp_resource(), cc.pp_completion_callback()); |
105 } | 109 } |
106 | 110 |
| 111 // static |
| 112 bool Graphics2D::SupportsScale() { |
| 113 return has_interface<PPB_Graphics2D_1_1>(); |
| 114 } |
| 115 |
| 116 bool Graphics2D::SetScale(float scale) { |
| 117 if (!has_interface<PPB_Graphics2D_1_1>()) |
| 118 return false; |
| 119 return PP_ToBool(get_interface<PPB_Graphics2D_1_1>()->SetScale(pp_resource(), |
| 120 scale)); |
| 121 } |
| 122 |
| 123 float Graphics2D::GetScale() { |
| 124 if (!has_interface<PPB_Graphics2D_1_1>()) |
| 125 return 1.0f; |
| 126 return get_interface<PPB_Graphics2D_1_1>()->GetScale(pp_resource()); |
| 127 } |
| 128 |
107 } // namespace pp | 129 } // namespace pp |
OLD | NEW |