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

Side by Side Diff: content/common/gpu/media/android_copying_backing_strategy.cc

Issue 1814703002: AVDA: Use the SurfaceTexture matrix when copying on destruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | content/common/gpu/media/android_deferred_rendering_backing_strategy.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/common/gpu/media/android_copying_backing_strategy.h" 5 #include "content/common/gpu/media/android_copying_backing_strategy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/common/gpu/media/avda_return_on_failure.h" 10 #include "content/common/gpu/media/avda_return_on_failure.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 media_codec_->ReleaseOutputBuffer(codec_buf_index, true); 105 media_codec_->ReleaseOutputBuffer(codec_buf_index, true);
106 } 106 }
107 107
108 { 108 {
109 TRACE_EVENT0("media", "AVDA::UpdateTexImage"); 109 TRACE_EVENT0("media", "AVDA::UpdateTexImage");
110 surface_texture_->UpdateTexImage(); 110 surface_texture_->UpdateTexImage();
111 } 111 }
112 112
113 float transform_matrix[16]; 113 float transform_matrix[16];
114 surface_texture_->GetTransformMatrix(transform_matrix); 114 surface_texture_->GetTransformMatrix(transform_matrix);
115 // add y-flip to correct UV coordinate systems.
116 transform_matrix[13] += transform_matrix[5];
117 transform_matrix[5] = -transform_matrix[5];
118 115
119 uint32_t picture_buffer_texture_id = picture_buffer.texture_id(); 116 uint32_t picture_buffer_texture_id = picture_buffer.texture_id();
120 117
121 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 118 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
122 // needed because it takes 10s of milliseconds to initialize. 119 // needed because it takes 10s of milliseconds to initialize.
123 if (!copier_) { 120 if (!copier_) {
124 copier_.reset(new gpu::CopyTextureCHROMIUMResourceManager()); 121 copier_.reset(new gpu::CopyTextureCHROMIUMResourceManager());
125 copier_->Initialize(state_provider_->GetGlDecoder().get(), 122 copier_->Initialize(state_provider_->GetGlDecoder().get(),
126 state_provider_->GetGlDecoder()->GetContextGroup()-> 123 state_provider_->GetGlDecoder()->GetContextGroup()->
127 feature_info()->feature_flags()); 124 feature_info()->feature_flags());
128 } 125 }
129 126
130 // Here, we copy |surface_texture_id_| to the picture buffer instead of 127 // Here, we copy |surface_texture_id_| to the picture buffer instead of
131 // setting new texture to |surface_texture_| by calling attachToGLContext() 128 // setting new texture to |surface_texture_| by calling attachToGLContext()
132 // because: 129 // because:
133 // 1. Once we call detachFrameGLContext(), it deletes the texture previously 130 // 1. Once we call detachFrameGLContext(), it deletes the texture previously
134 // attached. 131 // attached.
135 // 2. SurfaceTexture requires us to apply a transform matrix when we show 132 // 2. SurfaceTexture requires us to apply a transform matrix when we show
136 // the texture. 133 // the texture.
137 copier_->DoCopyTextureWithTransform( 134 copier_->DoCopyTextureWithTransform(
138 state_provider_->GetGlDecoder().get(), GL_TEXTURE_EXTERNAL_OES, 135 state_provider_->GetGlDecoder().get(), GL_TEXTURE_EXTERNAL_OES,
139 surface_texture_id_, GL_TEXTURE_2D, picture_buffer_texture_id, 136 surface_texture_id_, GL_TEXTURE_2D, picture_buffer_texture_id,
140 state_provider_->GetSize().width(), state_provider_->GetSize().height(), 137 state_provider_->GetSize().width(), state_provider_->GetSize().height(),
141 false, false, false, transform_matrix); 138 true, false, false, transform_matrix);
142 } 139 }
143 140
144 void AndroidCopyingBackingStrategy::CodecChanged( 141 void AndroidCopyingBackingStrategy::CodecChanged(
145 media::VideoCodecBridge* codec, 142 media::VideoCodecBridge* codec,
146 const AndroidVideoDecodeAccelerator::OutputBufferMap&) { 143 const AndroidVideoDecodeAccelerator::OutputBufferMap&) {
147 media_codec_ = codec; 144 media_codec_ = codec;
148 } 145 }
149 146
150 void AndroidCopyingBackingStrategy::OnFrameAvailable() { 147 void AndroidCopyingBackingStrategy::OnFrameAvailable() {
151 // TODO(liberato): crbug.com/574948 . The OnFrameAvailable logic can be 148 // TODO(liberato): crbug.com/574948 . The OnFrameAvailable logic can be
(...skipping 28 matching lines...) Expand all
180 RETURN_IF_NULL(texture_ref); 177 RETURN_IF_NULL(texture_ref);
181 gpu::gles2::TextureManager* texture_manager = 178 gpu::gles2::TextureManager* texture_manager =
182 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); 179 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
183 RETURN_IF_NULL(texture_manager); 180 RETURN_IF_NULL(texture_manager);
184 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, 181 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA,
185 new_size.width(), new_size.height(), 1, 0, 182 new_size.width(), new_size.height(), 1, 0,
186 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size)); 183 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size));
187 } 184 }
188 185
189 } // namespace content 186 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/android_deferred_rendering_backing_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698