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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SURFACE_TEXTURE_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SURFACE_TEXTURE_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SURFACE_TEXTURE_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SURFACE_TEXTURE_H_ |
7 | 7 |
8 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
9 | 9 |
10 struct ANativeWindow; | 10 struct ANativeWindow; |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 // Implementation of GPU memory buffer based on SurfaceTextures. | 14 // Implementation of GPU memory buffer based on SurfaceTextures. |
15 class GpuMemoryBufferImplSurfaceTexture : public GpuMemoryBufferImpl { | 15 class GpuMemoryBufferImplSurfaceTexture : public GpuMemoryBufferImpl { |
16 public: | 16 public: |
| 17 static void Create(const gfx::Size& size, |
| 18 unsigned internalformat, |
| 19 unsigned usage, |
| 20 int client_id, |
| 21 const CreationCallback& callback); |
| 22 |
| 23 static void AllocateForChildProcess(const gfx::Size& size, |
| 24 unsigned internalformat, |
| 25 unsigned usage, |
| 26 int child_client_id, |
| 27 const AllocationCallback& callback); |
| 28 |
17 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 29 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
18 const gfx::GpuMemoryBufferHandle& handle, | 30 const gfx::GpuMemoryBufferHandle& handle, |
19 const gfx::Size& size, | 31 const gfx::Size& size, |
20 unsigned internalformat, | 32 unsigned internalformat, |
21 const DestructionCallback& callback); | 33 const DestructionCallback& callback); |
22 | 34 |
23 static bool IsFormatSupported(unsigned internalformat); | 35 static bool IsFormatSupported(unsigned internalformat); |
24 static bool IsUsageSupported(unsigned usage); | 36 static bool IsUsageSupported(unsigned usage); |
25 static bool IsConfigurationSupported(unsigned internalformat, unsigned usage); | 37 static bool IsConfigurationSupported(unsigned internalformat, unsigned usage); |
26 static int WindowFormat(unsigned internalformat); | 38 static int WindowFormat(unsigned internalformat); |
27 | 39 |
28 // Overridden from gfx::GpuMemoryBuffer: | 40 // Overridden from gfx::GpuMemoryBuffer: |
29 virtual void* Map() override; | 41 virtual void* Map() override; |
30 virtual void Unmap() override; | 42 virtual void Unmap() override; |
31 virtual gfx::GpuMemoryBufferHandle GetHandle() const override; | 43 virtual gfx::GpuMemoryBufferHandle GetHandle() const override; |
32 virtual uint32 GetStride() const override; | 44 virtual uint32 GetStride() const override; |
33 | 45 |
34 private: | 46 private: |
35 GpuMemoryBufferImplSurfaceTexture( | 47 GpuMemoryBufferImplSurfaceTexture(const gfx::Size& size, |
36 const gfx::Size& size, | 48 unsigned internalformat, |
37 unsigned internalformat, | 49 const DestructionCallback& callback, |
38 const DestructionCallback& callback, | 50 const gfx::GpuMemoryBufferId& id, |
39 const gfx::SurfaceTextureId& surface_texture_id, | 51 ANativeWindow* native_window); |
40 ANativeWindow* native_window); | |
41 virtual ~GpuMemoryBufferImplSurfaceTexture(); | 52 virtual ~GpuMemoryBufferImplSurfaceTexture(); |
42 | 53 |
43 gfx::SurfaceTextureId surface_texture_id_; | 54 gfx::GpuMemoryBufferId id_; |
44 ANativeWindow* native_window_; | 55 ANativeWindow* native_window_; |
45 size_t stride_; | 56 size_t stride_; |
46 | 57 |
47 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplSurfaceTexture); | 58 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplSurfaceTexture); |
48 }; | 59 }; |
49 | 60 |
50 } // namespace content | 61 } // namespace content |
51 | 62 |
52 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SURFACE_TEXTURE_H_ | 63 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SURFACE_TEXTURE_H_ |
OLD | NEW |