OLD | NEW |
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 "media/gpu/android_deferred_rendering_backing_strategy.h" | 5 #include "media/gpu/android_deferred_rendering_backing_strategy.h" |
6 | 6 |
7 #include <EGL/egl.h> | 7 #include <EGL/egl.h> |
8 #include <EGL/eglext.h> | 8 #include <EGL/eglext.h> |
9 | 9 |
10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const media::PictureBuffer& picture_buffer, | 138 const media::PictureBuffer& picture_buffer, |
139 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { | 139 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { |
140 gpu::gles2::TextureRef* texture_ref = | 140 gpu::gles2::TextureRef* texture_ref = |
141 state_provider_->GetTextureForPicture(picture_buffer); | 141 state_provider_->GetTextureForPicture(picture_buffer); |
142 RETURN_IF_NULL(texture_ref); | 142 RETURN_IF_NULL(texture_ref); |
143 | 143 |
144 gpu::gles2::TextureManager* texture_manager = | 144 gpu::gles2::TextureManager* texture_manager = |
145 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); | 145 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); |
146 RETURN_IF_NULL(texture_manager); | 146 RETURN_IF_NULL(texture_manager); |
147 | 147 |
| 148 // Default to zero which will clear the stream texture service id if one was |
| 149 // previously set. |
| 150 GLuint stream_texture_service_id = 0; |
148 if (image) { | 151 if (image) { |
149 // Also set the parameters for the level if we're not clearing | 152 // Override the texture's service_id, so that it will use the one that is |
150 // the image. | 153 // attached to the SurfaceTexture. |
| 154 stream_texture_service_id = shared_state_->surface_texture_service_id(); |
| 155 DCHECK_NE(stream_texture_service_id, 0u); |
| 156 |
| 157 // Also set the parameters for the level if we're not clearing the image. |
151 const gfx::Size size = state_provider_->GetSize(); | 158 const gfx::Size size = state_provider_->GetSize(); |
152 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, | 159 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, |
153 size.width(), size.height(), 1, 0, GL_RGBA, | 160 size.width(), size.height(), 1, 0, GL_RGBA, |
154 GL_UNSIGNED_BYTE, gfx::Rect()); | 161 GL_UNSIGNED_BYTE, gfx::Rect()); |
155 | 162 |
156 // Override the texture's service_id, so that it will use the one that | |
157 // will be / is attached to the SurfaceTexture. | |
158 DCHECK(shared_state_->surface_texture_service_id()); | |
159 texture_ref->texture()->SetUnownedServiceId( | |
160 shared_state_->surface_texture_service_id()); | |
161 | |
162 static_cast<AVDACodecImage*>(image.get()) | 163 static_cast<AVDACodecImage*>(image.get()) |
163 ->set_texture(texture_ref->texture()); | 164 ->set_texture(texture_ref->texture()); |
164 } else { | |
165 // Clear the unowned service_id, so that this texture is no longer going | |
166 // to depend on the surface texture at all. | |
167 texture_ref->texture()->SetUnownedServiceId(0); | |
168 } | 165 } |
169 | 166 |
170 // For SurfaceTexture we set the image to UNBOUND so that the implementation | 167 // For SurfaceTexture we set the image to UNBOUND so that the implementation |
171 // will call CopyTexImage, which is where AVDACodecImage updates the | 168 // will call CopyTexImage, which is where AVDACodecImage updates the |
172 // SurfaceTexture to the right frame. | 169 // SurfaceTexture to the right frame. |
173 // For SurfaceView we set the image to be BOUND because ScheduleOverlayPlane | 170 // For SurfaceView we set the image to be BOUND because ScheduleOverlayPlane |
174 // expects it. If something tries to sample from this texture it won't work, | 171 // expects it. If something tries to sample from this texture it won't work, |
175 // but there's no way to sample from a SurfaceView anyway, so it doesn't | 172 // but there's no way to sample from a SurfaceView anyway, so it doesn't |
176 // matter. The only way to use this texture is to schedule it as an overlay. | 173 // matter. The only way to use this texture is to schedule it as an overlay. |
177 const gpu::gles2::Texture::ImageState image_state = | 174 const gpu::gles2::Texture::ImageState image_state = |
178 surface_texture_ ? gpu::gles2::Texture::UNBOUND | 175 surface_texture_ ? gpu::gles2::Texture::UNBOUND |
179 : gpu::gles2::Texture::BOUND; | 176 : gpu::gles2::Texture::BOUND; |
180 texture_manager->SetLevelStreamTextureImage(texture_ref, GetTextureTarget(), | 177 texture_manager->SetLevelStreamTextureImage(texture_ref, GetTextureTarget(), |
181 0, image.get(), image_state); | 178 0, image.get(), image_state, |
| 179 stream_texture_service_id); |
182 } | 180 } |
183 | 181 |
184 void AndroidDeferredRenderingBackingStrategy::UseCodecBufferForPictureBuffer( | 182 void AndroidDeferredRenderingBackingStrategy::UseCodecBufferForPictureBuffer( |
185 int32_t codec_buf_index, | 183 int32_t codec_buf_index, |
186 const media::PictureBuffer& picture_buffer) { | 184 const media::PictureBuffer& picture_buffer) { |
187 // Make sure that the decoder is available. | 185 // Make sure that the decoder is available. |
188 RETURN_IF_NULL(state_provider_->GetGlDecoder()); | 186 RETURN_IF_NULL(state_provider_->GetGlDecoder()); |
189 | 187 |
190 // Notify the AVDACodecImage for picture_buffer that it should use the | 188 // Notify the AVDACodecImage for picture_buffer that it should use the |
191 // decoded buffer codec_buf_index to render this frame. | 189 // decoded buffer codec_buf_index to render this frame. |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 model.find("sm-t285") != std::string::npos || | 442 model.find("sm-t285") != std::string::npos || |
445 model.find("sm-j320") != std::string::npos) | 443 model.find("sm-j320") != std::string::npos) |
446 return false; | 444 return false; |
447 } | 445 } |
448 } | 446 } |
449 | 447 |
450 return true; | 448 return true; |
451 } | 449 } |
452 | 450 |
453 } // namespace media | 451 } // namespace media |
OLD | NEW |