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

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: rebase 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; 16 class BrowserGpuMemoryBufferManager;
17 class GpuMemoryBufferFactoryHostImpl; 17 class GpuMemoryBufferFactoryHostImpl;
18 18
19 class CONTENT_EXPORT BrowserGpuChannelHostFactory 19 class CONTENT_EXPORT BrowserGpuChannelHostFactory
20 : public GpuChannelHostFactory { 20 : public GpuChannelHostFactory {
21 public: 21 public:
22 static void Initialize(bool establish_gpu_channel); 22 static void Initialize(bool establish_gpu_channel);
23 static void Terminate(); 23 static void Terminate();
24 static BrowserGpuChannelHostFactory* instance() { return instance_; } 24 static BrowserGpuChannelHostFactory* instance() { return instance_; }
25 25
26 // GpuChannelHostFactory implementation. 26 // GpuChannelHostFactory implementation.
27 virtual bool IsMainThread() override; 27 virtual bool IsMainThread() override;
28 virtual base::MessageLoop* GetMainLoop() override; 28 virtual base::MessageLoop* GetMainLoop() override;
29 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() override; 29 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() override;
30 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( 30 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(
31 size_t size) override; 31 size_t size) override;
32 virtual CreateCommandBufferResult CreateViewCommandBuffer( 32 virtual CreateCommandBufferResult CreateViewCommandBuffer(
33 int32 surface_id, 33 int32 surface_id,
34 const GPUCreateCommandBufferConfig& init_params, 34 const GPUCreateCommandBufferConfig& init_params,
35 int32 route_id) override; 35 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 36
42 // Specify a task runner and callback to be used for a set of messages. The 37 // 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 38 // callback will be set up on the current GpuProcessHost, identified by
44 // GpuProcessHostId(). 39 // GpuProcessHostId().
45 virtual void SetHandlerForControlMessages( 40 virtual void SetHandlerForControlMessages(
46 const uint32* message_ids, 41 const uint32* message_ids,
47 size_t num_messages, 42 size_t num_messages,
48 const base::Callback<void(const IPC::Message&)>& handler, 43 const base::Callback<void(const IPC::Message&)>& handler,
49 base::TaskRunner* target_task_runner); 44 base::TaskRunner* target_task_runner);
50 int GpuProcessHostId() { return gpu_host_id_; } 45 int GpuProcessHostId() { return gpu_host_id_; }
51 GpuChannelHost* EstablishGpuChannelSync( 46 GpuChannelHost* EstablishGpuChannelSync(
52 CauseForGpuLaunch cause_for_gpu_launch); 47 CauseForGpuLaunch cause_for_gpu_launch);
53 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, 48 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch,
54 const base::Closure& callback); 49 const base::Closure& callback);
55 GpuChannelHost* GetGpuChannel(); 50 GpuChannelHost* GetGpuChannel();
56 int GetGpuChannelId() { return gpu_client_id_; } 51 int GetGpuChannelId() { return gpu_client_id_; }
57 52
58 // Used to skip GpuChannelHost tests when there can be no GPU process. 53 // Used to skip GpuChannelHost tests when there can be no GPU process.
59 static bool CanUseForTesting(); 54 static bool CanUseForTesting();
60 55
61 private: 56 private:
62 struct CreateRequest; 57 struct CreateRequest;
63 struct AllocateGpuMemoryBufferRequest;
64 class EstablishRequest; 58 class EstablishRequest;
65 59
66 BrowserGpuChannelHostFactory(); 60 BrowserGpuChannelHostFactory();
67 virtual ~BrowserGpuChannelHostFactory(); 61 virtual ~BrowserGpuChannelHostFactory();
68 62
69 void GpuChannelEstablished(); 63 void GpuChannelEstablished();
70 void CreateViewCommandBufferOnIO( 64 void CreateViewCommandBufferOnIO(
71 CreateRequest* request, 65 CreateRequest* request,
72 int32 surface_id, 66 int32 surface_id,
73 const GPUCreateCommandBufferConfig& init_params); 67 const GPUCreateCommandBufferConfig& init_params);
74 static void CommandBufferCreatedOnIO(CreateRequest* request, 68 static void CommandBufferCreatedOnIO(CreateRequest* request,
75 CreateCommandBufferResult result); 69 CreateCommandBufferResult result);
76 static void AddFilterOnIO(int gpu_host_id, 70 static void AddFilterOnIO(int gpu_host_id,
77 scoped_refptr<IPC::MessageFilter> filter); 71 scoped_refptr<IPC::MessageFilter> filter);
78 static void AllocateGpuMemoryBufferOnIO(
79 AllocateGpuMemoryBufferRequest* request);
80 static void OnGpuMemoryBufferCreated(AllocateGpuMemoryBufferRequest* request,
81 scoped_ptr<GpuMemoryBufferImpl> buffer);
82 72
83 const int gpu_client_id_; 73 const int gpu_client_id_;
84 scoped_ptr<base::WaitableEvent> shutdown_event_; 74 scoped_ptr<base::WaitableEvent> shutdown_event_;
85 scoped_refptr<GpuChannelHost> gpu_channel_; 75 scoped_refptr<GpuChannelHost> gpu_channel_;
86 scoped_ptr<GpuMemoryBufferFactoryHostImpl> gpu_memory_buffer_factory_host_; 76 scoped_ptr<GpuMemoryBufferFactoryHostImpl> gpu_memory_buffer_factory_host_;
77 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_;
87 int gpu_host_id_; 78 int gpu_host_id_;
88 scoped_refptr<EstablishRequest> pending_request_; 79 scoped_refptr<EstablishRequest> pending_request_;
89 std::vector<base::Closure> established_callbacks_; 80 std::vector<base::Closure> established_callbacks_;
90 81
91 static BrowserGpuChannelHostFactory* instance_; 82 static BrowserGpuChannelHostFactory* instance_;
92 83
93 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); 84 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
94 }; 85 };
95 86
96 } // namespace content 87 } // namespace content
97 88
98 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 89 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
OLDNEW
« no previous file with comments | « content/browser/compositor/onscreen_display_client.cc ('k') | content/browser/gpu/browser_gpu_channel_host_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698