| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "gpu/command_buffer/common/sync_token.h" | |
| 12 #include "ui/gfx/geometry/size.h" | 11 #include "ui/gfx/geometry/size.h" |
| 13 #include "ui/gfx/gpu_memory_buffer.h" | 12 #include "ui/gfx/gpu_memory_buffer.h" |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 | 15 |
| 17 // Provides common implementation of a GPU memory buffer. | 16 // Provides common implementation of a GPU memory buffer. |
| 18 class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 17 class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
| 19 public: | 18 public: |
| 20 typedef base::Callback<void(const gpu::SyncToken& sync)> DestructionCallback; | 19 typedef base::Callback<void(uint32 sync_point)> DestructionCallback; |
| 21 | 20 |
| 22 ~GpuMemoryBufferImpl() override; | 21 ~GpuMemoryBufferImpl() override; |
| 23 | 22 |
| 24 // Creates an instance from the given |handle|. |size| and |internalformat| | 23 // Creates an instance from the given |handle|. |size| and |internalformat| |
| 25 // should match what was used to allocate the |handle|. |callback| is | 24 // should match what was used to allocate the |handle|. |callback| is |
| 26 // called when instance is deleted, which is not necessarily on the same | 25 // called when instance is deleted, which is not necessarily on the same |
| 27 // thread as this function was called on and instance was created on. | 26 // thread as this function was called on and instance was created on. |
| 28 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 27 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
| 29 const gfx::GpuMemoryBufferHandle& handle, | 28 const gfx::GpuMemoryBufferHandle& handle, |
| 30 const gfx::Size& size, | 29 const gfx::Size& size, |
| 31 gfx::BufferFormat format, | 30 gfx::BufferFormat format, |
| 32 gfx::BufferUsage usage, | 31 gfx::BufferUsage usage, |
| 33 const DestructionCallback& callback); | 32 const DestructionCallback& callback); |
| 34 | 33 |
| 35 // Type-checking upcast routine. Returns an NULL on failure. | 34 // Type-checking upcast routine. Returns an NULL on failure. |
| 36 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer); | 35 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer); |
| 37 | 36 |
| 38 // Overridden from gfx::GpuMemoryBuffer: | 37 // Overridden from gfx::GpuMemoryBuffer: |
| 39 gfx::Size GetSize() const override; | 38 gfx::Size GetSize() const override; |
| 40 gfx::BufferFormat GetFormat() const override; | 39 gfx::BufferFormat GetFormat() const override; |
| 41 gfx::GpuMemoryBufferId GetId() const override; | 40 gfx::GpuMemoryBufferId GetId() const override; |
| 42 ClientBuffer AsClientBuffer() override; | 41 ClientBuffer AsClientBuffer() override; |
| 43 | 42 |
| 44 void set_destruction_sync_token(const gpu::SyncToken& sync_token) { | 43 void set_destruction_sync_point(uint32 sync_point) { |
| 45 destruction_sync_token_ = sync_token; | 44 destruction_sync_point_ = sync_point; |
| 46 } | 45 } |
| 47 | 46 |
| 48 protected: | 47 protected: |
| 49 GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, | 48 GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, |
| 50 const gfx::Size& size, | 49 const gfx::Size& size, |
| 51 gfx::BufferFormat format, | 50 gfx::BufferFormat format, |
| 52 const DestructionCallback& callback); | 51 const DestructionCallback& callback); |
| 53 | 52 |
| 54 const gfx::GpuMemoryBufferId id_; | 53 const gfx::GpuMemoryBufferId id_; |
| 55 const gfx::Size size_; | 54 const gfx::Size size_; |
| 56 const gfx::BufferFormat format_; | 55 const gfx::BufferFormat format_; |
| 57 const DestructionCallback callback_; | 56 const DestructionCallback callback_; |
| 58 bool mapped_; | 57 bool mapped_; |
| 59 gpu::SyncToken destruction_sync_token_; | 58 uint32 destruction_sync_point_; |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 61 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 } // namespace content | 64 } // namespace content |
| 66 | 65 |
| 67 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 66 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| OLD | NEW |