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

Unified Diff: content/browser/gpu/gpu_process_host.cc

Issue 2676543003: gpu: Some code cleanup after r445649. (Closed)
Patch Set: tot merge Created 3 years, 10 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
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/gpu_process_host.cc
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index c61d97fd070cc1eee1fc72e9e72d40aa461332e4..a9f8824a2242d45513193e3328d5b43d0c41b41d 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -685,41 +685,6 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
return true;
}
-#if defined(OS_WIN)
-void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow(
- gpu::SurfaceHandle parent_handle,
- gpu::SurfaceHandle window_handle) {
- constexpr char kBadMessageError[] = "Bad parenting request from gpu process.";
- if (!in_process_) {
- DCHECK(process_);
- {
- DWORD process_id = 0;
- DWORD thread_id = GetWindowThreadProcessId(parent_handle, &process_id);
-
- if (!thread_id || process_id != ::GetCurrentProcessId()) {
- process_->TerminateOnBadMessageReceived(kBadMessageError);
- return;
- }
- }
-
- {
- DWORD process_id = 0;
- DWORD thread_id = GetWindowThreadProcessId(window_handle, &process_id);
-
- if (!thread_id || process_id != process_->GetProcess().Pid()) {
- process_->TerminateOnBadMessageReceived(kBadMessageError);
- return;
- }
- }
- }
-
- if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(
- parent_handle, window_handle)) {
- process_->TerminateOnBadMessageReceived(kBadMessageError);
- }
-}
-#endif
-
void GpuProcessHost::OnChannelConnected(int32_t peer_pid) {
TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected");
@@ -879,57 +844,6 @@ void GpuProcessHost::OnDestroyingVideoSurfaceAck(int surface_id) {
}
#endif
-void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) {
- urls_with_live_offscreen_contexts_.insert(url);
-}
-
-void GpuProcessHost::OnDidLoseContext(bool offscreen,
- gpu::error::ContextLostReason reason,
- const GURL& url) {
- // TODO(kbr): would be nice to see the "offscreen" flag too.
- TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext",
- "reason", reason,
- "url",
- url.possibly_invalid_spec());
-
- if (!offscreen || url.is_empty()) {
- // Assume that the loss of the compositor's or accelerated canvas'
- // context is a serious event and blame the loss on all live
- // offscreen contexts. This more robustly handles situations where
- // the GPU process may not actually detect the context loss in the
- // offscreen context.
- BlockLiveOffscreenContexts();
- return;
- }
-
- GpuDataManagerImpl::DomainGuilt guilt =
- GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
- switch (reason) {
- case gpu::error::kGuilty:
- guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
- break;
- // Treat most other error codes as though they had unknown provenance.
- // In practice this doesn't affect the user experience. A lost context
- // of either known or unknown guilt still causes user-level 3D APIs
- // (e.g. WebGL) to be blocked on that domain until the user manually
- // reenables them.
- case gpu::error::kUnknown:
- case gpu::error::kOutOfMemory:
- case gpu::error::kMakeCurrentFailed:
- case gpu::error::kGpuChannelLost:
- case gpu::error::kInvalidGpuMessage:
- break;
- case gpu::error::kInnocent:
- return;
- }
-
- GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(url, guilt);
-}
-
-void GpuProcessHost::OnDidDestroyOffscreenContext(const GURL& url) {
- urls_with_live_offscreen_contexts_.erase(url);
-}
-
void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) {
// Activate the trial in the browser process to match its state in the
// GPU process. This is done by calling FindFullName which finalizes the group
@@ -959,34 +873,103 @@ void GpuProcessHost::DidInitialize(const gpu::GPUInfo& gpu_info) {
}
void GpuProcessHost::DidCreateOffscreenContext(const GURL& url) {
- OnDidCreateOffscreenContext(url);
+ urls_with_live_offscreen_contexts_.insert(url);
}
void GpuProcessHost::DidDestroyOffscreenContext(const GURL& url) {
- OnDidDestroyOffscreenContext(url);
+ urls_with_live_offscreen_contexts_.erase(url);
}
void GpuProcessHost::DidDestroyChannel(int32_t client_id) {
- OnDestroyChannel(client_id);
+ TRACE_EVENT0("gpu", "GpuProcessHost::DidDestroyChannel");
+ client_id_to_shader_cache_.erase(client_id);
}
void GpuProcessHost::DidLoseContext(bool offscreen,
gpu::error::ContextLostReason reason,
const GURL& active_url) {
- OnDidLoseContext(offscreen, reason, active_url);
+ // TODO(kbr): would be nice to see the "offscreen" flag too.
+ TRACE_EVENT2("gpu", "GpuProcessHost::DidLoseContext", "reason", reason, "url",
+ active_url.possibly_invalid_spec());
+
+ if (!offscreen || active_url.is_empty()) {
+ // Assume that the loss of the compositor's or accelerated canvas'
+ // context is a serious event and blame the loss on all live
+ // offscreen contexts. This more robustly handles situations where
+ // the GPU process may not actually detect the context loss in the
+ // offscreen context.
+ BlockLiveOffscreenContexts();
+ return;
+ }
+
+ GpuDataManagerImpl::DomainGuilt guilt =
+ GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
+ switch (reason) {
+ case gpu::error::kGuilty:
+ guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
+ break;
+ // Treat most other error codes as though they had unknown provenance.
+ // In practice this doesn't affect the user experience. A lost context
+ // of either known or unknown guilt still causes user-level 3D APIs
+ // (e.g. WebGL) to be blocked on that domain until the user manually
+ // reenables them.
+ case gpu::error::kUnknown:
+ case gpu::error::kOutOfMemory:
+ case gpu::error::kMakeCurrentFailed:
+ case gpu::error::kGpuChannelLost:
+ case gpu::error::kInvalidGpuMessage:
+ break;
+ case gpu::error::kInnocent:
+ return;
+ }
+
+ GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(active_url, guilt);
}
-void GpuProcessHost::SetChildSurface(gpu::SurfaceHandle parent,
- gpu::SurfaceHandle child) {
+void GpuProcessHost::SetChildSurface(gpu::SurfaceHandle parent_handle,
+ gpu::SurfaceHandle window_handle) {
#if defined(OS_WIN)
- OnAcceleratedSurfaceCreatedChildWindow(parent, child);
+ constexpr char kBadMessageError[] = "Bad parenting request from gpu process.";
+ if (!in_process_) {
+ DCHECK(process_);
+ {
+ DWORD process_id = 0;
+ DWORD thread_id = GetWindowThreadProcessId(parent_handle, &process_id);
+
+ if (!thread_id || process_id != ::GetCurrentProcessId()) {
+ process_->TerminateOnBadMessageReceived(kBadMessageError);
+ return;
+ }
+ }
+
+ {
+ DWORD process_id = 0;
+ DWORD thread_id = GetWindowThreadProcessId(window_handle, &process_id);
+
+ if (!thread_id || process_id != process_->GetProcess().Pid()) {
+ process_->TerminateOnBadMessageReceived(kBadMessageError);
+ return;
+ }
+ }
+ }
+
+ if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(
+ parent_handle, window_handle)) {
+ process_->TerminateOnBadMessageReceived(kBadMessageError);
+ }
#endif
}
void GpuProcessHost::StoreShaderToDisk(int32_t client_id,
const std::string& key,
const std::string& shader) {
- OnCacheShader(client_id, key, shader);
+ TRACE_EVENT0("gpu", "GpuProcessHost::StoreShaderToDisk");
+ ClientIdToShaderCacheMap::iterator iter =
+ client_id_to_shader_cache_.find(client_id);
+ // If the cache doesn't exist then this is an off the record profile.
+ if (iter == client_id_to_shader_cache_.end())
+ return;
+ iter->second->Cache(GetShaderPrefixKey(shader) + ":" + key, shader);
}
GpuProcessHost::GpuProcessKind GpuProcessHost::kind() {
@@ -1225,21 +1208,4 @@ void GpuProcessHost::CreateChannelCache(int32_t client_id) {
client_id_to_shader_cache_[client_id] = cache;
}
-void GpuProcessHost::OnDestroyChannel(int32_t client_id) {
- TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyChannel");
- client_id_to_shader_cache_.erase(client_id);
-}
-
-void GpuProcessHost::OnCacheShader(int32_t client_id,
- const std::string& key,
- const std::string& shader) {
- TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
- ClientIdToShaderCacheMap::iterator iter =
- client_id_to_shader_cache_.find(client_id);
- // If the cache doesn't exist then this is an off the record profile.
- if (iter == client_id_to_shader_cache_.end())
- return;
- iter->second->Cache(GetShaderPrefixKey(shader) + ":" + key, shader);
-}
-
} // namespace content
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698