| 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 "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/common/android/surface_texture_lookup.h" | 9 #include "content/common/android/surface_texture_lookup.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool GpuMemoryBufferImplSurfaceTexture::InitializeFromHandle( | 65 bool GpuMemoryBufferImplSurfaceTexture::InitializeFromHandle( |
| 66 gfx::GpuMemoryBufferHandle handle) { | 66 gfx::GpuMemoryBufferHandle handle) { |
| 67 TRACE_EVENT0("gpu", | 67 TRACE_EVENT0("gpu", |
| 68 "GpuMemoryBufferImplSurfaceTexture::InitializeFromHandle"); | 68 "GpuMemoryBufferImplSurfaceTexture::InitializeFromHandle"); |
| 69 | 69 |
| 70 DCHECK(IsFormatSupported(internalformat_)); | 70 DCHECK(IsFormatSupported(internalformat_)); |
| 71 DCHECK(!native_window_); | 71 DCHECK(!native_window_); |
| 72 native_window_ = SurfaceTextureLookup::GetInstance()->AcquireNativeWidget( | 72 native_window_ = SurfaceTextureLookup::GetInstance()->AcquireNativeWidget( |
| 73 handle.surface_texture_id.primary_id, | 73 handle.gpu_memory_id.primary_id, handle.gpu_memory_id.secondary_id); |
| 74 handle.surface_texture_id.secondary_id); | |
| 75 if (!native_window_) | 74 if (!native_window_) |
| 76 return false; | 75 return false; |
| 77 | 76 |
| 78 ANativeWindow_setBuffersGeometry(native_window_, | 77 ANativeWindow_setBuffersGeometry(native_window_, |
| 79 size_.width(), | 78 size_.width(), |
| 80 size_.height(), | 79 size_.height(), |
| 81 WindowFormat(internalformat_)); | 80 WindowFormat(internalformat_)); |
| 82 | 81 |
| 83 surface_texture_id_ = handle.surface_texture_id; | 82 gpu_memory_id_ = handle.gpu_memory_id; |
| 84 return true; | 83 return true; |
| 85 } | 84 } |
| 86 | 85 |
| 87 void* GpuMemoryBufferImplSurfaceTexture::Map() { | 86 void* GpuMemoryBufferImplSurfaceTexture::Map() { |
| 88 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); | 87 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); |
| 89 | 88 |
| 90 DCHECK(!mapped_); | 89 DCHECK(!mapped_); |
| 91 DCHECK(native_window_); | 90 DCHECK(native_window_); |
| 92 ANativeWindow_Buffer buffer; | 91 ANativeWindow_Buffer buffer; |
| 93 int status = ANativeWindow_lock(native_window_, &buffer, NULL); | 92 int status = ANativeWindow_lock(native_window_, &buffer, NULL); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 109 ANativeWindow_unlockAndPost(native_window_); | 108 ANativeWindow_unlockAndPost(native_window_); |
| 110 mapped_ = false; | 109 mapped_ = false; |
| 111 } | 110 } |
| 112 | 111 |
| 113 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { return stride_; } | 112 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { return stride_; } |
| 114 | 113 |
| 115 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 114 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
| 116 const { | 115 const { |
| 117 gfx::GpuMemoryBufferHandle handle; | 116 gfx::GpuMemoryBufferHandle handle; |
| 118 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 117 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
| 119 handle.surface_texture_id = surface_texture_id_; | 118 handle.gpu_memory_id = gpu_memory_id_; |
| 120 return handle; | 119 return handle; |
| 121 } | 120 } |
| 122 | 121 |
| 123 } // namespace content | 122 } // namespace content |
| OLD | NEW |