| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/stream_texture_manager_in_process_android.h
" | 5 #include "gpu/command_buffer/service/stream_texture_manager_in_process_android.h
" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "gpu/command_buffer/service/texture_manager.h" | 9 #include "gpu/command_buffer/service/texture_manager.h" |
| 10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/gl/android/surface_texture.h" | 11 #include "ui/gl/android/surface_texture.h" |
| 12 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 13 #include "ui/gl/gl_image.h" | 13 #include "ui/gl/gl_image.h" |
| 14 | 14 |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Simply wraps a SurfaceTexture reference as a GLImage. | 19 // Simply wraps a SurfaceTexture reference as a GLImage. |
| 20 class GLImageImpl : public gfx::GLImage { | 20 class GLImageImpl : public gl::GLImage { |
| 21 public: | 21 public: |
| 22 GLImageImpl(uint32 texture_id, | 22 GLImageImpl(uint32 texture_id, |
| 23 gles2::TextureManager* texture_manager, | 23 gles2::TextureManager* texture_manager, |
| 24 const scoped_refptr<gfx::SurfaceTexture>& surface_texture, | 24 const scoped_refptr<gfx::SurfaceTexture>& surface_texture, |
| 25 const base::Closure& release_callback); | 25 const base::Closure& release_callback); |
| 26 | 26 |
| 27 // implement gfx::GLImage | 27 // implement gl::GLImage |
| 28 void Destroy(bool have_context) override; | 28 void Destroy(bool have_context) override; |
| 29 gfx::Size GetSize() override; | 29 gfx::Size GetSize() override; |
| 30 unsigned GetInternalFormat() override; | 30 unsigned GetInternalFormat() override; |
| 31 bool BindTexImage(unsigned target) override; | 31 bool BindTexImage(unsigned target) override; |
| 32 void ReleaseTexImage(unsigned target) override; | 32 void ReleaseTexImage(unsigned target) override; |
| 33 bool CopyTexImage(unsigned target) override; | 33 bool CopyTexImage(unsigned target) override; |
| 34 bool CopyTexSubImage(unsigned target, | 34 bool CopyTexSubImage(unsigned target, |
| 35 const gfx::Point& offset, | 35 const gfx::Point& offset, |
| 36 const gfx::Rect& rect) override; | 36 const gfx::Rect& rect) override; |
| 37 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 37 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 return 0; | 161 return 0; |
| 162 } | 162 } |
| 163 | 163 |
| 164 scoped_refptr<gfx::SurfaceTexture> surface_texture( | 164 scoped_refptr<gfx::SurfaceTexture> surface_texture( |
| 165 gfx::SurfaceTexture::Create(texture->service_id())); | 165 gfx::SurfaceTexture::Create(texture->service_id())); |
| 166 | 166 |
| 167 uint32 stream_id = next_id_++; | 167 uint32 stream_id = next_id_++; |
| 168 base::Closure release_callback = | 168 base::Closure release_callback = |
| 169 base::Bind(&StreamTextureManagerInProcess::OnReleaseStreamTexture, | 169 base::Bind(&StreamTextureManagerInProcess::OnReleaseStreamTexture, |
| 170 weak_factory_.GetWeakPtr(), stream_id); | 170 weak_factory_.GetWeakPtr(), stream_id); |
| 171 scoped_refptr<gfx::GLImage> gl_image( | 171 scoped_refptr<gl::GLImage> gl_image( |
| 172 new GLImageImpl(texture->service_id(), texture_manager, surface_texture, | 172 new GLImageImpl(texture->service_id(), texture_manager, surface_texture, |
| 173 release_callback)); | 173 release_callback)); |
| 174 | 174 |
| 175 gfx::Size size = gl_image->GetSize(); | 175 gfx::Size size = gl_image->GetSize(); |
| 176 texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES); | 176 texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES); |
| 177 texture_manager->SetLevelInfo(texture, GL_TEXTURE_EXTERNAL_OES, 0, GL_RGBA, | 177 texture_manager->SetLevelInfo(texture, GL_TEXTURE_EXTERNAL_OES, 0, GL_RGBA, |
| 178 size.width(), size.height(), 1, 0, GL_RGBA, | 178 size.width(), size.height(), 1, 0, GL_RGBA, |
| 179 GL_UNSIGNED_BYTE, gfx::Rect(size)); | 179 GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 180 texture_manager->SetLevelImage(texture, GL_TEXTURE_EXTERNAL_OES, 0, | 180 texture_manager->SetLevelImage(texture, GL_TEXTURE_EXTERNAL_OES, 0, |
| 181 gl_image.get(), gles2::Texture::UNBOUND); | 181 gl_image.get(), gles2::Texture::UNBOUND); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 202 StreamTextureManagerInProcess::GetSurfaceTexture(uint32 stream_id) { | 202 StreamTextureManagerInProcess::GetSurfaceTexture(uint32 stream_id) { |
| 203 base::AutoLock lock(map_lock_); | 203 base::AutoLock lock(map_lock_); |
| 204 TextureMap::const_iterator it = textures_.find(stream_id); | 204 TextureMap::const_iterator it = textures_.find(stream_id); |
| 205 if (it != textures_.end()) | 205 if (it != textures_.end()) |
| 206 return it->second; | 206 return it->second; |
| 207 | 207 |
| 208 return NULL; | 208 return NULL; |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace gpu | 211 } // namespace gpu |
| OLD | NEW |