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

Side by Side Diff: content/browser/media/android/browser_surface_view_manager.cc

Issue 2643893002: Skip video overlay surface management when in VR. (Closed)
Patch Set: Also send back no surface id when there is no web contents delegate. Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "content/browser/media/android/browser_surface_view_manager.h" 5 #include "content/browser/media/android/browser_surface_view_manager.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "content/browser/android/content_view_core_impl.h" 9 #include "content/browser/android/content_view_core_impl.h"
10 #include "content/browser/gpu/gpu_process_host.h" 10 #include "content/browser/gpu/gpu_process_host.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 } 57 }
58 58
59 void BrowserSurfaceViewManager::DidExitFullscreen(bool release_media_player) { 59 void BrowserSurfaceViewManager::DidExitFullscreen(bool release_media_player) {
60 DVLOG(3) << __func__; 60 DVLOG(3) << __func__;
61 content_video_view_.reset(); 61 content_video_view_.reset();
62 } 62 }
63 63
64 void BrowserSurfaceViewManager::OnCreateFullscreenSurface( 64 void BrowserSurfaceViewManager::OnCreateFullscreenSurface(
65 const gfx::Size& video_natural_size) { 65 const gfx::Size& video_natural_size) {
66 // If we are in virtual reality, no surface view is needed so just return.
67 // TODO(http://crbug.com/673886): Support overlay surfaces in VR using GVR
68 // reprojection video surface.
69 if (render_frame_host_->GetView()->IsInVR()) {
70 SendSurfaceID(media::SurfaceManager::kNoSurfaceID);
71 return;
72 }
73
66 // It's valid to get this call if we already own the fullscreen view. We just 74 // It's valid to get this call if we already own the fullscreen view. We just
67 // return the existing surface id. 75 // return the existing surface id.
68 if (content_video_view_) { 76 if (content_video_view_) {
69 // Send the surface now if we have it. Otherwise it will be returned by 77 // Send the surface now if we have it. Otherwise it will be returned by
70 // |SetVideoSurface|. 78 // |SetVideoSurface|.
71 if (surface_id_ != media::SurfaceManager::kNoSurfaceID) { 79 if (surface_id_ != media::SurfaceManager::kNoSurfaceID) {
72 SendSurfaceID(surface_id_); 80 SendSurfaceID(surface_id_);
73 OnNaturalSizeChanged(video_natural_size); 81 OnNaturalSizeChanged(video_natural_size);
74 return; 82 return;
75 } 83 }
76 } 84 }
77 85
78 // If we don't own the fullscreen view, but one exists, it means another 86 // If we don't own the fullscreen view, but one exists, it means another
79 // WebContents has it. Ignore this request and return a null surface id. 87 // WebContents has it. Ignore this request and return a null surface id.
80 if (ContentVideoView::GetInstance()) { 88 if (ContentVideoView::GetInstance()) {
81 SendSurfaceID(media::SurfaceManager::kNoSurfaceID); 89 SendSurfaceID(media::SurfaceManager::kNoSurfaceID);
82 return; 90 return;
83 } 91 }
84 92
85 WebContents* web_contents = 93 WebContents* web_contents =
86 WebContents::FromRenderFrameHost(render_frame_host_); 94 WebContents::FromRenderFrameHost(render_frame_host_);
87 if (!web_contents->GetDelegate()) 95 if (!web_contents->GetDelegate()) {
96 SendSurfaceID(media::SurfaceManager::kNoSurfaceID);
88 return; 97 return;
98 }
89 ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents); 99 ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents);
90 content_video_view_.reset( 100 content_video_view_.reset(
91 new ContentVideoView(this, cvc, 101 new ContentVideoView(this, cvc,
92 web_contents->GetDelegate()->GetContentVideoViewEmbedder(), 102 web_contents->GetDelegate()->GetContentVideoViewEmbedder(),
93 video_natural_size)); 103 video_natural_size));
94 } 104 }
95 105
96 void BrowserSurfaceViewManager::OnNaturalSizeChanged(const gfx::Size& size) { 106 void BrowserSurfaceViewManager::OnNaturalSizeChanged(const gfx::Size& size) {
97 if (content_video_view_) 107 if (content_video_view_)
98 content_video_view_->OnVideoSizeChanged(size.width(), size.height()); 108 content_video_view_->OnVideoSizeChanged(size.width(), size.height());
(...skipping 13 matching lines...) Expand all
112 BrowserThread::IO, FROM_HERE, 122 BrowserThread::IO, FROM_HERE,
113 base::Bind(&SendDestroyingVideoSurfaceOnIO, surface_id, 123 base::Bind(&SendDestroyingVideoSurfaceOnIO, surface_id,
114 base::Bind(&base::WaitableEvent::Signal, 124 base::Bind(&base::WaitableEvent::Signal,
115 base::Unretained(&waiter))))) { 125 base::Unretained(&waiter))))) {
116 base::ThreadRestrictions::ScopedAllowWait allow_wait; 126 base::ThreadRestrictions::ScopedAllowWait allow_wait;
117 waiter.Wait(); 127 waiter.Wait();
118 } 128 }
119 } 129 }
120 130
121 } // namespace content 131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698