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

Unified Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.h

Issue 1189943002: content: Fix lost context handling when using native GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: retry logic and remove singleton Created 5 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
Index: content/browser/gpu/browser_gpu_memory_buffer_manager.h
diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.h b/content/browser/gpu/browser_gpu_memory_buffer_manager.h
index d549029a50953c1e573d00fe6687d5f8c54687b9..7941878632ff4f72ba3fe01169708d1af23f67e3 100644
--- a/content/browser/gpu/browser_gpu_memory_buffer_manager.h
+++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.h
@@ -5,15 +5,16 @@
#ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
#define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
+#include <vector>
+
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/trace_event/memory_dump_provider.h"
#include "content/common/content_export.h"
+#include "content/common/gpu/gpu_memory_buffer_factory.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
namespace content {
-class GpuMemoryBufferFactoryHost;
-class GpuMemoryBufferImpl;
class CONTENT_EXPORT BrowserGpuMemoryBufferManager
: public gpu::GpuMemoryBufferManager,
@@ -22,13 +23,14 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager
typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>
AllocationCallback;
- BrowserGpuMemoryBufferManager(
- GpuMemoryBufferFactoryHost* gpu_memory_buffer_factory_host,
- int gpu_client_id);
+ explicit BrowserGpuMemoryBufferManager(int gpu_client_id);
~BrowserGpuMemoryBufferManager() override;
static BrowserGpuMemoryBufferManager* current();
+ static uint32 GetImageTextureTarget(gfx::GpuMemoryBuffer::Format format,
+ gfx::GpuMemoryBuffer::Usage usage);
+
// Overridden from gpu::GpuMemoryBufferManager:
scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
const gfx::Size& size,
@@ -65,42 +67,76 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager
private:
struct BufferInfo {
BufferInfo()
- : format(gfx::GpuMemoryBuffer::RGBA_8888), type(gfx::EMPTY_BUFFER) {}
+ : type(gfx::EMPTY_BUFFER),
+ format(gfx::GpuMemoryBuffer::RGBA_8888),
+ usage(gfx::GpuMemoryBuffer::MAP),
+ gpu_host_id(0) {}
BufferInfo(const gfx::Size& size,
+ gfx::GpuMemoryBufferType type,
gfx::GpuMemoryBuffer::Format format,
- gfx::GpuMemoryBufferType type)
- : size(size), format(format), type(type) {}
+ gfx::GpuMemoryBuffer::Usage usage,
+ int gpu_host_id)
+ : size(size),
+ type(type),
+ format(format),
+ usage(usage),
+ gpu_host_id(gpu_host_id) {}
gfx::Size size;
- gfx::GpuMemoryBuffer::Format format;
gfx::GpuMemoryBufferType type;
+ gfx::GpuMemoryBuffer::Format format;
+ gfx::GpuMemoryBuffer::Usage usage;
+ int gpu_host_id;
};
struct AllocateGpuMemoryBufferRequest;
- scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferCommon(
+ scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface(
const gfx::Size& size,
gfx::GpuMemoryBuffer::Format format,
gfx::GpuMemoryBuffer::Usage usage,
int32 surface_id);
- void AllocateGpuMemoryBufferOnIO(AllocateGpuMemoryBufferRequest* request);
- void GpuMemoryBufferAllocatedOnIO(AllocateGpuMemoryBufferRequest* request,
- const gfx::GpuMemoryBufferHandle& handle);
- void GpuMemoryBufferDeleted(gfx::GpuMemoryBufferId id,
- int client_id,
- uint32 sync_point);
- void GpuMemoryBufferAllocatedForChildProcess(
- gfx::GpuMemoryBufferId id,
- int child_client_id,
- const AllocationCallback& callback,
+ bool IsGpuMemoryBufferConfigurationSupported(
+ gfx::GpuMemoryBuffer::Format format,
+ gfx::GpuMemoryBuffer::Usage usage) const;
+ void AllocateGpuMemoryBufferForSurfaceOnIO(
+ AllocateGpuMemoryBufferRequest* request);
+ void GpuMemoryBufferAllocatedForSurfaceOnIO(
+ AllocateGpuMemoryBufferRequest* request,
const gfx::GpuMemoryBufferHandle& handle);
-
- GpuMemoryBufferFactoryHost* gpu_memory_buffer_factory_host_;
- int gpu_client_id_;
-
- typedef base::hash_map<gfx::GpuMemoryBufferId, BufferInfo> BufferMap;
- typedef base::hash_map<int, BufferMap> ClientMap;
+ void AllocateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
+ const gfx::Size& size,
+ gfx::GpuMemoryBuffer::Format format,
+ gfx::GpuMemoryBuffer::Usage usage,
+ int client_id,
+ int surface_id,
+ bool reused_gpu_process,
+ const AllocationCallback& callback);
+ void GpuMemoryBufferAllocatedOnIO(gfx::GpuMemoryBufferId id,
+ int client_id,
+ int surface_id,
+ int gpu_host_id,
+ bool reused_gpu_process,
+ const AllocationCallback& callback,
+ const gfx::GpuMemoryBufferHandle& handle);
+ void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
+ int client_id,
+ uint32 sync_point);
+
+ const gfx::GpuMemoryBufferType factory_type_;
+ const std::vector<GpuMemoryBufferFactory::Configuration>
+ supported_configurations_;
+ const int gpu_client_id_;
+
+ // The GPU process host ID. This should only be accessed on the IO thread.
+ int gpu_host_id_;
+
+ // Stores info about buffers for all clients. This should only be accessed
+ // on the IO thread.
+ using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>;
+ using ClientMap = base::hash_map<int, BufferMap>;
ClientMap clients_;
+ // This should only be accessed on the IO thread.
base::WeakPtrFactory<BrowserGpuMemoryBufferManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager);
« no previous file with comments | « content/browser/gpu/browser_gpu_channel_host_factory.cc ('k') | content/browser/gpu/browser_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698