Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
|
watk
2017/02/17 22:40:36
no (c)
liberato (no reviews please)
2017/03/07 21:30:25
Done.
| |
| 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 "media/gpu/content_video_view_overlay.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/threading/thread_task_runner_handle.h" | |
| 10 #include "gpu/ipc/common/gpu_surface_lookup.h" | |
| 11 | |
| 12 namespace media { | |
| 13 | |
| 14 ContentVideoViewOverlay::ContentVideoViewOverlay( | |
| 15 AVDACodecAllocator* codec_allocator, | |
| 16 int surface_id, | |
| 17 const AndroidOverlay::Config& config) | |
| 18 : codec_allocator_(codec_allocator), | |
| 19 surface_id_(surface_id), | |
| 20 config_(config), | |
| 21 weak_factory_(this) { | |
| 22 if (codec_allocator_->AllocateSurface(this, surface_id_)) { | |
| 23 // We have the surface -- post a callback to our OnSurfaceAvailable. | |
| 24 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 25 FROM_HERE, base::Bind(&ContentVideoViewOverlay::OnSurfaceAvailable, | |
| 26 weak_factory_.GetWeakPtr(), true)); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 ContentVideoViewOverlay::~ContentVideoViewOverlay() { | |
| 31 // Deallocate the surface. It's okay if we don't own it. | |
| 32 codec_allocator_->DeallocateSurface(this, surface_id_); | |
| 33 } | |
| 34 | |
| 35 void ContentVideoViewOverlay::ScheduleLayout(const gfx::Rect& rect) { | |
| 36 NOTIMPLEMENTED(); | |
| 37 } | |
| 38 | |
| 39 void ContentVideoViewOverlay::OnSurfaceAvailable(bool success) { | |
| 40 if (!success) { | |
| 41 // Notify that the surface won't be available. | |
| 42 // TODO(liberato): should we have a separate cb for this? | |
|
watk
2017/02/17 22:40:36
Delete TODO? Or is it just for the code review?
liberato (no reviews please)
2017/03/07 21:30:25
for review. on further thought, i think that we s
| |
| 43 config_.destroyed_cb.Run(); | |
| 44 // |this| may be deleted. | |
| 45 return; | |
| 46 } | |
| 47 | |
| 48 // Get the surface and notify our client. | |
| 49 SetJavaSurface( | |
| 50 gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id_)); | |
| 51 config_.ready_cb.Run(); | |
| 52 } | |
| 53 | |
| 54 void ContentVideoViewOverlay::OnSurfaceDestroyed() { | |
| 55 config_.destroyed_cb.Run(); | |
| 56 // |this| may be deleted, or deletion might be posted elsewhere. | |
| 57 } | |
| 58 | |
| 59 } // namespace media | |
| OLD | NEW |