OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/stream_texture_manager_android.h" | 5 #include "content/common/gpu/stream_texture_manager_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/common/gpu/gpu_channel.h" | 8 #include "content/common/gpu/gpu_channel.h" |
9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
10 #include "gpu/command_buffer/service/stream_texture.h" | 10 #include "gpu/command_buffer/service/stream_texture.h" |
11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
12 #include "ui/gl/android/surface_texture.h" | 12 #include "ui/gl/android/surface_texture.h" |
13 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 StreamTextureManagerAndroid::StreamTextureAndroid::StreamTextureAndroid( | 17 StreamTextureManagerAndroid::StreamTextureAndroid::StreamTextureAndroid( |
18 GpuChannel* channel, int service_id) | 18 GpuChannel* channel, int service_id) |
19 : surface_texture_(new gfx::SurfaceTexture(service_id)), | 19 : surface_texture_(new gfx::SurfaceTexture(service_id)), |
20 size_(0, 0), | 20 size_(0, 0), |
21 has_updated_(false), | 21 has_updated_(false), |
22 channel_(channel) { | 22 channel_(channel) { |
23 memset(current_matrix_, 0, sizeof(current_matrix_)); | 23 memset(current_matrix_, 0, sizeof(current_matrix_)); |
24 } | 24 } |
25 | 25 |
26 StreamTextureManagerAndroid::StreamTextureAndroid::~StreamTextureAndroid() { | 26 StreamTextureManagerAndroid::StreamTextureAndroid::~StreamTextureAndroid() { |
27 } | 27 } |
28 | 28 |
29 void StreamTextureManagerAndroid::StreamTextureAndroid::Update() { | 29 void StreamTextureManagerAndroid::StreamTextureAndroid::Update() { |
30 GLint texture_id = 0; | |
31 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id); | |
32 surface_texture_->UpdateTexImage(); | 30 surface_texture_->UpdateTexImage(); |
33 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id); | |
34 if (matrix_callback_.is_null()) | 31 if (matrix_callback_.is_null()) |
35 return; | 32 return; |
36 | 33 |
37 float mtx[16]; | 34 float mtx[16]; |
38 surface_texture_->GetTransformMatrix(mtx); | 35 surface_texture_->GetTransformMatrix(mtx); |
39 | 36 |
40 // Only query the matrix once we have bound a valid frame. | 37 // Only query the matrix once we have bound a valid frame. |
41 if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) { | 38 if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) { |
42 memcpy(current_matrix_, mtx, sizeof(mtx)); | 39 memcpy(current_matrix_, mtx, sizeof(mtx)); |
43 | 40 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 137 } |
141 | 138 |
142 void StreamTextureManagerAndroid::SetStreamTextureSize( | 139 void StreamTextureManagerAndroid::SetStreamTextureSize( |
143 int32 stream_id, const gfx::Size& size) { | 140 int32 stream_id, const gfx::Size& size) { |
144 StreamTextureAndroid* stream_texture = textures_.Lookup(stream_id); | 141 StreamTextureAndroid* stream_texture = textures_.Lookup(stream_id); |
145 if (stream_texture) | 142 if (stream_texture) |
146 stream_texture->SetSize(size); | 143 stream_texture->SetSize(size); |
147 } | 144 } |
148 | 145 |
149 } // namespace content | 146 } // namespace content |
OLD | NEW |