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

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

Issue 1750213002: Fix Android black frames from MSE config changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback: Adding UpdatePictureBufferSize to strategy 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
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 // Here, we copy |surface_texture_id_| to the picture buffer instead of 129 // Here, we copy |surface_texture_id_| to the picture buffer instead of
130 // setting new texture to |surface_texture_| by calling attachToGLContext() 130 // setting new texture to |surface_texture_| by calling attachToGLContext()
131 // because: 131 // because:
132 // 1. Once we call detachFrameGLContext(), it deletes the texture previously 132 // 1. Once we call detachFrameGLContext(), it deletes the texture previously
133 // attached. 133 // attached.
134 // 2. SurfaceTexture requires us to apply a transform matrix when we show 134 // 2. SurfaceTexture requires us to apply a transform matrix when we show
135 // the texture. 135 // the texture.
136 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 136 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
137 // instead of using default matrix crbug.com/226218. 137 // instead of using default matrix crbug.com/226218.
138 copier_->DoCopyTextureWithTransform( 138 copier_->DoCopyTextureWithTransform(
liberato (no reviews please) 2016/03/02 16:50:36 the problem might be here. have you checked that
chcunningham 2016/03/02 21:46:19 Added this log just now. I sadly cant check it unt
139 state_provider_->GetGlDecoder().get(), GL_TEXTURE_EXTERNAL_OES, 139 state_provider_->GetGlDecoder().get(), GL_TEXTURE_EXTERNAL_OES,
140 surface_texture_id_, GL_TEXTURE_2D, picture_buffer_texture_id, 140 surface_texture_id_, GL_TEXTURE_2D, picture_buffer_texture_id,
141 state_provider_->GetSize().width(), state_provider_->GetSize().height(), 141 state_provider_->GetSize().width(), state_provider_->GetSize().height(),
142 false, false, false, kIdentityMatrix); 142 false, false, false, kIdentityMatrix);
143 } 143 }
144 144
145 void AndroidCopyingBackingStrategy::CodecChanged( 145 void AndroidCopyingBackingStrategy::CodecChanged(
146 media::VideoCodecBridge* codec, 146 media::VideoCodecBridge* codec,
147 const AndroidVideoDecodeAccelerator::OutputBufferMap&) { 147 const AndroidVideoDecodeAccelerator::OutputBufferMap&) {
148 media_codec_ = codec; 148 media_codec_ = codec;
149 } 149 }
150 150
151 void AndroidCopyingBackingStrategy::OnFrameAvailable() { 151 void AndroidCopyingBackingStrategy::OnFrameAvailable() {
152 // TODO(liberato): crbug.com/574948 . The OnFrameAvailable logic can be 152 // TODO(liberato): crbug.com/574948 . The OnFrameAvailable logic can be
153 // moved into AVDA, and we should wait for it before doing the copy. 153 // moved into AVDA, and we should wait for it before doing the copy.
154 // Because there were some test failures, we don't do this now but 154 // Because there were some test failures, we don't do this now but
155 // instead preserve the old behavior. 155 // instead preserve the old behavior.
156 } 156 }
157 157
158 bool AndroidCopyingBackingStrategy::ArePicturesOverlayable() { 158 bool AndroidCopyingBackingStrategy::ArePicturesOverlayable() {
159 return false; 159 return false;
160 } 160 }
161 161
162 void AndroidCopyingBackingStrategy::UpdatePictureBufferSize(
163 media::PictureBuffer* picture_buffer,
164 const gfx::Size& new_size) {
165 LOG(ERROR) << __FUNCTION__ << " from:" << picture_buffer->size().ToString()
166 << " to:" << new_size.ToString();
167
168 // This strategy uses 2D textures who's allocated memory is dependent on the
169 // size. To update size in all places, we must:
170 // 1) Update the PictureBuffer meta-data
171 picture_buffer->set_size(new_size);
172
173 // 2) Update the GL texture via glTextImage2D. This step assumes the caller
174 // has made our GL context current.
175 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, new_size.width(), new_size.height(),
176 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
177
178 // 3) Update the CHROMIUM Texture's size.
179 gpu::gles2::TextureRef* texture_ref =
180 state_provider_->GetTextureForPicture(*picture_buffer);
181 RETURN_IF_NULL(texture_ref);
182 gpu::gles2::TextureManager* texture_manager =
183 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
184 RETURN_IF_NULL(texture_manager);
185 texture_manager->SetLevelInfo(
186 texture_ref, GetTextureTarget(), 0, GL_RGBA, new_size.width(),
187 new_size.height(), 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
188 gfx::Rect(new_size.width(),
189 new_size.height())); // TODO CONSIDER USING EMPTY RECT
190 }
191
162 } // namespace content 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698