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

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.h

Issue 302603004: Plumb GpuMemoryBuffer allocation to GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/gpu/client/gpu_channel_host.h" 12 #include "content/common/gpu/client/gpu_channel_host.h"
13 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h"
13 #include "ipc/message_filter.h" 14 #include "ipc/message_filter.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 class CONTENT_EXPORT BrowserGpuChannelHostFactory 18 class CONTENT_EXPORT BrowserGpuChannelHostFactory
18 : public GpuChannelHostFactory { 19 : public GpuChannelHostFactory,
20 public GpuMemoryBufferFactoryHost {
19 public: 21 public:
20 static void Initialize(bool establish_gpu_channel); 22 static void Initialize(bool establish_gpu_channel);
21 static void Terminate(); 23 static void Terminate();
22 static BrowserGpuChannelHostFactory* instance() { return instance_; } 24 static BrowserGpuChannelHostFactory* instance() { return instance_; }
23 25
24 // GpuChannelHostFactory implementation. 26 // GpuChannelHostFactory implementation.
25 virtual bool IsMainThread() OVERRIDE; 27 virtual bool IsMainThread() OVERRIDE;
26 virtual base::MessageLoop* GetMainLoop() OVERRIDE; 28 virtual base::MessageLoop* GetMainLoop() OVERRIDE;
27 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() OVERRIDE; 29 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() OVERRIDE;
28 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( 30 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(
29 size_t size) OVERRIDE; 31 size_t size) OVERRIDE;
30 virtual bool CreateViewCommandBuffer( 32 virtual bool CreateViewCommandBuffer(
31 int32 surface_id, 33 int32 surface_id,
32 const GPUCreateCommandBufferConfig& init_params, 34 const GPUCreateCommandBufferConfig& init_params,
33 int32 route_id) OVERRIDE; 35 int32 route_id) OVERRIDE;
34 virtual void CreateImage( 36 virtual void CreateImage(
35 gfx::PluginWindowHandle window, 37 gfx::PluginWindowHandle window,
36 int32 image_id, 38 int32 image_id,
37 const CreateImageCallback& callback) OVERRIDE; 39 const CreateImageCallback& callback) OVERRIDE;
38 virtual void DeleteImage(int32 image_idu, int32 sync_point) OVERRIDE; 40 virtual void DeleteImage(int32 image_idu, int32 sync_point) OVERRIDE;
39 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( 41 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
40 size_t width, 42 size_t width,
41 size_t height, 43 size_t height,
42 unsigned internalformat, 44 unsigned internalformat,
43 unsigned usage) OVERRIDE; 45 unsigned usage) OVERRIDE;
44 46
47 // GpuMemoryBufferFactoryHost implementation.
48 virtual void CreateGpuMemoryBuffer(
49 const gfx::GpuMemoryBufferHandle& handle,
50 const gfx::Size& size,
51 unsigned internalformat,
52 unsigned usage,
53 const CreateGpuMemoryBufferCallback& callback) OVERRIDE;
54 virtual void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle,
55 int32 sync_point) OVERRIDE;
56
45 // Specify a task runner and callback to be used for a set of messages. The 57 // Specify a task runner and callback to be used for a set of messages. The
46 // callback will be set up on the current GpuProcessHost, identified by 58 // callback will be set up on the current GpuProcessHost, identified by
47 // GpuProcessHostId(). 59 // GpuProcessHostId().
48 virtual void SetHandlerForControlMessages( 60 virtual void SetHandlerForControlMessages(
49 const uint32* message_ids, 61 const uint32* message_ids,
50 size_t num_messages, 62 size_t num_messages,
51 const base::Callback<void(const IPC::Message&)>& handler, 63 const base::Callback<void(const IPC::Message&)>& handler,
52 base::TaskRunner* target_task_runner); 64 base::TaskRunner* target_task_runner);
53 int GpuProcessHostId() { return gpu_host_id_; } 65 int GpuProcessHostId() { return gpu_host_id_; }
54 GpuChannelHost* EstablishGpuChannelSync( 66 GpuChannelHost* EstablishGpuChannelSync(
(...skipping 24 matching lines...) Expand all
79 int32 image_id, 91 int32 image_id,
80 const CreateImageCallback& callback); 92 const CreateImageCallback& callback);
81 static void ImageCreatedOnIO( 93 static void ImageCreatedOnIO(
82 const CreateImageCallback& callback, const gfx::Size size); 94 const CreateImageCallback& callback, const gfx::Size size);
83 static void OnImageCreated( 95 static void OnImageCreated(
84 const CreateImageCallback& callback, const gfx::Size size); 96 const CreateImageCallback& callback, const gfx::Size size);
85 void DeleteImageOnIO(int32 image_id, int32 sync_point); 97 void DeleteImageOnIO(int32 image_id, int32 sync_point);
86 static void AddFilterOnIO(int gpu_host_id, 98 static void AddFilterOnIO(int gpu_host_id,
87 scoped_refptr<IPC::MessageFilter> filter); 99 scoped_refptr<IPC::MessageFilter> filter);
88 100
101 void CreateGpuMemoryBufferOnIO(const gfx::GpuMemoryBufferHandle& handle,
102 const gfx::Size& size,
103 unsigned internalformat,
104 unsigned usage,
105 int32 request_id);
106 void GpuMemoryBufferCreatedOnIO(
107 int32 request_id,
108 const gfx::GpuMemoryBufferHandle& handle);
109 void OnGpuMemoryBufferCreated(
110 int32 request_id,
111 const gfx::GpuMemoryBufferHandle& handle);
112 void DestroyGpuMemoryBufferOnIO(const gfx::GpuMemoryBufferHandle& handle,
113 int32 sync_point);
114
89 const int gpu_client_id_; 115 const int gpu_client_id_;
90 scoped_ptr<base::WaitableEvent> shutdown_event_; 116 scoped_ptr<base::WaitableEvent> shutdown_event_;
91 scoped_refptr<GpuChannelHost> gpu_channel_; 117 scoped_refptr<GpuChannelHost> gpu_channel_;
92 int gpu_host_id_; 118 int gpu_host_id_;
93 scoped_refptr<EstablishRequest> pending_request_; 119 scoped_refptr<EstablishRequest> pending_request_;
94 std::vector<base::Closure> established_callbacks_; 120 std::vector<base::Closure> established_callbacks_;
95 121
122 uint32 next_create_gpu_memory_buffer_request_id_;
123 typedef std::map<int32, CreateGpuMemoryBufferCallback>
reveman 2014/06/11 14:52:09 uint32 here too
alexst (slow to review) 2014/06/11 15:36:47 Done.
124 CreateGpuMemoryBufferCallbackMap;
125 CreateGpuMemoryBufferCallbackMap create_gpu_memory_buffer_requests_;
126
96 static BrowserGpuChannelHostFactory* instance_; 127 static BrowserGpuChannelHostFactory* instance_;
97 128
98 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); 129 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
99 }; 130 };
100 131
101 } // namespace content 132 } // namespace content
102 133
103 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 134 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698