| 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 "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
| 8 #include "ui/gl/scoped_make_current.h" | |
| 9 | 8 |
| 10 namespace content { | 9 namespace content { |
| 11 | 10 |
| 12 AVDASharedState::AVDASharedState() | 11 AVDASharedState::AVDASharedState() |
| 13 : surface_texture_service_id_(0), | 12 : surface_texture_service_id_(0), |
| 14 frame_available_event_(false, false), | 13 frame_available_event_(false, false), |
| 15 surface_texture_is_attached_(false) {} | 14 surface_texture_is_attached_(false) {} |
| 16 | 15 |
| 17 AVDASharedState::~AVDASharedState() {} | 16 AVDASharedState::~AVDASharedState() { |
| 17 if (surface_texture_service_id_ != 0) { |
| 18 delete_texture_cb_.Run(surface_texture_service_id_); |
| 19 } |
| 20 } |
| 21 |
| 22 void AVDASharedState::SetSurfaceTextureServiceID( |
| 23 GLuint id, |
| 24 const base::Callback<void(GLuint)>& delete_texture_cb) { |
| 25 surface_texture_service_id_ = id; |
| 26 delete_texture_cb_ = delete_texture_cb; |
| 27 } |
| 18 | 28 |
| 19 void AVDASharedState::SignalFrameAvailable() { | 29 void AVDASharedState::SignalFrameAvailable() { |
| 20 frame_available_event_.Signal(); | 30 frame_available_event_.Signal(); |
| 21 } | 31 } |
| 22 | 32 |
| 23 void AVDASharedState::WaitForFrameAvailable() { | 33 void AVDASharedState::WaitForFrameAvailable() { |
| 24 frame_available_event_.Wait(); | 34 frame_available_event_.Wait(); |
| 25 } | 35 } |
| 26 | 36 |
| 27 void AVDASharedState::did_attach_surface_texture() { | 37 void AVDASharedState::DidAttachSurfaceTexture() { |
| 28 context_ = gfx::GLContext::GetCurrent(); | 38 context_ = gfx::GLContext::GetCurrent(); |
| 29 surface_ = gfx::GLSurface::GetCurrent(); | 39 surface_ = gfx::GLSurface::GetCurrent(); |
| 30 DCHECK(context_); | 40 DCHECK(context_); |
| 31 DCHECK(surface_); | 41 DCHECK(surface_); |
| 32 | 42 |
| 33 surface_texture_is_attached_ = true; | 43 surface_texture_is_attached_ = true; |
| 34 } | 44 } |
| 35 | 45 |
| 36 } // namespace content | 46 } // namespace content |
| OLD | NEW |