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/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 { | 12 namespace { |
13 | 13 |
14 DeviceFuncs<PPB_Buffer_Dev> buffer_f(PPB_BUFFER_DEV_INTERFACE); | 14 DeviceFuncs<PPB_Buffer_Dev> buffer_f(PPB_BUFFER_DEV_INTERFACE); |
15 | 15 |
16 } // namespace | 16 } // namespace |
17 | 17 |
18 namespace pp { | 18 namespace pp { |
19 | 19 |
20 Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) { | 20 Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) { |
21 } | 21 } |
22 | 22 |
23 Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) | 23 Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) |
24 : Resource(other), | 24 : Resource(other), |
25 data_(other.data_), | 25 data_(other.data_), |
26 size_(other.size_) { | 26 size_(other.size_) { |
27 } | 27 } |
28 | 28 |
29 Buffer_Dev::Buffer_Dev(int32_t size) : data_(NULL), size_(0) { | 29 Buffer_Dev::Buffer_Dev(uint32_t size) : data_(NULL), size_(0) { |
30 if (!buffer_f) | 30 if (!buffer_f) |
31 return; | 31 return; |
32 | 32 |
33 PassRefFromConstructor(buffer_f->Create(Module::Get()->pp_module(), size)); | 33 PassRefFromConstructor(buffer_f->Create(Module::Get()->pp_module(), size)); |
34 if (!buffer_f->Describe(pp_resource(), &size_) || | 34 if (!buffer_f->Describe(pp_resource(), &size_) || |
35 !(data_ = buffer_f->Map(pp_resource()))) | 35 !(data_ = buffer_f->Map(pp_resource()))) |
36 *this = Buffer_Dev(); | 36 *this = Buffer_Dev(); |
37 } | 37 } |
38 | 38 |
39 Buffer_Dev::~Buffer_Dev() { | 39 Buffer_Dev::~Buffer_Dev() { |
40 } | 40 } |
41 | 41 |
42 Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& other) { | 42 Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& other) { |
43 Buffer_Dev copy(other); | 43 Buffer_Dev copy(other); |
44 swap(copy); | 44 swap(copy); |
45 return *this; | 45 return *this; |
46 } | 46 } |
47 | 47 |
48 void Buffer_Dev::swap(Buffer_Dev& other) { | 48 void Buffer_Dev::swap(Buffer_Dev& other) { |
49 Resource::swap(other); | 49 Resource::swap(other); |
50 std::swap(size_, other.size_); | 50 std::swap(size_, other.size_); |
51 std::swap(data_, other.data_); | 51 std::swap(data_, other.data_); |
52 } | 52 } |
53 | 53 |
54 } // namespace pp | 54 } // namespace pp |
55 | 55 |
OLD | NEW |