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

Unified Diff: content/common/gpu/media/android_copying_backing_strategy.cc

Issue 1639963002: AndroidVideoDecodeAccelerator can now render to a SurfaceView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
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..67e886048dfa06070682cb124667109a168a5a90 100644
--- a/content/common/gpu/media/android_copying_backing_strategy.cc
+++ b/content/common/gpu/media/android_copying_backing_strategy.cc
@@ -22,33 +22,23 @@ 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;
-}
-
-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() {
+gfx::ScopedJavaSurface AndroidCopyingBackingStrategy::Initialize(
+ int surface_view_id) {
+ if (surface_view_id != media::VideoDecodeAccelerator::Config::kNoSurfaceID) {
+ LOG(ERROR) << "The copying strategy should not be initialized with a "
+ "surface id.";
+ return gfx::ScopedJavaSurface();
+ }
+
+ // 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 +47,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 +155,8 @@ void AndroidCopyingBackingStrategy::OnFrameAvailable() {
// instead preserve the old behavior.
}
+bool AndroidCopyingBackingStrategy::ArePicturesOverlayable() {
+ return false;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698