Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fix map map map unmap
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
index 1db7033..90be4b3 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc
@@ -30,7 +30,8 @@ GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap(
const DestructionCallback& callback,
scoped_ptr<ui::ClientNativePixmap> pixmap)
: GpuMemoryBufferImpl(id, size, format, callback),
- pixmap_(std::move(pixmap)) {}
+ pixmap_(std::move(pixmap)),
+ data_(nullptr) {}
GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {}
@@ -75,7 +76,9 @@ base::Closure GpuMemoryBufferImplOzoneNativePixmap::AllocateForTesting(
bool GpuMemoryBufferImplOzoneNativePixmap::Map() {
DCHECK(!mapped_);
- if (!pixmap_->Map())
+ DCHECK(!data_);
+ data_ = pixmap_->Map();
+ if (!data_)
return false;
mapped_ = true;
return mapped_;
@@ -84,13 +87,15 @@ bool GpuMemoryBufferImplOzoneNativePixmap::Map() {
void* GpuMemoryBufferImplOzoneNativePixmap::memory(size_t plane) {
DCHECK(mapped_);
DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
- return pixmap_->Map();
+ return data_;
}
void GpuMemoryBufferImplOzoneNativePixmap::Unmap() {
DCHECK(mapped_);
+ DCHECK(data_);
pixmap_->Unmap();
mapped_ = false;
+ data_ = nullptr;
}
int GpuMemoryBufferImplOzoneNativePixmap::stride(size_t plane) const {
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h
index aa073e1..3d89eb4 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h
@@ -54,6 +54,7 @@ class CONTENT_EXPORT GpuMemoryBufferImplOzoneNativePixmap
scoped_ptr<ui::ClientNativePixmap> native_pixmap);
scoped_ptr<ui::ClientNativePixmap> pixmap_;
+ void* data_;
DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplOzoneNativePixmap);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.