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/client/gpu_memory_buffer_impl_surface_texture.h" | 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_surface_texture.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "gpu/ipc/common/android/surface_texture_manager.h" | 9 #include "gpu/ipc/common/android/surface_texture_manager.h" |
10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
11 #include "ui/gfx/buffer_format_util.h" | 11 #include "ui/gfx/buffer_format_util.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 gpu { |
16 namespace { | 16 namespace { |
17 | 17 |
18 int WindowFormat(gfx::BufferFormat format) { | 18 int WindowFormat(gfx::BufferFormat format) { |
19 switch (format) { | 19 switch (format) { |
20 case gfx::BufferFormat::RGBA_8888: | 20 case gfx::BufferFormat::RGBA_8888: |
21 return WINDOW_FORMAT_RGBA_8888; | 21 return WINDOW_FORMAT_RGBA_8888; |
22 case gfx::BufferFormat::ATC: | 22 case gfx::BufferFormat::ATC: |
23 case gfx::BufferFormat::ATCIA: | 23 case gfx::BufferFormat::ATCIA: |
24 case gfx::BufferFormat::DXT1: | 24 case gfx::BufferFormat::DXT1: |
25 case gfx::BufferFormat::DXT5: | 25 case gfx::BufferFormat::DXT5: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const gfx::Size& size, | 68 const gfx::Size& size, |
69 gfx::BufferFormat format, | 69 gfx::BufferFormat format, |
70 gfx::BufferUsage usage, | 70 gfx::BufferUsage usage, |
71 const DestructionCallback& callback) { | 71 const DestructionCallback& callback) { |
72 ANativeWindow* native_window = | 72 ANativeWindow* native_window = |
73 gpu::SurfaceTextureManager::GetInstance() | 73 gpu::SurfaceTextureManager::GetInstance() |
74 ->AcquireNativeWidgetForSurfaceTexture(handle.id.id); | 74 ->AcquireNativeWidgetForSurfaceTexture(handle.id.id); |
75 if (!native_window) | 75 if (!native_window) |
76 return nullptr; | 76 return nullptr; |
77 | 77 |
78 ANativeWindow_setBuffersGeometry( | 78 ANativeWindow_setBuffersGeometry(native_window, size.width(), size.height(), |
79 native_window, size.width(), size.height(), WindowFormat(format)); | 79 WindowFormat(format)); |
80 | 80 |
81 return make_scoped_ptr(new GpuMemoryBufferImplSurfaceTexture( | 81 return make_scoped_ptr(new GpuMemoryBufferImplSurfaceTexture( |
82 handle.id, size, format, callback, native_window)); | 82 handle.id, size, format, callback, native_window)); |
83 } | 83 } |
84 | 84 |
85 // static | 85 // static |
86 bool GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported( | 86 bool GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported( |
87 gfx::BufferFormat format, | 87 gfx::BufferFormat format, |
88 gfx::BufferUsage usage) { | 88 gfx::BufferUsage usage) { |
89 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); | 89 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ANativeWindow_unlockAndPost(native_window_); | 132 ANativeWindow_unlockAndPost(native_window_); |
133 mapped_ = false; | 133 mapped_ = false; |
134 } | 134 } |
135 | 135 |
136 int GpuMemoryBufferImplSurfaceTexture::stride(size_t plane) const { | 136 int GpuMemoryBufferImplSurfaceTexture::stride(size_t plane) const { |
137 DCHECK(mapped_); | 137 DCHECK(mapped_); |
138 DCHECK_EQ(0u, plane); | 138 DCHECK_EQ(0u, plane); |
139 return gfx::RowSizeForBufferFormat(buffer_.stride, format_, 0); | 139 return gfx::RowSizeForBufferFormat(buffer_.stride, format_, 0); |
140 } | 140 } |
141 | 141 |
142 gfx::GpuMemoryBufferHandle | 142 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
143 GpuMemoryBufferImplSurfaceTexture::GetHandle() const { | 143 const { |
144 gfx::GpuMemoryBufferHandle handle; | 144 gfx::GpuMemoryBufferHandle handle; |
145 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 145 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
146 handle.id = id_; | 146 handle.id = id_; |
147 return handle; | 147 return handle; |
148 } | 148 } |
149 | 149 |
150 } // namespace content | 150 } // namespace gpu |
OLD | NEW |