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_codec_image.h" | 5 #include "content/common/gpu/media/avda_codec_image.h" |
6 | 6 |
7 #include "content/common/gpu/media/avda_shared_state.h" | 7 #include "content/common/gpu/media/avda_shared_state.h" |
8 #include "gpu/command_buffer/service/context_group.h" | |
8 #include "gpu/command_buffer/service/context_state.h" | 9 #include "gpu/command_buffer/service/context_state.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
10 #include "gpu/command_buffer/service/texture_manager.h" | 11 #include "gpu/command_buffer/service/texture_manager.h" |
11 #include "ui/gl/android/surface_texture.h" | 12 #include "ui/gl/android/surface_texture.h" |
12 #include "ui/gl/gl_context.h" | 13 #include "ui/gl/gl_context.h" |
13 #include "ui/gl/scoped_make_current.h" | 14 #include "ui/gl/scoped_make_current.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 AVDACodecImage::AVDACodecImage( | 18 AVDACodecImage::AVDACodecImage( |
(...skipping 25 matching lines...) Expand all Loading... | |
43 | 44 |
44 gfx::Size AVDACodecImage::GetSize() { | 45 gfx::Size AVDACodecImage::GetSize() { |
45 return size_; | 46 return size_; |
46 } | 47 } |
47 | 48 |
48 unsigned AVDACodecImage::GetInternalFormat() { | 49 unsigned AVDACodecImage::GetInternalFormat() { |
49 return GL_RGBA; | 50 return GL_RGBA; |
50 } | 51 } |
51 | 52 |
52 bool AVDACodecImage::BindTexImage(unsigned target) { | 53 bool AVDACodecImage::BindTexImage(unsigned target) { |
53 return true; | 54 return false; |
54 } | 55 } |
55 | 56 |
56 void AVDACodecImage::ReleaseTexImage(unsigned target) {} | 57 void AVDACodecImage::ReleaseTexImage(unsigned target) {} |
57 | 58 |
58 bool AVDACodecImage::CopyTexSubImage(unsigned target, | 59 bool AVDACodecImage::CopyTexImage(unsigned target) { |
59 const gfx::Point& offset, | |
60 const gfx::Rect& rect) { | |
61 return false; | |
62 } | |
63 | |
64 void AVDACodecImage::WillUseTexImage() { | |
65 // Have we bound the SurfaceTexture's texture handle to the active | 60 // Have we bound the SurfaceTexture's texture handle to the active |
66 // texture unit yet? | 61 // texture unit yet? |
67 bool bound_texture = false; | 62 bool bound_texture = false; |
68 | 63 |
69 // Attach the surface texture to our GL context if needed. | 64 // Attach the surface texture to our GL context if needed. |
70 if (!shared_state_->surface_texture_service_id()) { | 65 if (!shared_state_->surface_texture_service_id()) { |
71 AttachSurfaceTextureToContext(); | 66 AttachSurfaceTextureToContext(); |
72 bound_texture = true; | 67 bound_texture = true; |
73 } | 68 } |
74 | 69 |
75 // Make sure that we have the right image in the front buffer. | 70 // Make sure that we have the right image in the front buffer. |
76 bound_texture |= UpdateSurfaceTexture(); | 71 bound_texture |= UpdateSurfaceTexture(); |
77 | 72 |
78 // TODO(liberato): Handle the texture matrix properly. | 73 // TODO(liberato): Handle the texture matrix properly. |
79 // Either we can update the shader with it or we can move all of the logic | 74 // Either we can update the shader with it or we can move all of the logic |
80 // to updateTexImage() to the right place in the cc to send it to the shader. | 75 // to updateTexImage() to the right place in the cc to send it to the shader. |
81 // For now, we just skip it. crbug.com/530681 | 76 // For now, we just skip it. crbug.com/530681 |
82 | 77 |
83 // Sneakily bind the ST texture handle in the real GL context. | 78 gpu::gles2::TextureManager* texture_manager = |
84 // If we called UpdateTexImage() to update the ST front buffer, then we can | 79 decoder_->GetContextGroup()->texture_manager(); |
85 // skip this. Since one draw/frame is the common case, we optimize for it. | 80 gpu::gles2::Texture* texture = |
86 if (!bound_texture) | 81 texture_manager->GetTextureForServiceId( |
87 glBindTexture(GL_TEXTURE_EXTERNAL_OES, | 82 shared_state_->surface_texture_service_id()); |
liberato (no reviews please)
2015/10/19 16:11:41
this still needs to be done, but i don't see it in
reveman
2015/10/19 16:28:17
We get this service id from the glGetIntegerv(GL_T
| |
88 shared_state_->surface_texture_service_id()); | 83 if (texture) { |
84 // By setting image state to UNBOUND instead of COPIED we ensure that | |
85 // CopyTexImage() is called each time the surface texture is used for | |
86 // drawing. | |
87 texture->SetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0, this, | |
88 gpu::gles2::Texture::UNBOUND); | |
89 } | |
90 | |
91 return true; | |
89 } | 92 } |
90 | 93 |
91 void AVDACodecImage::DidUseTexImage() { | 94 bool AVDACodecImage::CopyTexSubImage(unsigned target, |
92 // Unbind the ST's service_id in the real GL context in favor of whatever | 95 const gfx::Point& offset, |
93 // the decoder thinks is bound there. | 96 const gfx::Rect& rect) { |
94 const gpu::gles2::ContextState* state = decoder_->GetContextState(); | 97 return false; |
95 const gpu::gles2::TextureUnit& active_unit = | |
96 state->texture_units[state->active_texture_unit]; | |
97 glBindTexture(GL_TEXTURE_EXTERNAL_OES, | |
liberato (no reviews please)
2015/10/19 16:11:41
i think this still needs to happen as well.
| |
98 active_unit.bound_texture_external_oes.get() | |
99 ? active_unit.bound_texture_external_oes->service_id() | |
100 : 0); | |
101 } | 98 } |
102 | 99 |
103 bool AVDACodecImage::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 100 bool AVDACodecImage::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
104 int z_order, | 101 int z_order, |
105 gfx::OverlayTransform transform, | 102 gfx::OverlayTransform transform, |
106 const gfx::Rect& bounds_rect, | 103 const gfx::Rect& bounds_rect, |
107 const gfx::RectF& crop_rect) { | 104 const gfx::RectF& crop_rect) { |
108 return false; | 105 return false; |
109 } | 106 } |
110 | 107 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 | 166 |
170 // The surface texture is already detached, so just attach it. | 167 // The surface texture is already detached, so just attach it. |
171 surface_texture_->AttachToGLContext(); | 168 surface_texture_->AttachToGLContext(); |
172 shared_state_->set_surface_texture_service_id(surface_texture_service_id); | 169 shared_state_->set_surface_texture_service_id(surface_texture_service_id); |
173 detach_surface_texture_on_destruction_ = true; | 170 detach_surface_texture_on_destruction_ = true; |
174 | 171 |
175 // We do not restore the GL state here. | 172 // We do not restore the GL state here. |
176 } | 173 } |
177 | 174 |
178 } // namespace content | 175 } // namespace content |
OLD | NEW |