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

Side by Side Diff: content/common/gpu/media/android_copying_backing_strategy.cc

Issue 1490333005: Don't require VDAs to return all PictureBuffers at once. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl feedback. Created 5 years 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 "content/common/gpu/media/android_copying_backing_strategy.h" 5 #include "content/common/gpu/media/android_copying_backing_strategy.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/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/common/gpu/media/avda_return_on_failure.h" 10 #include "content/common/gpu/media/avda_return_on_failure.h"
11 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 11 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
13 #include "media/base/limits.h" 13 #include "media/base/limits.h"
14 #include "media/video/picture.h" 14 #include "media/video/picture.h"
15 #include "ui/gl/android/surface_texture.h" 15 #include "ui/gl/android/surface_texture.h"
16 #include "ui/gl/gl_bindings.h" 16 #include "ui/gl/gl_bindings.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 // TODO(liberato): It is unclear if we have an issue with deadlock during
21 // playback if we lower this. Previously (crbug.com/176036), a deadlock
22 // could occur during preroll. More recent tests have shown some
23 // instability with kNumPictureBuffers==2 with similar symptoms
24 // during playback. crbug.com/:531588 .
25 enum { kNumPictureBuffers = media::limits::kMaxVideoFrames + 1 };
26
27 const static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 20 const static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
28 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 21 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
29 0.0f, 0.0f, 0.0f, 1.0f}; 22 0.0f, 0.0f, 0.0f, 1.0f};
30 23
31 AndroidCopyingBackingStrategy::AndroidCopyingBackingStrategy() 24 AndroidCopyingBackingStrategy::AndroidCopyingBackingStrategy()
32 : state_provider_(nullptr), surface_texture_id_(0), media_codec_(nullptr) {} 25 : state_provider_(nullptr), surface_texture_id_(0), media_codec_(nullptr) {}
33 26
34 AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {} 27 AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {}
35 28
36 void AndroidCopyingBackingStrategy::Initialize( 29 void AndroidCopyingBackingStrategy::Initialize(
37 AVDAStateProvider* state_provider) { 30 AVDAStateProvider* state_provider) {
38 state_provider_ = state_provider; 31 state_provider_ = state_provider;
39 } 32 }
40 33
41 void AndroidCopyingBackingStrategy::Cleanup( 34 void AndroidCopyingBackingStrategy::Cleanup(
42 const AndroidVideoDecodeAccelerator::OutputBufferMap&) { 35 const AndroidVideoDecodeAccelerator::OutputBufferMap&) {
43 DCHECK(state_provider_->ThreadChecker().CalledOnValidThread()); 36 DCHECK(state_provider_->ThreadChecker().CalledOnValidThread());
44 if (copier_) 37 if (copier_)
45 copier_->Destroy(); 38 copier_->Destroy();
46 39
47 if (surface_texture_id_) 40 if (surface_texture_id_)
48 glDeleteTextures(1, &surface_texture_id_); 41 glDeleteTextures(1, &surface_texture_id_);
49 } 42 }
50 43
51 uint32 AndroidCopyingBackingStrategy::GetNumPictureBuffers() const {
52 return kNumPictureBuffers;
53 }
54
55 uint32 AndroidCopyingBackingStrategy::GetTextureTarget() const { 44 uint32 AndroidCopyingBackingStrategy::GetTextureTarget() const {
56 return GL_TEXTURE_2D; 45 return GL_TEXTURE_2D;
57 } 46 }
58 47
59 scoped_refptr<gfx::SurfaceTexture> 48 scoped_refptr<gfx::SurfaceTexture>
60 AndroidCopyingBackingStrategy::CreateSurfaceTexture() { 49 AndroidCopyingBackingStrategy::CreateSurfaceTexture() {
61 glGenTextures(1, &surface_texture_id_); 50 glGenTextures(1, &surface_texture_id_);
62 glActiveTexture(GL_TEXTURE0); 51 glActiveTexture(GL_TEXTURE0);
63 glBindTexture(GL_TEXTURE_EXTERNAL_OES, surface_texture_id_); 52 glBindTexture(GL_TEXTURE_EXTERNAL_OES, surface_texture_id_);
64 53
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 false, false, false, kIdentityMatrix); 126 false, false, false, kIdentityMatrix);
138 } 127 }
139 128
140 void AndroidCopyingBackingStrategy::CodecChanged( 129 void AndroidCopyingBackingStrategy::CodecChanged(
141 media::VideoCodecBridge* codec, 130 media::VideoCodecBridge* codec,
142 const AndroidVideoDecodeAccelerator::OutputBufferMap&) { 131 const AndroidVideoDecodeAccelerator::OutputBufferMap&) {
143 media_codec_ = codec; 132 media_codec_ = codec;
144 } 133 }
145 134
146 } // namespace content 135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698