| 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->SetMediaCodec(codec); |
| 50 } |
| 51 |
| 52 void AVDASharedState::SetImageForPicture(int picture_buffer_id, |
| 53 AVDACodecImage* image) { |
| 54 DCHECK(codec_images_.find(picture_buffer_id) == codec_images_.end()); |
| 55 codec_images_[picture_buffer_id] = image; |
| 56 } |
| 57 |
| 58 AVDACodecImage* AVDASharedState::GetImageForPicture( |
| 59 int picture_buffer_id) const { |
| 60 auto it = codec_images_.find(picture_buffer_id); |
| 61 return it == codec_images_.end() ? nullptr : it->second; |
| 62 } |
| 63 |
| 64 void AVDASharedState::EraseImage(const AVDACodecImage* image) { |
| 65 for (auto it = codec_images_.begin(); it != codec_images_.end(); ++it) { |
| 66 if (it->second == image) { |
| 67 codec_images_.erase(it); |
| 68 return; |
| 69 } |
| 70 } |
| 71 } |
| 72 |
| 46 } // namespace content | 73 } // namespace content |
| OLD | NEW |