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