OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/common.h" |
9 #include "ppapi/cpp/completion_callback.h" | 10 #include "ppapi/cpp/completion_callback.h" |
10 #include "ppapi/cpp/image_data.h" | 11 #include "ppapi/cpp/image_data.h" |
11 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
12 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
13 #include "ppapi/cpp/point.h" | 14 #include "ppapi/cpp/point.h" |
14 #include "ppapi/cpp/rect.h" | 15 #include "ppapi/cpp/rect.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 DeviceFuncs<PPB_Graphics2D> graphics_2d_f(PPB_GRAPHICS_2D_INTERFACE); | 19 DeviceFuncs<PPB_Graphics2D> graphics_2d_f(PPB_GRAPHICS_2D_INTERFACE); |
19 | 20 |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 namespace pp { | 23 namespace pp { |
23 | 24 |
24 Graphics2D::Graphics2D() : Resource() { | 25 Graphics2D::Graphics2D() : Resource() { |
25 } | 26 } |
26 | 27 |
27 Graphics2D::Graphics2D(const Graphics2D& other) | 28 Graphics2D::Graphics2D(const Graphics2D& other) |
28 : Resource(other), | 29 : Resource(other), |
29 size_(other.size_) { | 30 size_(other.size_) { |
30 } | 31 } |
31 | 32 |
32 Graphics2D::Graphics2D(const Size& size, bool is_always_opaque) | 33 Graphics2D::Graphics2D(const Size& size, bool is_always_opaque) |
33 : Resource() { | 34 : Resource() { |
34 if (!graphics_2d_f) | 35 if (!graphics_2d_f) |
35 return; | 36 return; |
36 PassRefFromConstructor(graphics_2d_f->Create(Module::Get()->pp_module(), | 37 PassRefFromConstructor(graphics_2d_f->Create(Module::Get()->pp_module(), |
37 &size.pp_size(), | 38 &size.pp_size(), |
38 is_always_opaque)); | 39 BoolToPPBool(is_always_opaque))); |
39 if (!is_null()) { | 40 if (!is_null()) { |
40 // Only save the size if allocation succeeded. | 41 // Only save the size if allocation succeeded. |
41 size_ = size; | 42 size_ = size; |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
45 Graphics2D::~Graphics2D() { | 46 Graphics2D::~Graphics2D() { |
46 } | 47 } |
47 | 48 |
48 Graphics2D& Graphics2D::operator=(const Graphics2D& other) { | 49 Graphics2D& Graphics2D::operator=(const Graphics2D& other) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 *image = ImageData(); | 90 *image = ImageData(); |
90 } | 91 } |
91 | 92 |
92 int32_t Graphics2D::Flush(const CompletionCallback& cc) { | 93 int32_t Graphics2D::Flush(const CompletionCallback& cc) { |
93 if (!graphics_2d_f) | 94 if (!graphics_2d_f) |
94 return PP_ERROR_NOINTERFACE; | 95 return PP_ERROR_NOINTERFACE; |
95 return graphics_2d_f->Flush(pp_resource(), cc.pp_completion_callback()); | 96 return graphics_2d_f->Flush(pp_resource(), cc.pp_completion_callback()); |
96 } | 97 } |
97 | 98 |
98 } // namespace pp | 99 } // namespace pp |
OLD | NEW |