Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/media/android/browser_surface_view_manager.h" | |
| 6 | |
| 7 #include "content/browser/android/child_process_launcher_android.h" | |
| 8 #include "content/browser/android/content_view_core_impl.h" | |
| 9 #include "content/browser/gpu/gpu_surface_tracker.h" | |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | |
| 11 #include "content/common/media/surface_view_manager_messages_android.h" | |
| 12 #include "content/public/browser/render_frame_host.h" | |
| 13 #include "media/base/surface_manager.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 BrowserSurfaceViewManager::BrowserSurfaceViewManager( | |
| 19 RenderFrameHost* render_frame_host) | |
| 20 : render_frame_host_(render_frame_host), | |
| 21 surface_id_(media::SurfaceManager::kNoSurfaceID) {} | |
| 22 | |
| 23 void BrowserSurfaceViewManager::SetVideoSurface( | |
| 24 gfx::ScopedJavaSurface surface) { | |
| 25 if (surface.IsEmpty()) { | |
| 26 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | |
| 27 UnregisterViewSurface(surface_id_); | |
| 28 surface_id_ = media::SurfaceManager::kNoSurfaceID; | |
| 29 } else { | |
| 30 // We mainly use the surface tracker to allocate a surface id for us. The | |
| 31 // lookup will go through the Android specific path and get the java | |
| 32 // surface directly, so there's no need to add a valid native widget here. | |
| 33 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForNativeWidget( | |
| 34 gfx::kNullAcceleratedWidget); | |
| 35 RegisterViewSurface(surface_id_, surface.j_surface().obj()); | |
| 36 SendSurfaceID(surface_id_); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 void BrowserSurfaceViewManager::DidExitFullscreen(bool release_media_player) { | |
| 41 DVLOG(3) << __FUNCTION__; | |
| 42 content_video_view_.reset(); | |
| 43 } | |
| 44 | |
| 45 void BrowserSurfaceViewManager::OnCreateFullscreenSurface( | |
| 46 gfx::Size video_size) { | |
| 47 // It's valid to get this call if we already own the fullscreen view. We just | |
| 48 // return the existing surface id. | |
| 49 if (content_video_view_) { | |
| 50 // Send the surface now if we have it. Otherwise it will be returned by | |
| 51 // |SetVideoSurface|. | |
| 52 if (surface_id_ != media::SurfaceManager::kNoSurfaceID) | |
| 53 SendSurfaceID(surface_id_); | |
|
liberato (no reviews please)
2016/02/05 22:09:46
do we need to OnFullscreenVideoSizeChanged() too?
watk
2016/02/11 23:03:25
Oops, Done
| |
| 54 return; | |
| 55 } | |
| 56 | |
| 57 // If we don't own the fullscreen view, but one exists, it means another | |
| 58 // WebContents has it. Ignore this request and return a null surface id. | |
| 59 if (ContentVideoView::GetInstance()) { | |
| 60 SendSurfaceID(media::SurfaceManager::kNoSurfaceID); | |
| 61 return; | |
| 62 } | |
| 63 | |
| 64 ContentViewCore* cvc = ContentViewCore::FromWebContents( | |
| 65 WebContents::FromRenderFrameHost(render_frame_host_)); | |
| 66 content_video_view_.reset(new ContentVideoView(this, cvc)); | |
| 67 OnFullscreenVideoSizeChanged(video_size); | |
| 68 } | |
| 69 | |
| 70 void BrowserSurfaceViewManager::OnFullscreenVideoSizeChanged(gfx::Size size) { | |
|
liberato (no reviews please)
2016/02/05 22:09:46
OnNaturalSizeChanged (here and elsewhere)? i see
watk
2016/02/11 23:03:25
Done.
| |
| 71 if (content_video_view_) | |
| 72 content_video_view_->OnVideoSizeChanged(size.width(), size.height()); | |
| 73 } | |
| 74 | |
| 75 bool BrowserSurfaceViewManager::SendSurfaceID(int surface_id) { | |
| 76 return render_frame_host_->Send( | |
| 77 new RendererSurfaceViewManagerMsg_FullscreenSurfaceCreated( | |
| 78 render_frame_host_->GetRoutingID(), surface_id)); | |
| 79 } | |
| 80 | |
| 81 } // namespace content | |
| OLD | NEW |