| 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 "ui/gfx/gpu_memory_buffer.h" | 10 #include "ui/gfx/gpu_memory_buffer.h" |
| 11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // Provides common implementation of a GPU memory buffer. | 15 // Provides common implementation of a GPU memory buffer. |
| 16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
| 17 public: | 17 public: |
| 18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> | 18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> |
| 19 CreationCallback; | 19 CreationCallback; |
| 20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
| 21 AllocationCallback; | 21 AllocationCallback; |
| 22 typedef base::Closure DestructionCallback; | 22 typedef base::Closure DestructionCallback; |
| 23 | 23 |
| 24 virtual ~GpuMemoryBufferImpl(); | 24 ~GpuMemoryBufferImpl() override; |
| 25 | 25 |
| 26 // Creates a GPU memory buffer instance with |size| and |format| for |usage| | 26 // Creates a GPU memory buffer instance with |size| and |format| for |usage| |
| 27 // by the current process and |client_id|. | 27 // by the current process and |client_id|. |
| 28 static void Create(const gfx::Size& size, | 28 static void Create(const gfx::Size& size, |
| 29 Format format, | 29 Format format, |
| 30 Usage usage, | 30 Usage usage, |
| 31 int client_id, | 31 int client_id, |
| 32 const CreationCallback& callback); | 32 const CreationCallback& callback); |
| 33 | 33 |
| 34 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| | 34 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| |
| (...skipping 22 matching lines...) Expand all Loading... |
| 57 const DestructionCallback& callback); | 57 const DestructionCallback& callback); |
| 58 | 58 |
| 59 // Type-checking upcast routine. Returns an NULL on failure. | 59 // Type-checking upcast routine. Returns an NULL on failure. |
| 60 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer); | 60 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer); |
| 61 | 61 |
| 62 // Returns the number of bytes per pixel that must be used by an | 62 // Returns the number of bytes per pixel that must be used by an |
| 63 // implementation when using |format|. | 63 // implementation when using |format|. |
| 64 static size_t BytesPerPixel(Format format); | 64 static size_t BytesPerPixel(Format format); |
| 65 | 65 |
| 66 // Overridden from gfx::GpuMemoryBuffer: | 66 // Overridden from gfx::GpuMemoryBuffer: |
| 67 virtual bool IsMapped() const override; | 67 bool IsMapped() const override; |
| 68 virtual Format GetFormat() const override; | 68 Format GetFormat() const override; |
| 69 virtual ClientBuffer AsClientBuffer() override; | 69 ClientBuffer AsClientBuffer() override; |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 GpuMemoryBufferImpl(const gfx::Size& size, | 72 GpuMemoryBufferImpl(const gfx::Size& size, |
| 73 Format format, | 73 Format format, |
| 74 const DestructionCallback& callback); | 74 const DestructionCallback& callback); |
| 75 | 75 |
| 76 const gfx::Size size_; | 76 const gfx::Size size_; |
| 77 const Format format_; | 77 const Format format_; |
| 78 const DestructionCallback callback_; | 78 const DestructionCallback callback_; |
| 79 bool mapped_; | 79 bool mapped_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 81 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace content | 84 } // namespace content |
| 85 | 85 |
| 86 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 86 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| OLD | NEW |