Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: components/viz/common/server_gpu_memory_buffer_manager.h

Issue 2941933002: viz: Convert a sync api in ServerGpuMemoryBufferManager into async. (Closed)
Patch Set: fix test build on windows Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/viz/common/DEPS ('k') | components/viz/common/server_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/viz/common/server_gpu_memory_buffer_manager.h
diff --git a/components/viz/common/server_gpu_memory_buffer_manager.h b/components/viz/common/server_gpu_memory_buffer_manager.h
index c34eda825d3ec8e20583999d874e6aa90c1ad15e..f546bc76f9cbf1b5a400a656675188b829320c82 100644
--- a/components/viz/common/server_gpu_memory_buffer_manager.h
+++ b/components/viz/common/server_gpu_memory_buffer_manager.h
@@ -9,7 +9,8 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/threading/thread_checker.h"
+#include "base/sequenced_task_runner.h"
+#include "base/synchronization/waitable_event.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/ipc/host/gpu_memory_buffer_support.h"
@@ -23,8 +24,9 @@ namespace viz {
// This GpuMemoryBufferManager implementation is for [de]allocating gpu memory
// from the gpu process over the mojom.GpuService api.
-class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager,
- public base::ThreadChecker {
+// Note that |CreateGpuMemoryBuffer()| can be called on any thread. All the rest
+// of the functions must be called on the thread this object is created on.
+class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager {
public:
ServerGpuMemoryBufferManager(ui::mojom::GpuService* gpu_service,
int client_id);
@@ -36,13 +38,14 @@ class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager,
void DestroyAllGpuMemoryBufferForClient(int client_id);
- gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferHandle(
+ void AllocateGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
int client_id,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
- gpu::SurfaceHandle surface_handle);
+ gpu::SurfaceHandle surface_handle,
+ base::OnceCallback<void(const gfx::GpuMemoryBufferHandle&)> callback);
// Overridden from gpu::GpuMemoryBufferManager:
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer(
@@ -54,6 +57,11 @@ class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager,
const gpu::SyncToken& sync_token) override;
private:
+ void OnGpuMemoryBufferAllocated(
+ int client_id,
+ base::OnceCallback<void(const gfx::GpuMemoryBufferHandle&)> callback,
+ const gfx::GpuMemoryBufferHandle& handle);
+
ui::mojom::GpuService* gpu_service_;
const int client_id_;
int next_gpu_memory_id_ = 1;
@@ -62,8 +70,10 @@ class ServerGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager,
std::unordered_set<gfx::GpuMemoryBufferId,
BASE_HASH_NAMESPACE::hash<gfx::GpuMemoryBufferId>>;
std::unordered_map<int, NativeBuffers> native_buffers_;
+ std::unordered_set<int> pending_buffers_;
const gpu::GpuMemoryBufferConfigurationSet native_configurations_;
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
base::WeakPtrFactory<ServerGpuMemoryBufferManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ServerGpuMemoryBufferManager);
« no previous file with comments | « components/viz/common/DEPS ('k') | components/viz/common/server_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698