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

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

Issue 2049053004: AVDACodecImages keep their backing SurfaceTexture alive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: fixed gl->gfx renames Created 4 years, 6 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
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_image.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 1378
1379 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size()); 1379 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size());
1380 gpu::gles2::TextureRef* texture_ref = 1380 gpu::gles2::TextureRef* texture_ref =
1381 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]); 1381 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]);
1382 RETURN_ON_FAILURE(this, texture_manager, "Null texture_ref", ILLEGAL_STATE, 1382 RETURN_ON_FAILURE(this, texture_manager, "Null texture_ref", ILLEGAL_STATE,
1383 nullptr); 1383 nullptr);
1384 1384
1385 return texture_ref; 1385 return texture_ref;
1386 } 1386 }
1387 1387
1388 scoped_refptr<gfx::SurfaceTexture>
1389 AndroidVideoDecodeAccelerator::CreateAttachedSurfaceTexture(
1390 GLuint* service_id) {
1391 GLuint texture_id;
1392 glGenTextures(1, &texture_id);
1393
1394 glActiveTexture(GL_TEXTURE0);
1395 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
1396 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1397 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1398 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1399 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1400
1401 auto gl_decoder = GetGlDecoder();
1402 gl_decoder->RestoreTextureUnitBindings(0);
1403 gl_decoder->RestoreActiveTexture();
1404 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
1405
1406 *service_id = texture_id;
1407 // Previously, to reduce context switching, we used to create an unattached
1408 // SurfaceTexture and attach it lazily in the compositor's context. But that
1409 // was flaky because SurfaceTexture#detachFromGLContext() is buggy on a lot of
1410 // devices. Now we attach it to the current context, which means we might have
1411 // to context switch later to call updateTexImage(). Fortunately, if virtual
1412 // contexts are in use, we won't have to context switch.
1413 return gfx::SurfaceTexture::Create(texture_id);
1414 }
1415
1388 void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) { 1416 void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) {
1389 DCHECK(thread_checker_.CalledOnValidThread()); 1417 DCHECK(thread_checker_.CalledOnValidThread());
1390 TRACE_EVENT0("media", "AVDA::OnDestroyingSurface"); 1418 TRACE_EVENT0("media", "AVDA::OnDestroyingSurface");
1391 DVLOG(1) << __FUNCTION__ << " surface_id: " << surface_id; 1419 DVLOG(1) << __FUNCTION__ << " surface_id: " << surface_id;
1392 1420
1393 if (surface_id != config_.surface_id) 1421 if (surface_id != config_.surface_id)
1394 return; 1422 return;
1395 1423
1396 // If we're currently asynchronously configuring a codec, it will be destroyed 1424 // If we're currently asynchronously configuring a codec, it will be destroyed
1397 // when configuration completes and it notices that |state_| has changed to 1425 // when configuration completes and it notices that |state_| has changed to
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { 1659 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) {
1632 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: 1660 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities::
1633 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; 1661 SUPPORTS_EXTERNAL_OUTPUT_SURFACE;
1634 } 1662 }
1635 } 1663 }
1636 1664
1637 return capabilities; 1665 return capabilities;
1638 } 1666 }
1639 1667
1640 } // namespace media 1668 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698