| 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/avda_shared_state.h" | 5 #include "content/common/gpu/media/avda_shared_state.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "content/common/gpu/media/avda_codec_image.h" |
| 8 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
| 9 #include "ui/gl/scoped_make_current.h" | 10 #include "ui/gl/scoped_make_current.h" |
| 10 | 11 |
| 11 namespace content { | 12 namespace content { |
| 12 | 13 |
| 13 AVDASharedState::AVDASharedState() | 14 AVDASharedState::AVDASharedState() |
| 14 : surface_texture_service_id_(0), | 15 : surface_texture_service_id_(0), |
| 15 frame_available_event_(false, false), | 16 frame_available_event_(false, false), |
| 16 surface_texture_is_attached_(false) {} | 17 surface_texture_is_attached_(false) {} |
| 17 | 18 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 36 | 37 |
| 37 surface_texture_is_attached_ = true; | 38 surface_texture_is_attached_ = true; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void AVDASharedState::DidDetachSurfaceTexture() { | 41 void AVDASharedState::DidDetachSurfaceTexture() { |
| 41 context_ = nullptr; | 42 context_ = nullptr; |
| 42 surface_ = nullptr; | 43 surface_ = nullptr; |
| 43 surface_texture_is_attached_ = false; | 44 surface_texture_is_attached_ = false; |
| 44 } | 45 } |
| 45 | 46 |
| 47 void AVDASharedState::CodecChanged(media::MediaCodecBridge* codec) { |
| 48 for (auto& image_kv : codec_images_) |
| 49 image_kv.second->CodecChanged(codec); |
| 50 } |
| 51 |
| 52 void AVDASharedState::SetImageForPicture(int picture_buffer_id, |
| 53 AVDACodecImage* image) { |
| 54 if (!image) { |
| 55 DCHECK(codec_images_.find(picture_buffer_id) != codec_images_.end()); |
| 56 codec_images_.erase(picture_buffer_id); |
| 57 return; |
| 58 } |
| 59 |
| 60 DCHECK(codec_images_.find(picture_buffer_id) == codec_images_.end()); |
| 61 codec_images_[picture_buffer_id] = image; |
| 62 } |
| 63 |
| 64 AVDACodecImage* AVDASharedState::GetImageForPicture( |
| 65 int picture_buffer_id) const { |
| 66 auto it = codec_images_.find(picture_buffer_id); |
| 67 return it == codec_images_.end() ? nullptr : it->second; |
| 68 } |
| 69 |
| 46 } // namespace content | 70 } // namespace content |
| OLD | NEW |