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