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

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.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: fix tests 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 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 <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "content/common/gpu/client/gpu_channel_host.h" 13 #include "content/common/gpu/client/gpu_channel_host.h"
14 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h"
15 #include "ipc/message_filter.h" 14 #include "ipc/message_filter.h"
16 15
17 namespace content { 16 namespace content {
18 class BrowserGpuMemoryBufferManager; 17 class BrowserGpuMemoryBufferManager;
19 18
20 class CONTENT_EXPORT BrowserGpuChannelHostFactory 19 class CONTENT_EXPORT BrowserGpuChannelHostFactory
21 : public GpuChannelHostFactory, 20 : public GpuChannelHostFactory {
22 public GpuMemoryBufferFactoryHost {
23 public: 21 public:
24 static void Initialize(bool establish_gpu_channel); 22 static void Initialize(bool establish_gpu_channel);
25 static void Terminate(); 23 static void Terminate();
26 static BrowserGpuChannelHostFactory* instance() { return instance_; } 24 static BrowserGpuChannelHostFactory* instance() { return instance_; }
27 25
28 static void EnableGpuMemoryBufferFactoryUsage(
29 gfx::GpuMemoryBuffer::Usage usage);
30 static bool IsGpuMemoryBufferFactoryUsageEnabled(
31 gfx::GpuMemoryBuffer::Usage usage);
32 static uint32 GetImageTextureTarget(gfx::GpuMemoryBuffer::Format format,
33 gfx::GpuMemoryBuffer::Usage usage);
34
35 // Overridden from GpuChannelHostFactory: 26 // Overridden from GpuChannelHostFactory:
36 bool IsMainThread() override; 27 bool IsMainThread() override;
37 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; 28 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
38 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; 29 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override;
39 CreateCommandBufferResult CreateViewCommandBuffer( 30 CreateCommandBufferResult CreateViewCommandBuffer(
40 int32 surface_id, 31 int32 surface_id,
41 const GPUCreateCommandBufferConfig& init_params, 32 const GPUCreateCommandBufferConfig& init_params,
42 int32 route_id) override; 33 int32 route_id) override;
43 34
44 // Overridden from GpuMemoryBufferFactoryHost:
45 bool IsGpuMemoryBufferConfigurationSupported(
46 gfx::GpuMemoryBuffer::Format format,
47 gfx::GpuMemoryBuffer::Usage usage) override;
48 void CreateGpuMemoryBuffer(
49 gfx::GpuMemoryBufferId id,
50 const gfx::Size& size,
51 gfx::GpuMemoryBuffer::Format format,
52 gfx::GpuMemoryBuffer::Usage usage,
53 int client_id,
54 int32 surface_id,
55 const CreateGpuMemoryBufferCallback& callback) override;
56 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
57 int client_id,
58 int32 sync_point) override;
59
60 int GpuProcessHostId() { return gpu_host_id_; } 35 int GpuProcessHostId() { return gpu_host_id_; }
61 #if !defined(OS_ANDROID) 36 #if !defined(OS_ANDROID)
62 GpuChannelHost* EstablishGpuChannelSync( 37 GpuChannelHost* EstablishGpuChannelSync(
63 CauseForGpuLaunch cause_for_gpu_launch); 38 CauseForGpuLaunch cause_for_gpu_launch);
64 #endif 39 #endif
65 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, 40 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch,
66 const base::Closure& callback); 41 const base::Closure& callback);
67 GpuChannelHost* GetGpuChannel(); 42 GpuChannelHost* GetGpuChannel();
68 int GetGpuChannelId() { return gpu_client_id_; } 43 int GetGpuChannelId() { return gpu_client_id_; }
69 44
70 // Used to skip GpuChannelHost tests when there can be no GPU process. 45 // Used to skip GpuChannelHost tests when there can be no GPU process.
71 static bool CanUseForTesting(); 46 static bool CanUseForTesting();
72 47
73 private: 48 private:
74 struct CreateRequest; 49 struct CreateRequest;
75 class EstablishRequest; 50 class EstablishRequest;
76 51
77 BrowserGpuChannelHostFactory(); 52 BrowserGpuChannelHostFactory();
78 ~BrowserGpuChannelHostFactory() override; 53 ~BrowserGpuChannelHostFactory() override;
79 54
80 void GpuChannelEstablished(); 55 void GpuChannelEstablished();
81 void CreateViewCommandBufferOnIO( 56 void CreateViewCommandBufferOnIO(
82 CreateRequest* request, 57 CreateRequest* request,
83 int32 surface_id, 58 int32 surface_id,
84 const GPUCreateCommandBufferConfig& init_params); 59 const GPUCreateCommandBufferConfig& init_params);
85 static void CommandBufferCreatedOnIO(CreateRequest* request, 60 static void CommandBufferCreatedOnIO(CreateRequest* request,
86 CreateCommandBufferResult result); 61 CreateCommandBufferResult result);
87 static void AddFilterOnIO(int gpu_host_id, 62 static void AddFilterOnIO(int gpu_host_id,
88 scoped_refptr<IPC::MessageFilter> filter); 63 scoped_refptr<IPC::MessageFilter> filter);
89 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
90 int client_id,
91 int32 sync_point);
92 void OnGpuMemoryBufferCreated(uint32 request_id,
93 const gfx::GpuMemoryBufferHandle& handle);
94 64
95 const int gpu_client_id_; 65 const int gpu_client_id_;
96 scoped_ptr<base::WaitableEvent> shutdown_event_; 66 scoped_ptr<base::WaitableEvent> shutdown_event_;
97 scoped_refptr<GpuChannelHost> gpu_channel_; 67 scoped_refptr<GpuChannelHost> gpu_channel_;
98 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_;
99 int gpu_host_id_; 68 int gpu_host_id_;
100 scoped_refptr<EstablishRequest> pending_request_; 69 scoped_refptr<EstablishRequest> pending_request_;
101 std::vector<base::Closure> established_callbacks_; 70 std::vector<base::Closure> established_callbacks_;
102 uint32 next_create_gpu_memory_buffer_request_id_;
103 typedef std::map<uint32, CreateGpuMemoryBufferCallback>
104 CreateGpuMemoryBufferCallbackMap;
105 CreateGpuMemoryBufferCallbackMap create_gpu_memory_buffer_requests_;
106 71
107 static BrowserGpuChannelHostFactory* instance_; 72 static BrowserGpuChannelHostFactory* instance_;
108 73
109 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); 74 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
110 }; 75 };
111 76
112 } // namespace content 77 } // namespace content
113 78
114 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 79 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698