| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // TODO(liberato): crbug.com/574948 . The OnFrameAvailable logic can be | 151 // TODO(liberato): crbug.com/574948 . The OnFrameAvailable logic can be |
| 152 // moved into AVDA, and we should wait for it before doing the copy. | 152 // moved into AVDA, and we should wait for it before doing the copy. |
| 153 // Because there were some test failures, we don't do this now but | 153 // Because there were some test failures, we don't do this now but |
| 154 // instead preserve the old behavior. | 154 // instead preserve the old behavior. |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool AndroidCopyingBackingStrategy::ArePicturesOverlayable() { | 157 bool AndroidCopyingBackingStrategy::ArePicturesOverlayable() { |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void AndroidCopyingBackingStrategy::UpdatePictureBufferSize( |
| 162 media::PictureBuffer* picture_buffer, |
| 163 const gfx::Size& new_size) { |
| 164 // This strategy uses 2D textures who's allocated memory is dependent on the |
| 165 // size. To update size in all places, we must: |
| 166 // 1) Update the PictureBuffer meta-data |
| 167 picture_buffer->set_size(new_size); |
| 168 |
| 169 // 2) Update the GL texture via glTexImage2D. This step assumes the caller |
| 170 // has made our GL context current. |
| 171 glBindTexture(GL_TEXTURE_2D, picture_buffer->texture_id()); |
| 172 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, new_size.width(), new_size.height(), |
| 173 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 174 state_provider_->GetGlDecoder()->RestoreActiveTextureUnitBinding( |
| 175 GL_TEXTURE_2D); |
| 176 |
| 177 // 3) Update the CHROMIUM Texture's size. |
| 178 gpu::gles2::TextureRef* texture_ref = |
| 179 state_provider_->GetTextureForPicture(*picture_buffer); |
| 180 RETURN_IF_NULL(texture_ref); |
| 181 gpu::gles2::TextureManager* texture_manager = |
| 182 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); |
| 183 RETURN_IF_NULL(texture_manager); |
| 184 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, |
| 185 new_size.width(), new_size.height(), 1, 0, |
| 186 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size)); |
| 187 } |
| 188 |
| 161 } // namespace content | 189 } // namespace content |
| OLD | NEW |