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

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

Issue 1370443007: Move SurfaceTexture construction to BackingStrategy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased. Created 5 years, 3 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 7118335138b37e560a60bef30993f0234103b554..b0a37fee2887d24cb876b6d079f454c21aebdf05 100644
--- a/content/common/gpu/media/android_copying_backing_strategy.cc
+++ b/content/common/gpu/media/android_copying_backing_strategy.cc
@@ -29,7 +29,8 @@ const static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f, 1.0f};
AndroidCopyingBackingStrategy::AndroidCopyingBackingStrategy()
- : state_provider_(nullptr) {}
+ : state_provider_(nullptr)
+ , surface_texture_id_(0) {}
AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {}
@@ -42,6 +43,9 @@ void AndroidCopyingBackingStrategy::Cleanup() {
DCHECK(state_provider_->ThreadChecker().CalledOnValidThread());
if (copier_)
copier_->Destroy();
+
+ if (surface_texture_id_)
+ glDeleteTextures(1, &surface_texture_id_);
}
uint32 AndroidCopyingBackingStrategy::GetNumPictureBuffers() const {
@@ -52,7 +56,25 @@ uint32 AndroidCopyingBackingStrategy::GetTextureTarget() const {
return GL_TEXTURE_2D;
}
-void AndroidCopyingBackingStrategy::AssignCurrentSurfaceToPictureBuffer(
+scoped_refptr<gfx::SurfaceTexture>
+AndroidCopyingBackingStrategy::CreateSurfaceTexture() {
+ glGenTextures(1, &surface_texture_id_);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, surface_texture_id_);
+
+ glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ 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 surface_texture_;
+}
+
+void AndroidCopyingBackingStrategy::UseCodecBufferForPictureBuffer(
int32 codec_buf_index,
const media::PictureBuffer& picture_buffer) {
// Make sure that the decoder is available.
@@ -83,14 +105,13 @@ void AndroidCopyingBackingStrategy::AssignCurrentSurfaceToPictureBuffer(
true);
}
- gfx::SurfaceTexture* surface_texture = state_provider_->GetSurfaceTexture();
{
TRACE_EVENT0("media", "AVDA::UpdateTexImage");
- surface_texture->UpdateTexImage();
+ surface_texture_->UpdateTexImage();
}
float transfrom_matrix[16];
- surface_texture->GetTransformMatrix(transfrom_matrix);
+ surface_texture_->GetTransformMatrix(transfrom_matrix);
uint32 picture_buffer_texture_id = picture_buffer.texture_id();
@@ -112,7 +133,7 @@ void AndroidCopyingBackingStrategy::AssignCurrentSurfaceToPictureBuffer(
// instead of using default matrix crbug.com/226218.
copier_->DoCopyTextureWithTransform(
state_provider_->GetGlDecoder(), GL_TEXTURE_EXTERNAL_OES,
- state_provider_->GetSurfaceTextureId(), picture_buffer_texture_id,
+ surface_texture_id_, picture_buffer_texture_id,
state_provider_->GetSize().width(), state_provider_->GetSize().height(),
false, false, false, kIdentityMatrix);
}

Powered by Google App Engine
This is Rietveld 408576698