OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dev/buffer_dev.h" | 5 #include "ppapi/cpp/dev/buffer_dev.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_buffer_dev.h" | 7 #include "ppapi/c/dev/ppb_buffer_dev.h" |
8 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
10 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
11 | 11 |
12 namespace pp { | 12 namespace pp { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 template <> const char* interface_name<PPB_Buffer_Dev>() { | 16 template <> const char* interface_name<PPB_Buffer_Dev>() { |
17 return PPB_BUFFER_DEV_INTERFACE; | 17 return PPB_BUFFER_DEV_INTERFACE; |
18 } | 18 } |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) { | 22 Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) { |
23 } | 23 } |
24 | 24 |
25 Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) | 25 Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) |
26 : Resource(other) { | 26 : Resource(other) { |
27 Init(); | 27 Init(); |
28 } | 28 } |
29 | 29 |
| 30 Buffer_Dev::Buffer_Dev(PP_Resource resource) |
| 31 : Resource(resource) { |
| 32 Init(); |
| 33 } |
| 34 |
30 Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size) | 35 Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size) |
31 : data_(NULL), | 36 : data_(NULL), |
32 size_(0) { | 37 size_(0) { |
33 if (!has_interface<PPB_Buffer_Dev>()) | 38 if (!has_interface<PPB_Buffer_Dev>()) |
34 return; | 39 return; |
35 | 40 |
36 PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create( | 41 PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create( |
37 instance->pp_instance(), size)); | 42 instance->pp_instance(), size)); |
38 Init(); | 43 Init(); |
39 } | 44 } |
(...skipping 10 matching lines...) Expand all Loading... |
50 | 55 |
51 void Buffer_Dev::Init() { | 56 void Buffer_Dev::Init() { |
52 if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || | 57 if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || |
53 !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { | 58 !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { |
54 data_ = NULL; | 59 data_ = NULL; |
55 size_ = 0; | 60 size_ = 0; |
56 } | 61 } |
57 } | 62 } |
58 | 63 |
59 } // namespace pp | 64 } // namespace pp |
OLD | NEW |