OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/android_video_decode_accelerator.h" | 5 #include "media/gpu/android_video_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 | 1372 |
1373 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size()); | 1373 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size()); |
1374 gpu::gles2::TextureRef* texture_ref = | 1374 gpu::gles2::TextureRef* texture_ref = |
1375 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]); | 1375 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]); |
1376 RETURN_ON_FAILURE(this, texture_manager, "Null texture_ref", ILLEGAL_STATE, | 1376 RETURN_ON_FAILURE(this, texture_manager, "Null texture_ref", ILLEGAL_STATE, |
1377 nullptr); | 1377 nullptr); |
1378 | 1378 |
1379 return texture_ref; | 1379 return texture_ref; |
1380 } | 1380 } |
1381 | 1381 |
| 1382 scoped_refptr<gl::SurfaceTexture> |
| 1383 AndroidVideoDecodeAccelerator::CreateAttachedSurfaceTexture( |
| 1384 GLuint* service_id) { |
| 1385 GLuint texture_id; |
| 1386 glGenTextures(1, &texture_id); |
| 1387 |
| 1388 glActiveTexture(GL_TEXTURE0); |
| 1389 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id); |
| 1390 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 1391 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 1392 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1393 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1394 |
| 1395 auto gl_decoder = GetGlDecoder(); |
| 1396 gl_decoder->RestoreTextureUnitBindings(0); |
| 1397 gl_decoder->RestoreActiveTexture(); |
| 1398 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1399 |
| 1400 *service_id = texture_id; |
| 1401 // Previously, to reduce context switching, we used to create an unattached |
| 1402 // SurfaceTexture and attach it lazily in the compositor's context. But that |
| 1403 // was flaky because SurfaceTexture#detachFromGLContext() is buggy on a lot of |
| 1404 // devices. Now we attach it to the current context, which means we might have |
| 1405 // to context switch later to call updateTexImage(). Fortunately, if virtual |
| 1406 // contexts are in use, we won't have to context switch. |
| 1407 return gl::SurfaceTexture::Create(texture_id); |
| 1408 } |
| 1409 |
1382 void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) { | 1410 void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) { |
1383 DCHECK(thread_checker_.CalledOnValidThread()); | 1411 DCHECK(thread_checker_.CalledOnValidThread()); |
1384 TRACE_EVENT0("media", "AVDA::OnDestroyingSurface"); | 1412 TRACE_EVENT0("media", "AVDA::OnDestroyingSurface"); |
1385 DVLOG(1) << __FUNCTION__ << " surface_id: " << surface_id; | 1413 DVLOG(1) << __FUNCTION__ << " surface_id: " << surface_id; |
1386 | 1414 |
1387 if (surface_id != config_.surface_id) | 1415 if (surface_id != config_.surface_id) |
1388 return; | 1416 return; |
1389 | 1417 |
1390 // If we're currently asynchronously configuring a codec, it will be destroyed | 1418 // If we're currently asynchronously configuring a codec, it will be destroyed |
1391 // when configuration completes and it notices that |state_| has changed to | 1419 // when configuration completes and it notices that |state_| has changed to |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1653 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
1626 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1654 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
1627 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1655 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
1628 } | 1656 } |
1629 } | 1657 } |
1630 | 1658 |
1631 return capabilities; | 1659 return capabilities; |
1632 } | 1660 } |
1633 | 1661 |
1634 } // namespace media | 1662 } // namespace media |
OLD | NEW |