summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/dev/buffer_dev.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi/cpp/dev/buffer_dev.cc')
-rw-r--r--ppapi/cpp/dev/buffer_dev.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc
index 38a1b1f..d2be1d0 100644
--- a/ppapi/cpp/dev/buffer_dev.cc
+++ b/ppapi/cpp/dev/buffer_dev.cc
@@ -24,10 +24,7 @@ Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) {
Buffer_Dev::Buffer_Dev(const Buffer_Dev& other)
: Resource(other) {
- if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) ||
- !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) {
- *this = Buffer_Dev();
- }
+ Init();
}
Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size)
@@ -38,14 +35,25 @@ Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size)
PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create(
instance->pp_instance(), size));
- if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) ||
- !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) {
- *this = Buffer_Dev();
- }
+ Init();
}
Buffer_Dev::~Buffer_Dev() {
get_interface<PPB_Buffer_Dev>()->Unmap(pp_resource());
}
+Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) {
+ Resource::operator=(rhs);
+ Init();
+ return *this;
+}
+
+void Buffer_Dev::Init() {
+ if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) ||
+ !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) {
+ data_ = NULL;
+ size_ = 0;
+ }
+}
+
} // namespace pp