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

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

Issue 2692863011: Add ContentVideoViewOverlay to AVDA. (Closed)
Patch Set: keep |overlay| longer in UpdateSurface, comments Created 3 years, 10 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 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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "gpu/command_buffer/service/context_group.h" 15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/gl_stream_texture_image.h" 16 #include "gpu/command_buffer/service/gl_stream_texture_image.h"
17 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 17 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
18 #include "gpu/command_buffer/service/texture_manager.h" 18 #include "gpu/command_buffer/service/texture_manager.h"
19 #include "gpu/ipc/common/gpu_surface_lookup.h"
20 #include "gpu/ipc/service/gpu_channel.h" 19 #include "gpu/ipc/service/gpu_channel.h"
21 #include "media/base/android/media_codec_bridge_impl.h" 20 #include "media/base/android/media_codec_bridge_impl.h"
22 #include "media/gpu/avda_codec_image.h" 21 #include "media/gpu/avda_codec_image.h"
23 #include "media/gpu/avda_shared_state.h" 22 #include "media/gpu/avda_shared_state.h"
23 #include "ui/gl/android/scoped_java_surface.h"
24 #include "ui/gl/android/surface_texture.h" 24 #include "ui/gl/android/surface_texture.h"
25 #include "ui/gl/egl_util.h" 25 #include "ui/gl/egl_util.h"
26 #include "ui/gl/gl_bindings.h" 26 #include "ui/gl/gl_bindings.h"
27 #include "ui/gl/gl_surface_egl.h" 27 #include "ui/gl/gl_surface_egl.h"
28 #include "ui/gl/scoped_binders.h" 28 #include "ui/gl/scoped_binders.h"
29 #include "ui/gl/scoped_make_current.h" 29 #include "ui/gl/scoped_make_current.h"
30 30
31 // If !|ptr|, log a message, notify |state_provider_| of the error, and 31 // If !|ptr|, log a message, notify |state_provider_| of the error, and
32 // return an optional value. 32 // return an optional value.
33 #define RETURN_IF_NULL(ptr, ...) \ 33 #define RETURN_IF_NULL(ptr, ...) \
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 } // namespace 74 } // namespace
75 75
76 AVDAPictureBufferManager::AVDAPictureBufferManager( 76 AVDAPictureBufferManager::AVDAPictureBufferManager(
77 AVDAStateProvider* state_provider) 77 AVDAStateProvider* state_provider)
78 : state_provider_(state_provider), media_codec_(nullptr) {} 78 : state_provider_(state_provider), media_codec_(nullptr) {}
79 79
80 AVDAPictureBufferManager::~AVDAPictureBufferManager() {} 80 AVDAPictureBufferManager::~AVDAPictureBufferManager() {}
81 81
82 gl::ScopedJavaSurface AVDAPictureBufferManager::Initialize(int surface_id) { 82 void AVDAPictureBufferManager::InitializeForOverlay() {
83 shared_state_ = new AVDASharedState();
84 surface_texture_ = nullptr;
85 }
86
87 gl::ScopedJavaSurface AVDAPictureBufferManager::InitializeForSurfaceTexture() {
83 shared_state_ = new AVDASharedState(); 88 shared_state_ = new AVDASharedState();
84 surface_texture_ = nullptr; 89 surface_texture_ = nullptr;
85 90
86 // Acquire the SurfaceView surface if given a valid id. 91 // Create a SurfaceTexture.
87 if (surface_id != SurfaceManager::kNoSurfaceID)
88 return gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id);
89
90 // Otherwise create a SurfaceTexture.
91 GLuint service_id; 92 GLuint service_id;
92 surface_texture_ = CreateAttachedSurfaceTexture( 93 surface_texture_ = CreateAttachedSurfaceTexture(
93 state_provider_->GetGlDecoder(), &service_id); 94 state_provider_->GetGlDecoder(), &service_id);
94 shared_state_->SetSurfaceTexture(surface_texture_, service_id); 95 shared_state_->SetSurfaceTexture(surface_texture_, service_id);
95 return gl::ScopedJavaSurface(surface_texture_.get()); 96 return gl::ScopedJavaSurface(surface_texture_.get());
96 } 97 }
97 98
98 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) { 99 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) {
99 // Do nothing if Initialize() has not been called. 100 // Do nothing if Initialize() has not been called.
100 if (!shared_state_) 101 if (!shared_state_)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 285
285 bool AVDAPictureBufferManager::HasUnrenderedPictures() const { 286 bool AVDAPictureBufferManager::HasUnrenderedPictures() const {
286 for (int id : pictures_out_for_display_) { 287 for (int id : pictures_out_for_display_) {
287 if (GetImageForPicture(id)->is_unrendered()) 288 if (GetImageForPicture(id)->is_unrendered())
288 return true; 289 return true;
289 } 290 }
290 return false; 291 return false;
291 } 292 }
292 293
293 } // namespace media 294 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698