diff options
author | kaanb@chromium.org <kaanb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 22:18:57 +0000 |
---|---|---|
committer | kaanb@chromium.org <kaanb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 22:18:57 +0000 |
commit | f022d73e4353d3554216e8731bf2eab01778d91a (patch) | |
tree | 6be843a6a5d32e674170e5222a4f16f014d9daa5 | |
parent | b5382e56e7748de30b5fbdfb0dab168d725a6cdd (diff) | |
download | chromium_src-f022d73e4353d3554216e8731bf2eab01778d91a.zip chromium_src-f022d73e4353d3554216e8731bf2eab01778d91a.tar.gz chromium_src-f022d73e4353d3554216e8731bf2eab01778d91a.tar.bz2 |
Change Map() API to take in a mode for read/write/read-or-write, also pass gfx::Size by value as for small structs it's more efficient.
BUG=175012
Review URL: https://chromiumcodereview.appspot.com/13879002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193234 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | android_webview/browser/gpu_memory_buffer_impl.cc | 7 | ||||
-rw-r--r-- | android_webview/browser/gpu_memory_buffer_impl.h | 5 | ||||
-rw-r--r-- | android_webview/public/browser/draw_gl.h | 7 | ||||
-rw-r--r-- | ui/gl/gpu_memory_buffer.h | 13 |
4 files changed, 20 insertions, 12 deletions
diff --git a/android_webview/browser/gpu_memory_buffer_impl.cc b/android_webview/browser/gpu_memory_buffer_impl.cc index e67ad67..d42b361 100644 --- a/android_webview/browser/gpu_memory_buffer_impl.cc +++ b/android_webview/browser/gpu_memory_buffer_impl.cc @@ -17,7 +17,7 @@ namespace android_webview { // Provides hardware rendering functions from the Android glue layer. AwDrawGLFunctionTable* g_gl_draw_functions = NULL; -GpuMemoryBufferImpl::GpuMemoryBufferImpl(const gfx::Size& size) +GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::Size size) : buffer_id_(g_gl_draw_functions->create_graphic_buffer( size.width(), size.height())), size_(size) { @@ -29,9 +29,10 @@ GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { buffer_id_ = 0; } -void GpuMemoryBufferImpl::MapForWrite(void** vaddr) { +void GpuMemoryBufferImpl::Map(gfx::GpuMemoryBuffer::AccessMode mode, + void** vaddr) { DCHECK(buffer_id_ != 0); - int err = g_gl_draw_functions->lock_for_write(buffer_id_, vaddr); + int err = g_gl_draw_functions->lock(buffer_id_, mode, vaddr); DCHECK(err == 0); } diff --git a/android_webview/browser/gpu_memory_buffer_impl.h b/android_webview/browser/gpu_memory_buffer_impl.h index dc6f598..bd4e436 100644 --- a/android_webview/browser/gpu_memory_buffer_impl.h +++ b/android_webview/browser/gpu_memory_buffer_impl.h @@ -17,11 +17,12 @@ namespace android_webview { class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { public: static void SetAwDrawGLFunctionTable(AwDrawGLFunctionTable* table); - GpuMemoryBufferImpl(const gfx::Size& size); + GpuMemoryBufferImpl(gfx::Size size); virtual ~GpuMemoryBufferImpl(); // methods from GpuMemoryBuffer - virtual void MapForWrite(void** vaddr) OVERRIDE; + virtual void Map(gfx::GpuMemoryBuffer::AccessMode mode, + void** vaddr) OVERRIDE; virtual void Unmap() OVERRIDE; virtual void* GetNativeBuffer() OVERRIDE; virtual uint32 GetStride() OVERRIDE; diff --git a/android_webview/public/browser/draw_gl.h b/android_webview/public/browser/draw_gl.h index bfbf8a4..4c43669 100644 --- a/android_webview/public/browser/draw_gl.h +++ b/android_webview/public/browser/draw_gl.h @@ -82,8 +82,9 @@ typedef void (AwDrawGLFunction)(int view_context, typedef int AwCreateGraphicBufferFunction(int w, int h); // Called to release a GraphicBuffer typedef void AwReleaseGraphicBufferFunction(int buffer_id); -// Called to lock a GraphicBuffer for writing -typedef int AwLockForWriteFunction(int buffer_id, void** vaddr); +// Called to lock a GraphicBuffer in |mode|, which is +// defined in AccessMode enum in ui/gl/gpu_memory_buffer.h +typedef int AwLockFunction(int buffer_id, int mode, void** vaddr); // Called to unlock a GraphicBuffer typedef int AwUnlockFunction(int buffer_id); // Called to get a native buffer pointer @@ -95,7 +96,7 @@ typedef unsigned int AwGetStrideFunction(int buffer_id); struct AwDrawGLFunctionTable { AwCreateGraphicBufferFunction* create_graphic_buffer; AwReleaseGraphicBufferFunction* release_graphic_buffer; - AwLockForWriteFunction* lock_for_write; + AwLockFunction* lock; AwUnlockFunction* unlock; AwGetNativeBufferFunction* get_native_buffer; AwGetStrideFunction* get_stride; diff --git a/ui/gl/gpu_memory_buffer.h b/ui/gl/gpu_memory_buffer.h index 2e24903..403c278 100644 --- a/ui/gl/gpu_memory_buffer.h +++ b/ui/gl/gpu_memory_buffer.h @@ -18,12 +18,17 @@ class Size; // // THREADING CONSIDERATIONS: // -// This interface is thread-safe. However, multiple threads calling -// MapForWrite() simultaneously may result in undefined behavior -// and is not allowed. +// This interface is thread-safe. However, multiple threads mapping +// a buffer for Write or ReadOrWrite simultaneously may result in undefined +// behavior and is not allowed. class GpuMemoryBuffer { public: typedef base::Callback<scoped_ptr<gfx::GpuMemoryBuffer>(gfx::Size)> Create; + enum AccessMode { + READ_ONLY, + WRITE_ONLY, + READ_OR_WRITE, + }; // Frees a previously allocated buffer. Freeing a buffer that is still // mapped in any process is undefined behavior. @@ -32,7 +37,7 @@ class GpuMemoryBuffer { // Maps the buffer so the client can write the bitmap data in |*vaddr| // subsequently. This call may block, for instance if the hardware needs // to finish rendering or if CPU caches need to be synchronized. - virtual void MapForWrite(void** vaddr) = 0; + virtual void Map(AccessMode mode, void** vaddr) = 0; // Unmaps the buffer. Called after all changes to the buffer are // completed. |