| 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 <vector> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/common/content_export.h" |
| 10 #include "ui/gfx/gpu_memory_buffer.h" | 13 #include "ui/gfx/gpu_memory_buffer.h" |
| 11 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 12 | 15 |
| 13 namespace content { | 16 namespace content { |
| 14 | 17 |
| 15 // Provides common implementation of a GPU memory buffer. | 18 // Provides common implementation of a GPU memory buffer. |
| 16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 19 class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
| 17 public: | 20 public: |
| 18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> | 21 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> |
| 19 CreationCallback; | 22 CreationCallback; |
| 20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 23 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
| 21 AllocationCallback; | 24 AllocationCallback; |
| 22 typedef base::Callback<void(uint32 sync_point)> DestructionCallback; | 25 typedef base::Callback<void(uint32 sync_point)> DestructionCallback; |
| 23 | 26 |
| 24 ~GpuMemoryBufferImpl() override; | 27 ~GpuMemoryBufferImpl() override; |
| 25 | 28 |
| 29 // Gets system supported GPU memory buffer types. Preferred type at the front |
| 30 // of vector. |
| 31 static void GetSupportedTypes(std::vector<gfx::GpuMemoryBufferType>* types); |
| 32 |
| 33 // Sets the preferred GPU memory buffer type. This overrides the default |
| 34 // preferred type. Can only be called once prior to GetPreferredType(). |
| 35 // Caller is responsible for correct ordering. |
| 36 static void SetPreferredType(gfx::GpuMemoryBufferType type); |
| 37 |
| 38 // Gets the preferred discardable memory type. |
| 39 static gfx::GpuMemoryBufferType GetPreferredType(); |
| 40 |
| 41 // Returns true if |format| and |usage| is a supported configuration for |
| 42 // |type|. |type| must be a supported GPU memory buffer type. |
| 43 static bool IsConfigurationSupported(gfx::GpuMemoryBufferType type, |
| 44 Format format, |
| 45 Usage usage); |
| 46 |
| 26 // Creates a GPU memory buffer instance with |size| and |format| for |usage| | 47 // Creates a GPU memory buffer instance with |size| and |format| for |usage| |
| 27 // by the current process and |client_id|. | 48 // by the current process and |client_id|. |
| 28 static void Create(gfx::GpuMemoryBufferId id, | 49 static void Create(gfx::GpuMemoryBufferType type, |
| 50 gfx::GpuMemoryBufferId id, |
| 29 const gfx::Size& size, | 51 const gfx::Size& size, |
| 30 Format format, | 52 Format format, |
| 31 Usage usage, | 53 Usage usage, |
| 32 int client_id, | 54 int client_id, |
| 33 const CreationCallback& callback); | 55 const CreationCallback& callback); |
| 34 | 56 |
| 35 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| | 57 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| |
| 36 // by |child_process| and |child_client_id|. The |handle| returned can be | 58 // by |child_process| and |child_client_id|. The |handle| returned can be |
| 37 // used by the |child_process| to create an instance of this class. | 59 // used by the |child_process| to create an instance of this class. |
| 38 static void AllocateForChildProcess(gfx::GpuMemoryBufferId id, | 60 static void AllocateForChildProcess(gfx::GpuMemoryBufferType type, |
| 61 gfx::GpuMemoryBufferId id, |
| 39 const gfx::Size& size, | 62 const gfx::Size& size, |
| 40 Format format, | 63 Format format, |
| 41 Usage usage, | 64 Usage usage, |
| 42 base::ProcessHandle child_process, | 65 base::ProcessHandle child_process, |
| 43 int child_client_id, | 66 int child_client_id, |
| 44 const AllocationCallback& callback); | 67 const AllocationCallback& callback); |
| 45 | 68 |
| 46 // Notify that GPU memory buffer has been deleted by |child_process|. | 69 // Notify that GPU memory buffer has been deleted by |child_process|. |
| 47 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, | 70 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, |
| 48 gfx::GpuMemoryBufferId id, | 71 gfx::GpuMemoryBufferId id, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 Format format, | 105 Format format, |
| 83 const DestructionCallback& callback); | 106 const DestructionCallback& callback); |
| 84 | 107 |
| 85 const gfx::GpuMemoryBufferId id_; | 108 const gfx::GpuMemoryBufferId id_; |
| 86 const gfx::Size size_; | 109 const gfx::Size size_; |
| 87 const Format format_; | 110 const Format format_; |
| 88 const DestructionCallback callback_; | 111 const DestructionCallback callback_; |
| 89 bool mapped_; | 112 bool mapped_; |
| 90 uint32 destruction_sync_point_; | 113 uint32 destruction_sync_point_; |
| 91 | 114 |
| 115 private: |
| 92 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 116 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
| 93 }; | 117 }; |
| 94 | 118 |
| 95 } // namespace content | 119 } // namespace content |
| 96 | 120 |
| 97 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 121 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| OLD | NEW |