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

Side by Side Diff: media/gpu/android_deferred_rendering_backing_strategy.cc

Issue 2051633002: StreamTextureImages can now override a Texture's service id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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 | « gpu/ipc/service/stream_texture_android.cc ('k') | media/gpu/avda_codec_image.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 "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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 const media::PictureBuffer& picture_buffer, 128 const media::PictureBuffer& picture_buffer,
129 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { 129 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) {
130 gpu::gles2::TextureRef* texture_ref = 130 gpu::gles2::TextureRef* texture_ref =
131 state_provider_->GetTextureForPicture(picture_buffer); 131 state_provider_->GetTextureForPicture(picture_buffer);
132 RETURN_IF_NULL(texture_ref); 132 RETURN_IF_NULL(texture_ref);
133 133
134 gpu::gles2::TextureManager* texture_manager = 134 gpu::gles2::TextureManager* texture_manager =
135 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); 135 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
136 RETURN_IF_NULL(texture_manager); 136 RETURN_IF_NULL(texture_manager);
137 137
138 // Default to zero which will clear the stream texture service id if one was
139 // previously set.
140 GLuint stream_texture_service_id = 0;
138 if (image) { 141 if (image) {
139 // Also set the parameters for the level if we're not clearing 142 // Override the texture's service_id, so that it will use the one that is
140 // the image. 143 // attached to the SurfaceTexture.
144 stream_texture_service_id = shared_state_->surface_texture_service_id();
145 DCHECK_NE(stream_texture_service_id, 0u);
146
147 // Also set the parameters for the level if we're not clearing the image.
141 const gfx::Size size = state_provider_->GetSize(); 148 const gfx::Size size = state_provider_->GetSize();
142 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, 149 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA,
143 size.width(), size.height(), 1, 0, GL_RGBA, 150 size.width(), size.height(), 1, 0, GL_RGBA,
144 GL_UNSIGNED_BYTE, gfx::Rect()); 151 GL_UNSIGNED_BYTE, gfx::Rect());
145 152
146 // Override the texture's service_id, so that it will use the one that
147 // will be / is attached to the SurfaceTexture.
148 DCHECK(shared_state_->surface_texture_service_id());
149 texture_ref->texture()->SetUnownedServiceId(
150 shared_state_->surface_texture_service_id());
151
152 static_cast<AVDACodecImage*>(image.get()) 153 static_cast<AVDACodecImage*>(image.get())
153 ->set_texture(texture_ref->texture()); 154 ->set_texture(texture_ref->texture());
154 } else {
155 // Clear the unowned service_id, so that this texture is no longer going
156 // to depend on the surface texture at all.
157 texture_ref->texture()->SetUnownedServiceId(0);
158 } 155 }
159 156
160 // For SurfaceTexture we set the image to UNBOUND so that the implementation 157 // For SurfaceTexture we set the image to UNBOUND so that the implementation
161 // will call CopyTexImage, which is where AVDACodecImage updates the 158 // will call CopyTexImage, which is where AVDACodecImage updates the
162 // SurfaceTexture to the right frame. 159 // SurfaceTexture to the right frame.
163 // For SurfaceView we set the image to be BOUND because ScheduleOverlayPlane 160 // For SurfaceView we set the image to be BOUND because ScheduleOverlayPlane
164 // expects it. If something tries to sample from this texture it won't work, 161 // expects it. If something tries to sample from this texture it won't work,
165 // but there's no way to sample from a SurfaceView anyway, so it doesn't 162 // but there's no way to sample from a SurfaceView anyway, so it doesn't
166 // matter. The only way to use this texture is to schedule it as an overlay. 163 // matter. The only way to use this texture is to schedule it as an overlay.
167 const gpu::gles2::Texture::ImageState image_state = 164 const gpu::gles2::Texture::ImageState image_state =
168 surface_texture_ ? gpu::gles2::Texture::UNBOUND 165 surface_texture_ ? gpu::gles2::Texture::UNBOUND
169 : gpu::gles2::Texture::BOUND; 166 : gpu::gles2::Texture::BOUND;
170 texture_manager->SetLevelStreamTextureImage(texture_ref, GetTextureTarget(), 167 texture_manager->SetLevelStreamTextureImage(texture_ref, GetTextureTarget(),
171 0, image.get(), image_state); 168 0, image.get(), image_state,
169 stream_texture_service_id);
172 } 170 }
173 171
174 void AndroidDeferredRenderingBackingStrategy::UseCodecBufferForPictureBuffer( 172 void AndroidDeferredRenderingBackingStrategy::UseCodecBufferForPictureBuffer(
175 int32_t codec_buf_index, 173 int32_t codec_buf_index,
176 const media::PictureBuffer& picture_buffer) { 174 const media::PictureBuffer& picture_buffer) {
177 // Make sure that the decoder is available. 175 // Make sure that the decoder is available.
178 RETURN_IF_NULL(state_provider_->GetGlDecoder()); 176 RETURN_IF_NULL(state_provider_->GetGlDecoder());
179 177
180 // Notify the AVDACodecImage for picture_buffer that it should use the 178 // Notify the AVDACodecImage for picture_buffer that it should use the
181 // decoded buffer codec_buf_index to render this frame. 179 // decoded buffer codec_buf_index to render this frame.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 model.find("sm-t285") != std::string::npos || 432 model.find("sm-t285") != std::string::npos ||
435 model.find("sm-j320") != std::string::npos) 433 model.find("sm-j320") != std::string::npos)
436 return false; 434 return false;
437 } 435 }
438 } 436 }
439 437
440 return true; 438 return true;
441 } 439 }
442 440
443 } // namespace media 441 } // namespace media
OLDNEW
« no previous file with comments | « gpu/ipc/service/stream_texture_android.cc ('k') | media/gpu/avda_codec_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698