Chromium Code Reviews| Index: content/common/gpu/media/android_copying_backing_strategy.cc |
| diff --git a/content/common/gpu/media/android_copying_backing_strategy.cc b/content/common/gpu/media/android_copying_backing_strategy.cc |
| index aa1af4a54aff795f6bf30d6cf7d1d113eae35018..eec2fae206a715f946aa4f92ebf916c5ed409e8e 100644 |
| --- a/content/common/gpu/media/android_copying_backing_strategy.cc |
| +++ b/content/common/gpu/media/android_copying_backing_strategy.cc |
| @@ -22,33 +22,20 @@ const static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
| 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, |
| 0.0f, 0.0f, 0.0f, 1.0f}; |
| -AndroidCopyingBackingStrategy::AndroidCopyingBackingStrategy() |
| - : state_provider_(nullptr), surface_texture_id_(0), media_codec_(nullptr) {} |
| +AndroidCopyingBackingStrategy::AndroidCopyingBackingStrategy( |
| + AVDAStateProvider* state_provider) |
| + : state_provider_(state_provider), |
| + surface_texture_id_(0), |
| + media_codec_(nullptr) {} |
| AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {} |
| -void AndroidCopyingBackingStrategy::Initialize( |
| - AVDAStateProvider* state_provider) { |
| - state_provider_ = state_provider; |
| -} |
| +gfx::ScopedJavaSurface AndroidCopyingBackingStrategy::Initialize( |
| + int surface_view_id) { |
| + DCHECK_EQ(surface_view_id, |
|
dcheng
2016/02/02 07:37:26
Ultimately, this is invoked by a message sent by t
watk
2016/02/02 19:56:45
Done.
|
| + media::VideoDecodeAccelerator::Config::kNoSurfaceID); |
| -void AndroidCopyingBackingStrategy::Cleanup( |
| - bool have_context, |
| - const AndroidVideoDecodeAccelerator::OutputBufferMap&) { |
| - DCHECK(state_provider_->ThreadChecker().CalledOnValidThread()); |
| - if (copier_) |
| - copier_->Destroy(); |
| - |
| - if (surface_texture_id_ && have_context) |
| - glDeleteTextures(1, &surface_texture_id_); |
| -} |
| - |
| -uint32_t AndroidCopyingBackingStrategy::GetTextureTarget() const { |
| - return GL_TEXTURE_2D; |
| -} |
| - |
| -scoped_refptr<gfx::SurfaceTexture> |
| -AndroidCopyingBackingStrategy::CreateSurfaceTexture() { |
| + // Create a texture and attach the SurfaceTexture to it. |
| glGenTextures(1, &surface_texture_id_); |
| glActiveTexture(GL_TEXTURE0); |
| glBindTexture(GL_TEXTURE_EXTERNAL_OES, surface_texture_id_); |
| @@ -57,14 +44,36 @@ AndroidCopyingBackingStrategy::CreateSurfaceTexture() { |
| glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| + |
| state_provider_->GetGlDecoder()->RestoreTextureUnitBindings(0); |
| state_provider_->GetGlDecoder()->RestoreActiveTexture(); |
| surface_texture_ = gfx::SurfaceTexture::Create(surface_texture_id_); |
| + return gfx::ScopedJavaSurface(surface_texture_.get()); |
| +} |
| + |
| +void AndroidCopyingBackingStrategy::Cleanup( |
| + bool have_context, |
| + const AndroidVideoDecodeAccelerator::OutputBufferMap&) { |
| + DCHECK(state_provider_->ThreadChecker().CalledOnValidThread()); |
| + |
| + if (copier_) |
| + copier_->Destroy(); |
| + |
| + if (surface_texture_id_ && have_context) |
| + glDeleteTextures(1, &surface_texture_id_); |
| +} |
| + |
| +scoped_refptr<gfx::SurfaceTexture> |
| +AndroidCopyingBackingStrategy::GetSurfaceTexture() const { |
| return surface_texture_; |
| } |
| +uint32_t AndroidCopyingBackingStrategy::GetTextureTarget() const { |
| + return GL_TEXTURE_2D; |
| +} |
| + |
| void AndroidCopyingBackingStrategy::UseCodecBufferForPictureBuffer( |
| int32_t codec_buf_index, |
| const media::PictureBuffer& picture_buffer) { |
| @@ -143,4 +152,8 @@ void AndroidCopyingBackingStrategy::OnFrameAvailable() { |
| // instead preserve the old behavior. |
| } |
| +bool AndroidCopyingBackingStrategy::ArePicturesOverlayable() { |
| + return false; |
| +} |
| + |
| } // namespace content |