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

Side by Side Diff: media/gpu/content_video_view_overlay.cc

Issue 2856253004: removed AndroidOverlayFactory (Closed)
Patch Set: cl feedvback Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "media/gpu/content_video_view_overlay.h" 5 #include "media/gpu/content_video_view_overlay.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "gpu/ipc/common/gpu_surface_lookup.h" 10 #include "gpu/ipc/common/gpu_surface_lookup.h"
11 11
12 namespace media { 12 namespace media {
13 13
14 ContentVideoViewOverlay::ContentVideoViewOverlay( 14 ContentVideoViewOverlay::ContentVideoViewOverlay(int surface_id,
15 int surface_id, 15 AndroidOverlayConfig config)
16 const AndroidOverlay::Config& config) 16 : surface_id_(surface_id), config_(std::move(config)), weak_factory_(this) {
17 : surface_id_(surface_id), config_(config), weak_factory_(this) {
18 if (ContentVideoViewOverlayAllocator::GetInstance()->AllocateSurface(this)) { 17 if (ContentVideoViewOverlayAllocator::GetInstance()->AllocateSurface(this)) {
19 // We have the surface -- post a callback to our OnSurfaceAvailable. 18 // We have the surface -- post a callback to our OnSurfaceAvailable.
20 base::ThreadTaskRunnerHandle::Get()->PostTask( 19 base::ThreadTaskRunnerHandle::Get()->PostTask(
21 FROM_HERE, base::Bind(&ContentVideoViewOverlay::OnSurfaceAvailable, 20 FROM_HERE, base::Bind(&ContentVideoViewOverlay::OnSurfaceAvailable,
22 weak_factory_.GetWeakPtr(), true)); 21 weak_factory_.GetWeakPtr(), true));
23 } 22 }
24 } 23 }
25 24
26 ContentVideoViewOverlay::~ContentVideoViewOverlay() { 25 ContentVideoViewOverlay::~ContentVideoViewOverlay() {
27 // Deallocate the surface. It's okay if we don't own it. 26 // Deallocate the surface. It's okay if we don't own it.
28 // Note that this only happens once any codec is done with us. 27 // Note that this only happens once any codec is done with us.
29 ContentVideoViewOverlayAllocator::GetInstance()->DeallocateSurface(this); 28 ContentVideoViewOverlayAllocator::GetInstance()->DeallocateSurface(this);
30 } 29 }
31 30
32 void ContentVideoViewOverlay::ScheduleLayout(const gfx::Rect& rect) { 31 void ContentVideoViewOverlay::ScheduleLayout(const gfx::Rect& rect) {
33 NOTIMPLEMENTED(); 32 NOTIMPLEMENTED();
34 } 33 }
35 34
36 const base::android::JavaRef<jobject>& ContentVideoViewOverlay::GetJavaSurface() 35 const base::android::JavaRef<jobject>& ContentVideoViewOverlay::GetJavaSurface()
37 const { 36 const {
38 return surface_.j_surface(); 37 return surface_.j_surface();
39 } 38 }
40 39
41 void ContentVideoViewOverlay::OnSurfaceAvailable(bool success) { 40 void ContentVideoViewOverlay::OnSurfaceAvailable(bool success) {
42 if (!success) { 41 if (!success) {
43 // Notify that the surface won't be available. 42 // Notify that the surface won't be available.
44 config_.failed_cb.Run(this); 43 config_.is_failed(this);
45 // |this| may be deleted. 44 // |this| may be deleted.
46 return; 45 return;
47 } 46 }
48 47
49 // Get the surface and notify our client. 48 // Get the surface and notify our client.
50 surface_ = 49 surface_ =
51 gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id_); 50 gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id_);
52 51
53 // If no surface was returned, then fail instead. 52 // If no surface was returned, then fail instead.
54 if (surface_.IsEmpty()) { 53 if (surface_.IsEmpty()) {
55 config_.failed_cb.Run(this); 54 config_.is_failed(this);
56 // |this| may be deleted. 55 // |this| may be deleted.
57 return; 56 return;
58 } 57 }
59 58
60 config_.ready_cb.Run(this); 59 config_.is_ready(this);
61 } 60 }
62 61
63 void ContentVideoViewOverlay::OnSurfaceDestroyed() { 62 void ContentVideoViewOverlay::OnSurfaceDestroyed() {
64 config_.destroyed_cb.Run(this); 63 config_.is_destroyed(this);
65 // |this| may be deleted, or deletion might be posted elsewhere. 64 // |this| may be deleted, or deletion might be posted elsewhere.
66 } 65 }
67 66
68 int32_t ContentVideoViewOverlay::GetSurfaceId() { 67 int32_t ContentVideoViewOverlay::GetSurfaceId() {
69 return surface_id_; 68 return surface_id_;
70 } 69 }
71 70
72 } // namespace media 71 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698