Index: media/gpu/content_video_view_overlay.cc |
diff --git a/media/gpu/content_video_view_overlay.cc b/media/gpu/content_video_view_overlay.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..16e21a6078094ce3b29694484a6cc6ec8a2d5b35 |
--- /dev/null |
+++ b/media/gpu/content_video_view_overlay.cc |
@@ -0,0 +1,59 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/gpu/content_video_view_overlay.h" |
+ |
+#include "base/bind.h" |
+#include "base/logging.h" |
+#include "base/threading/thread_task_runner_handle.h" |
+#include "gpu/ipc/common/gpu_surface_lookup.h" |
+ |
+namespace media { |
+ |
+ContentVideoViewOverlay::ContentVideoViewOverlay( |
+ AVDACodecAllocator* codec_allocator, |
+ int surface_id, |
+ const AndroidOverlay::Config& config) |
+ : codec_allocator_(codec_allocator), |
+ surface_id_(surface_id), |
+ config_(config), |
+ weak_factory_(this) { |
+ if (codec_allocator_->AllocateSurface(this, surface_id_)) { |
+ // We have the surface -- post a callback to our OnSurfaceAvailable. |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, base::Bind(&ContentVideoViewOverlay::OnSurfaceAvailable, |
+ weak_factory_.GetWeakPtr(), true)); |
+ } |
+} |
+ |
+ContentVideoViewOverlay::~ContentVideoViewOverlay() { |
+ // Deallocate the surface. It's okay if we don't own it. |
+ codec_allocator_->DeallocateSurface(this, surface_id_); |
+} |
+ |
+void ContentVideoViewOverlay::ScheduleLayout(const gfx::Rect& rect) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void ContentVideoViewOverlay::OnSurfaceAvailable(bool success) { |
+ if (!success) { |
+ // Notify that the surface won't be available. |
+ // 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
|
+ config_.destroyed_cb.Run(); |
+ // |this| may be deleted. |
+ return; |
+ } |
+ |
+ // Get the surface and notify our client. |
+ SetJavaSurface( |
+ gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id_)); |
+ config_.ready_cb.Run(); |
+} |
+ |
+void ContentVideoViewOverlay::OnSurfaceDestroyed() { |
+ config_.destroyed_cb.Run(); |
+ // |this| may be deleted, or deletion might be posted elsewhere. |
+} |
+ |
+} // namespace media |