OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/avda_picture_buffer_manager.h" | 5 #include "media/gpu/avda_picture_buffer_manager.h" |
6 | 6 |
7 #include <EGL/egl.h> | 7 #include <EGL/egl.h> |
8 #include <EGL/eglext.h> | 8 #include <EGL/eglext.h> |
9 | 9 |
10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 AVDAPictureBufferManager::AVDAPictureBufferManager( | 69 AVDAPictureBufferManager::AVDAPictureBufferManager( |
70 AVDAStateProvider* state_provider) | 70 AVDAStateProvider* state_provider) |
71 : state_provider_(state_provider), media_codec_(nullptr) {} | 71 : state_provider_(state_provider), media_codec_(nullptr) {} |
72 | 72 |
73 AVDAPictureBufferManager::~AVDAPictureBufferManager() {} | 73 AVDAPictureBufferManager::~AVDAPictureBufferManager() {} |
74 | 74 |
75 void AVDAPictureBufferManager::InitializeForOverlay() { | 75 bool AVDAPictureBufferManager::Initialize( |
76 shared_state_ = new AVDASharedState(); | 76 scoped_refptr<AVDASurfaceBundle> surface_bundle) { |
77 surface_texture_ = nullptr; | 77 shared_state_ = nullptr; |
watk
2017/05/17 19:45:14
delete now?
liberato (no reviews please)
2017/05/17 20:19:32
can't, in case of the early out @85.
| |
78 } | |
79 | |
80 gl::ScopedJavaSurface AVDAPictureBufferManager::InitializeForSurfaceTexture() { | |
81 shared_state_ = new AVDASharedState(); | |
82 surface_texture_ = nullptr; | 78 surface_texture_ = nullptr; |
83 | 79 |
84 // Create a SurfaceTexture. | 80 if (!surface_bundle->overlay) { |
85 surface_texture_ = | 81 // Create the surface texture. |
86 CreateAttachedSurfaceTexture(state_provider_->GetGlDecoder()); | 82 surface_texture_ = |
87 if (!surface_texture_) | 83 CreateAttachedSurfaceTexture(state_provider_->GetGlDecoder()); |
88 return gl::ScopedJavaSurface(); | 84 if (!surface_texture_) |
85 return false; | |
89 | 86 |
90 shared_state_->SetSurfaceTexture(surface_texture_); | 87 surface_bundle->surface_texture_surface = |
91 return gl::ScopedJavaSurface(surface_texture_.get()); | 88 gl::ScopedJavaSurface(surface_texture_.get()); |
89 surface_bundle->surface_texture = surface_texture_; | |
90 } | |
91 | |
92 // Only do this one the surface texture is filled in, since the constructor | |
watk
2017/05/17 19:45:14
s/one/once
liberato (no reviews please)
2017/05/17 20:19:32
Done.
| |
93 // assumes that it will be. | |
94 shared_state_ = new AVDASharedState(surface_bundle); | |
95 | |
96 return true; | |
92 } | 97 } |
93 | 98 |
94 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) { | 99 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) { |
95 // Do nothing if Initialize() has not been called. | 100 // Do nothing if Initialize() has not been called. |
96 if (!shared_state_) | 101 if (!shared_state_) |
97 return; | 102 return; |
98 | 103 |
99 ReleaseCodecBuffers(buffers); | 104 ReleaseCodecBuffers(buffers); |
100 CodecChanged(nullptr); | 105 CodecChanged(nullptr); |
101 surface_texture_ = nullptr; | 106 surface_texture_ = nullptr; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 | 285 |
281 bool AVDAPictureBufferManager::HasUnrenderedPictures() const { | 286 bool AVDAPictureBufferManager::HasUnrenderedPictures() const { |
282 for (int id : pictures_out_for_display_) { | 287 for (int id : pictures_out_for_display_) { |
283 if (GetImageForPicture(id)->is_unrendered()) | 288 if (GetImageForPicture(id)->is_unrendered()) |
284 return true; | 289 return true; |
285 } | 290 } |
286 return false; | 291 return false; |
287 } | 292 } |
288 | 293 |
289 } // namespace media | 294 } // namespace media |
OLD | NEW |