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

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

Issue 1751323002: Allow multiple texture ids per picture buffer. (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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 115
116 uint32_t picture_buffer_texture_id = picture_buffer.texture_id(); 116 DCHECK_LE(1u, picture_buffer.texture_ids().size());
117 uint32_t picture_buffer_texture_id = picture_buffer.texture_ids()[0];
117 118
118 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 119 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
119 // needed because it takes 10s of milliseconds to initialize. 120 // needed because it takes 10s of milliseconds to initialize.
120 if (!copier_) { 121 if (!copier_) {
121 copier_.reset(new gpu::CopyTextureCHROMIUMResourceManager()); 122 copier_.reset(new gpu::CopyTextureCHROMIUMResourceManager());
122 copier_->Initialize(state_provider_->GetGlDecoder().get(), 123 copier_->Initialize(state_provider_->GetGlDecoder().get(),
123 state_provider_->GetGlDecoder()->GetContextGroup()-> 124 state_provider_->GetGlDecoder()->GetContextGroup()->
124 feature_info()->feature_flags()); 125 feature_info()->feature_flags());
125 } 126 }
126 127
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void AndroidCopyingBackingStrategy::UpdatePictureBufferSize( 159 void AndroidCopyingBackingStrategy::UpdatePictureBufferSize(
159 media::PictureBuffer* picture_buffer, 160 media::PictureBuffer* picture_buffer,
160 const gfx::Size& new_size) { 161 const gfx::Size& new_size) {
161 // This strategy uses 2D textures who's allocated memory is dependent on the 162 // This strategy uses 2D textures who's allocated memory is dependent on the
162 // size. To update size in all places, we must: 163 // size. To update size in all places, we must:
163 // 1) Update the PictureBuffer meta-data 164 // 1) Update the PictureBuffer meta-data
164 picture_buffer->set_size(new_size); 165 picture_buffer->set_size(new_size);
165 166
166 // 2) Update the GL texture via glTexImage2D. This step assumes the caller 167 // 2) Update the GL texture via glTexImage2D. This step assumes the caller
167 // has made our GL context current. 168 // has made our GL context current.
168 glBindTexture(GL_TEXTURE_2D, picture_buffer->texture_id()); 169 DCHECK_LE(1u, picture_buffer->texture_ids().size());
170 glBindTexture(GL_TEXTURE_2D, picture_buffer->texture_ids()[0]);
169 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, new_size.width(), new_size.height(), 171 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, new_size.width(), new_size.height(),
170 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); 172 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
171 state_provider_->GetGlDecoder()->RestoreActiveTextureUnitBinding( 173 state_provider_->GetGlDecoder()->RestoreActiveTextureUnitBinding(
172 GL_TEXTURE_2D); 174 GL_TEXTURE_2D);
173 175
174 // 3) Update the CHROMIUM Texture's size. 176 // 3) Update the CHROMIUM Texture's size.
175 gpu::gles2::TextureRef* texture_ref = 177 gpu::gles2::TextureRef* texture_ref =
176 state_provider_->GetTextureForPicture(*picture_buffer); 178 state_provider_->GetTextureForPicture(*picture_buffer);
177 RETURN_IF_NULL(texture_ref); 179 RETURN_IF_NULL(texture_ref);
178 gpu::gles2::TextureManager* texture_manager = 180 gpu::gles2::TextureManager* texture_manager =
179 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); 181 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
180 RETURN_IF_NULL(texture_manager); 182 RETURN_IF_NULL(texture_manager);
181 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, 183 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA,
182 new_size.width(), new_size.height(), 1, 0, 184 new_size.width(), new_size.height(), 1, 0,
183 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size)); 185 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size));
184 } 186 }
185 187
186 } // namespace content 188 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698