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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: mac build fix Created 6 years, 2 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 "ipc/message_filter.h" 13 #include "ipc/message_filter.h"
14 14
15 namespace content { 15 namespace content {
16 class GpuMemoryBufferImpl;
17 class GpuMemoryBufferFactoryHostImpl; 16 class GpuMemoryBufferFactoryHostImpl;
18 17
19 class CONTENT_EXPORT BrowserGpuChannelHostFactory 18 class CONTENT_EXPORT BrowserGpuChannelHostFactory
20 : public GpuChannelHostFactory { 19 : public GpuChannelHostFactory {
21 public: 20 public:
22 static void Initialize(bool establish_gpu_channel); 21 static void Initialize(bool establish_gpu_channel);
23 static void Terminate(); 22 static void Terminate();
24 static BrowserGpuChannelHostFactory* instance() { return instance_; } 23 static BrowserGpuChannelHostFactory* instance() { return instance_; }
25 24
26 // GpuChannelHostFactory implementation. 25 // GpuChannelHostFactory implementation.
27 virtual bool IsMainThread() override; 26 virtual bool IsMainThread() override;
28 virtual base::MessageLoop* GetMainLoop() override; 27 virtual base::MessageLoop* GetMainLoop() override;
29 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() override; 28 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() override;
30 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( 29 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(
31 size_t size) override; 30 size_t size) override;
32 virtual CreateCommandBufferResult CreateViewCommandBuffer( 31 virtual CreateCommandBufferResult CreateViewCommandBuffer(
33 int32 surface_id, 32 int32 surface_id,
34 const GPUCreateCommandBufferConfig& init_params, 33 const GPUCreateCommandBufferConfig& init_params,
35 int32 route_id) override; 34 int32 route_id) override;
36 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
37 size_t width,
38 size_t height,
39 unsigned internalformat,
40 unsigned usage) override;
41 35
42 // Specify a task runner and callback to be used for a set of messages. The 36 // Specify a task runner and callback to be used for a set of messages. The
43 // callback will be set up on the current GpuProcessHost, identified by 37 // callback will be set up on the current GpuProcessHost, identified by
44 // GpuProcessHostId(). 38 // GpuProcessHostId().
45 virtual void SetHandlerForControlMessages( 39 virtual void SetHandlerForControlMessages(
46 const uint32* message_ids, 40 const uint32* message_ids,
47 size_t num_messages, 41 size_t num_messages,
48 const base::Callback<void(const IPC::Message&)>& handler, 42 const base::Callback<void(const IPC::Message&)>& handler,
49 base::TaskRunner* target_task_runner); 43 base::TaskRunner* target_task_runner);
50 int GpuProcessHostId() { return gpu_host_id_; } 44 int GpuProcessHostId() { return gpu_host_id_; }
51 GpuChannelHost* EstablishGpuChannelSync( 45 GpuChannelHost* EstablishGpuChannelSync(
52 CauseForGpuLaunch cause_for_gpu_launch); 46 CauseForGpuLaunch cause_for_gpu_launch);
53 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, 47 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch,
54 const base::Closure& callback); 48 const base::Closure& callback);
55 GpuChannelHost* GetGpuChannel(); 49 GpuChannelHost* GetGpuChannel();
56 int GetGpuChannelId() { return gpu_client_id_; } 50 int GetGpuChannelId() { return gpu_client_id_; }
57 51
58 // Used to skip GpuChannelHost tests when there can be no GPU process. 52 // Used to skip GpuChannelHost tests when there can be no GPU process.
59 static bool CanUseForTesting(); 53 static bool CanUseForTesting();
60 54
61 private: 55 private:
62 struct CreateRequest; 56 struct CreateRequest;
63 struct AllocateGpuMemoryBufferRequest;
64 class EstablishRequest; 57 class EstablishRequest;
65 58
66 BrowserGpuChannelHostFactory(); 59 BrowserGpuChannelHostFactory();
67 virtual ~BrowserGpuChannelHostFactory(); 60 virtual ~BrowserGpuChannelHostFactory();
68 61
69 void GpuChannelEstablished(); 62 void GpuChannelEstablished();
70 void CreateViewCommandBufferOnIO( 63 void CreateViewCommandBufferOnIO(
71 CreateRequest* request, 64 CreateRequest* request,
72 int32 surface_id, 65 int32 surface_id,
73 const GPUCreateCommandBufferConfig& init_params); 66 const GPUCreateCommandBufferConfig& init_params);
74 static void CommandBufferCreatedOnIO(CreateRequest* request, 67 static void CommandBufferCreatedOnIO(CreateRequest* request,
75 CreateCommandBufferResult result); 68 CreateCommandBufferResult result);
76 static void AddFilterOnIO(int gpu_host_id, 69 static void AddFilterOnIO(int gpu_host_id,
77 scoped_refptr<IPC::MessageFilter> filter); 70 scoped_refptr<IPC::MessageFilter> filter);
78 static void AllocateGpuMemoryBufferOnIO(
79 AllocateGpuMemoryBufferRequest* request);
80 static void OnGpuMemoryBufferCreated(AllocateGpuMemoryBufferRequest* request,
81 scoped_ptr<GpuMemoryBufferImpl> buffer);
82 71
83 const int gpu_client_id_; 72 const int gpu_client_id_;
84 scoped_ptr<base::WaitableEvent> shutdown_event_; 73 scoped_ptr<base::WaitableEvent> shutdown_event_;
85 scoped_refptr<GpuChannelHost> gpu_channel_; 74 scoped_refptr<GpuChannelHost> gpu_channel_;
86 scoped_ptr<GpuMemoryBufferFactoryHostImpl> gpu_memory_buffer_factory_host_; 75 scoped_ptr<GpuMemoryBufferFactoryHostImpl> gpu_memory_buffer_factory_host_;
87 int gpu_host_id_; 76 int gpu_host_id_;
88 scoped_refptr<EstablishRequest> pending_request_; 77 scoped_refptr<EstablishRequest> pending_request_;
89 std::vector<base::Closure> established_callbacks_; 78 std::vector<base::Closure> established_callbacks_;
90 79
91 static BrowserGpuChannelHostFactory* instance_; 80 static BrowserGpuChannelHostFactory* instance_;
92 81
93 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); 82 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
94 }; 83 };
95 84
96 } // namespace content 85 } // namespace content
97 86
98 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 87 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698