OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gpu_memory_buffer_factory_surface_texture.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" |
6 | 6 |
7 #include "content/common/android/surface_texture_manager.h" | 7 #include "gpu/ipc/common/android/surface_texture_manager.h" |
8 #include "ui/gl/android/surface_texture.h" | 8 #include "ui/gl/android/surface_texture.h" |
9 #include "ui/gl/gl_image_surface_texture.h" | 9 #include "ui/gl/gl_image_surface_texture.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 GpuMemoryBufferFactorySurfaceTexture::GpuMemoryBufferFactorySurfaceTexture() { | 13 GpuMemoryBufferFactorySurfaceTexture::GpuMemoryBufferFactorySurfaceTexture() { |
14 } | 14 } |
15 | 15 |
16 GpuMemoryBufferFactorySurfaceTexture::~GpuMemoryBufferFactorySurfaceTexture() { | 16 GpuMemoryBufferFactorySurfaceTexture::~GpuMemoryBufferFactorySurfaceTexture() { |
17 } | 17 } |
(...skipping 25 matching lines...) Expand all Loading... |
43 // Note: this needs to be 0 as the surface texture implemenation will take | 43 // Note: this needs to be 0 as the surface texture implemenation will take |
44 // ownership of the texture and call glDeleteTextures when the GPU service | 44 // ownership of the texture and call glDeleteTextures when the GPU service |
45 // attaches the surface texture to a real texture id. glDeleteTextures | 45 // attaches the surface texture to a real texture id. glDeleteTextures |
46 // silently ignores 0. | 46 // silently ignores 0. |
47 const int kDummyTextureId = 0; | 47 const int kDummyTextureId = 0; |
48 scoped_refptr<gfx::SurfaceTexture> surface_texture = | 48 scoped_refptr<gfx::SurfaceTexture> surface_texture = |
49 gfx::SurfaceTexture::Create(kDummyTextureId); | 49 gfx::SurfaceTexture::Create(kDummyTextureId); |
50 if (!surface_texture.get()) | 50 if (!surface_texture.get()) |
51 return gfx::GpuMemoryBufferHandle(); | 51 return gfx::GpuMemoryBufferHandle(); |
52 | 52 |
53 SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( | 53 gpu::SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( |
54 id.id, client_id, surface_texture.get()); | 54 id.id, client_id, surface_texture.get()); |
55 | 55 |
56 { | 56 { |
57 base::AutoLock lock(surface_textures_lock_); | 57 base::AutoLock lock(surface_textures_lock_); |
58 | 58 |
59 SurfaceTextureMapKey key(id.id, client_id); | 59 SurfaceTextureMapKey key(id.id, client_id); |
60 DCHECK(surface_textures_.find(key) == surface_textures_.end()); | 60 DCHECK(surface_textures_.find(key) == surface_textures_.end()); |
61 surface_textures_[key] = surface_texture; | 61 surface_textures_[key] = surface_texture; |
62 } | 62 } |
63 | 63 |
(...skipping 18 matching lines...) Expand all Loading... |
82 gfx::GpuMemoryBufferId id, | 82 gfx::GpuMemoryBufferId id, |
83 int client_id) { | 83 int client_id) { |
84 { | 84 { |
85 base::AutoLock lock(surface_textures_lock_); | 85 base::AutoLock lock(surface_textures_lock_); |
86 | 86 |
87 SurfaceTextureMapKey key(id.id, client_id); | 87 SurfaceTextureMapKey key(id.id, client_id); |
88 DCHECK(surface_textures_.find(key) != surface_textures_.end()); | 88 DCHECK(surface_textures_.find(key) != surface_textures_.end()); |
89 surface_textures_.erase(key); | 89 surface_textures_.erase(key); |
90 } | 90 } |
91 | 91 |
92 SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture(id.id, | 92 gpu::SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture( |
93 client_id); | 93 id.id, client_id); |
94 } | 94 } |
95 | 95 |
96 gpu::ImageFactory* GpuMemoryBufferFactorySurfaceTexture::AsImageFactory() { | 96 gpu::ImageFactory* GpuMemoryBufferFactorySurfaceTexture::AsImageFactory() { |
97 return this; | 97 return this; |
98 } | 98 } |
99 | 99 |
100 scoped_refptr<gl::GLImage> | 100 scoped_refptr<gl::GLImage> |
101 GpuMemoryBufferFactorySurfaceTexture::CreateImageForGpuMemoryBuffer( | 101 GpuMemoryBufferFactorySurfaceTexture::CreateImageForGpuMemoryBuffer( |
102 const gfx::GpuMemoryBufferHandle& handle, | 102 const gfx::GpuMemoryBufferHandle& handle, |
103 const gfx::Size& size, | 103 const gfx::Size& size, |
(...skipping 11 matching lines...) Expand all Loading... |
115 | 115 |
116 scoped_refptr<gl::GLImageSurfaceTexture> image( | 116 scoped_refptr<gl::GLImageSurfaceTexture> image( |
117 new gl::GLImageSurfaceTexture(size)); | 117 new gl::GLImageSurfaceTexture(size)); |
118 if (!image->Initialize(it->second.get())) | 118 if (!image->Initialize(it->second.get())) |
119 return scoped_refptr<gl::GLImage>(); | 119 return scoped_refptr<gl::GLImage>(); |
120 | 120 |
121 return image; | 121 return image; |
122 } | 122 } |
123 | 123 |
124 } // namespace content | 124 } // namespace content |
OLD | NEW |