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