Chromium Code Reviews| 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 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1341 | 1341 |
| 1342 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size()); | 1342 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size()); |
| 1343 gpu::gles2::TextureRef* texture_ref = | 1343 gpu::gles2::TextureRef* texture_ref = |
| 1344 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]); | 1344 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]); |
| 1345 RETURN_ON_FAILURE(this, texture_manager, "Null texture_ref", ILLEGAL_STATE, | 1345 RETURN_ON_FAILURE(this, texture_manager, "Null texture_ref", ILLEGAL_STATE, |
| 1346 nullptr); | 1346 nullptr); |
| 1347 | 1347 |
| 1348 return texture_ref; | 1348 return texture_ref; |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 scoped_refptr<gfx::SurfaceTexture> | |
| 1352 AndroidVideoDecodeAccelerator::CreateAttachedSurfaceTexture( | |
| 1353 GLuint* service_id) { | |
| 1354 GLuint texture_id; | |
| 1355 glGenTextures(1, &texture_id); | |
| 1356 | |
| 1357 glActiveTexture(GL_TEXTURE0); | |
| 1358 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id); | |
| 1359 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
| 1360 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
| 1361 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 1362 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 1363 | |
| 1364 auto gl_decoder = GetGlDecoder(); | |
| 1365 gl_decoder->RestoreTextureUnitBindings(0); | |
| 1366 gl_decoder->RestoreActiveTexture(); | |
| 1367 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | |
| 1368 | |
| 1369 *service_id = texture_id; | |
| 1370 // To reduce context switching we used to create an unattached | |
|
liberato (no reviews please)
2016/05/26 16:59:19
comment is out of date.
| |
| 1371 // SurfaceTexture and attach it lazily in the context used to draw with it, | |
| 1372 // but detaching SurfaceTextures doesn't work reliably on a lot of devices. | |
| 1373 // Now we attach it here and and possibly context switch later. Fortunately, | |
| 1374 // if virtual contexts are in use, we don't have to context switch at all. | |
| 1375 return gfx::SurfaceTexture::Create(texture_id); | |
| 1376 } | |
| 1377 | |
| 1351 void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) { | 1378 void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) { |
| 1352 DCHECK(thread_checker_.CalledOnValidThread()); | 1379 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1353 TRACE_EVENT0("media", "AVDA::OnDestroyingSurface"); | 1380 TRACE_EVENT0("media", "AVDA::OnDestroyingSurface"); |
| 1354 DVLOG(1) << __FUNCTION__ << " surface_id: " << surface_id; | 1381 DVLOG(1) << __FUNCTION__ << " surface_id: " << surface_id; |
| 1355 | 1382 |
| 1356 if (surface_id != config_.surface_id) | 1383 if (surface_id != config_.surface_id) |
| 1357 return; | 1384 return; |
| 1358 | 1385 |
| 1359 // If we're currently asynchronously configuring a codec, it will be destroyed | 1386 // If we're currently asynchronously configuring a codec, it will be destroyed |
| 1360 // when configuration completes and it notices that |state_| has changed to | 1387 // when configuration completes and it notices that |state_| has changed to |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1594 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1621 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
| 1595 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1622 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
| 1596 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1623 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
| 1597 } | 1624 } |
| 1598 } | 1625 } |
| 1599 | 1626 |
| 1600 return capabilities; | 1627 return capabilities; |
| 1601 } | 1628 } |
| 1602 | 1629 |
| 1603 } // namespace media | 1630 } // namespace media |
| OLD | NEW |