Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: media/gpu/avda_shared_state.cc

Issue 2351293003: Relocate SurfaceTexture usage from AVDA GLImage into shared state. (Closed)
Patch Set: Unflip default matrix. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/gpu/avda_shared_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/gpu/avda_shared_state.h" 5 #include "media/gpu/avda_shared_state.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "media/gpu/avda_codec_image.h" 9 #include "media/gpu/avda_codec_image.h"
10 #include "ui/gl/android/surface_texture.h" 10 #include "ui/gl/android/surface_texture.h"
11 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
12 #include "ui/gl/scoped_make_current.h" 12 #include "ui/gl/scoped_make_current.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 AVDASharedState::AVDASharedState() 16 AVDASharedState::AVDASharedState()
17 : surface_texture_service_id_(0), 17 : surface_texture_service_id_(0),
18 frame_available_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 18 frame_available_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
19 base::WaitableEvent::InitialState::NOT_SIGNALED) {} 19 base::WaitableEvent::InitialState::NOT_SIGNALED),
20
21 gl_matrix_{
22 1, 0, 1, 0, // Default to a sane guess just in case we can't get the
liberato (no reviews please) 2016/10/05 15:35:17 methinks that the 1 in the third column should be
23 0, 1, 0, 0, // matrix on the first call. Will be Y-flipped later.
24 0, 0, 1, 0, //
25 0, 0, 0, 1, // Comment preserves 4x4 formatting.
26 } {}
20 27
21 AVDASharedState::~AVDASharedState() { 28 AVDASharedState::~AVDASharedState() {
22 if (!surface_texture_service_id_) 29 if (!surface_texture_service_id_)
23 return; 30 return;
24 31
25 ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get()); 32 ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get());
26 if (scoped_make_current.Succeeded()) { 33 if (scoped_make_current.Succeeded()) {
27 glDeleteTextures(1, &surface_texture_service_id_); 34 glDeleteTextures(1, &surface_texture_service_id_);
28 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 35 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
29 } 36 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 107
101 void AVDASharedState::RenderCodecBufferToSurfaceTexture( 108 void AVDASharedState::RenderCodecBufferToSurfaceTexture(
102 MediaCodecBridge* codec, 109 MediaCodecBridge* codec,
103 int codec_buffer_index) { 110 int codec_buffer_index) {
104 if (!release_time_.is_null()) 111 if (!release_time_.is_null())
105 WaitForFrameAvailable(); 112 WaitForFrameAvailable();
106 codec->ReleaseOutputBuffer(codec_buffer_index, true); 113 codec->ReleaseOutputBuffer(codec_buffer_index, true);
107 release_time_ = base::TimeTicks::Now(); 114 release_time_ = base::TimeTicks::Now();
108 } 115 }
109 116
117 void AVDASharedState::UpdateTexImage() {
118 surface_texture_->UpdateTexImage();
119 // Helpfully, this is already column major.
120 surface_texture_->GetTransformMatrix(gl_matrix_);
121 }
122
123 void AVDASharedState::GetTransformMatrix(float matrix[16]) const {
124 memcpy(matrix, gl_matrix_, sizeof(gl_matrix_));
125 }
126
110 } // namespace media 127 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/avda_shared_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698