OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 : render_frame_host_(render_frame_host), | 34 : render_frame_host_(render_frame_host), |
35 surface_id_(media::SurfaceManager::kNoSurfaceID) {} | 35 surface_id_(media::SurfaceManager::kNoSurfaceID) {} |
36 | 36 |
37 BrowserSurfaceViewManager::~BrowserSurfaceViewManager() {} | 37 BrowserSurfaceViewManager::~BrowserSurfaceViewManager() {} |
38 | 38 |
39 void BrowserSurfaceViewManager::SetVideoSurface(gl::ScopedJavaSurface surface) { | 39 void BrowserSurfaceViewManager::SetVideoSurface(gl::ScopedJavaSurface surface) { |
40 TRACE_EVENT0("media", "BrowserSurfaceViewManager::SetVideoSurface"); | 40 TRACE_EVENT0("media", "BrowserSurfaceViewManager::SetVideoSurface"); |
41 if (surface.IsEmpty()) { | 41 if (surface.IsEmpty()) { |
42 DCHECK_NE(surface_id_, media::SurfaceManager::kNoSurfaceID); | 42 DCHECK_NE(surface_id_, media::SurfaceManager::kNoSurfaceID); |
43 gpu::GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | 43 gpu::GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); |
44 gpu::GpuSurfaceTracker::Get()->UnregisterViewSurface(surface_id_); | |
45 SendDestroyingVideoSurface(surface_id_); | 44 SendDestroyingVideoSurface(surface_id_); |
46 surface_id_ = media::SurfaceManager::kNoSurfaceID; | 45 surface_id_ = media::SurfaceManager::kNoSurfaceID; |
47 } else { | 46 } else { |
48 // We just use the surface tracker to allocate a surface id for us. The | 47 // We just use the surface tracker to allocate a surface id for us. The |
49 // lookup will go through the Android specific path and get the java | 48 // lookup will go through the Android specific path and get the java |
50 // surface directly, so there's no need to add a valid native widget here. | 49 // surface directly, so there's no need to add a valid native widget here. |
51 surface_id_ = gpu::GpuSurfaceTracker::Get()->AddSurfaceForNativeWidget( | 50 surface_id_ = gpu::GpuSurfaceTracker::Get()->AddSurfaceForNativeWidget( |
52 gfx::kNullAcceleratedWidget); | 51 gpu::GpuSurfaceTracker::SurfaceRecord(gfx::kNullAcceleratedWidget, |
53 gpu::GpuSurfaceTracker::GetInstance()->RegisterViewSurface( | 52 surface.j_surface().obj())); |
54 surface_id_, surface.j_surface().obj()); | |
55 SendSurfaceID(surface_id_); | 53 SendSurfaceID(surface_id_); |
56 } | 54 } |
57 } | 55 } |
58 | 56 |
59 void BrowserSurfaceViewManager::DidExitFullscreen(bool release_media_player) { | 57 void BrowserSurfaceViewManager::DidExitFullscreen(bool release_media_player) { |
60 DVLOG(3) << __func__; | 58 DVLOG(3) << __func__; |
61 content_video_view_.reset(); | 59 content_video_view_.reset(); |
62 } | 60 } |
63 | 61 |
64 void BrowserSurfaceViewManager::OnCreateFullscreenSurface( | 62 void BrowserSurfaceViewManager::OnCreateFullscreenSurface( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 BrowserThread::IO, FROM_HERE, | 122 BrowserThread::IO, FROM_HERE, |
125 base::Bind(&SendDestroyingVideoSurfaceOnIO, surface_id, | 123 base::Bind(&SendDestroyingVideoSurfaceOnIO, surface_id, |
126 base::Bind(&base::WaitableEvent::Signal, | 124 base::Bind(&base::WaitableEvent::Signal, |
127 base::Unretained(&waiter))))) { | 125 base::Unretained(&waiter))))) { |
128 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 126 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
129 waiter.Wait(); | 127 waiter.Wait(); |
130 } | 128 } |
131 } | 129 } |
132 | 130 |
133 } // namespace content | 131 } // namespace content |
OLD | NEW |