| 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_manager.h" | 9 #include "content/common/android/surface_texture_manager.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 DCHECK(!mapped_); | 69 DCHECK(!mapped_); |
| 70 DCHECK(native_window_); | 70 DCHECK(native_window_); |
| 71 ANativeWindow_Buffer buffer; | 71 ANativeWindow_Buffer buffer; |
| 72 int status = ANativeWindow_lock(native_window_, &buffer, NULL); | 72 int status = ANativeWindow_lock(native_window_, &buffer, NULL); |
| 73 if (status) { | 73 if (status) { |
| 74 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; | 74 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; |
| 75 return NULL; | 75 return NULL; |
| 76 } | 76 } |
| 77 | 77 |
| 78 size_t stride_in_bytes = 0; |
| 79 if (!StrideInBytes(buffer.stride, format_, &stride_in_bytes)) |
| 80 return NULL; |
| 81 |
| 78 DCHECK_LE(size_.width(), buffer.stride); | 82 DCHECK_LE(size_.width(), buffer.stride); |
| 79 stride_ = buffer.stride * BytesPerPixel(format_); | 83 stride_ = stride_in_bytes; |
| 80 mapped_ = true; | 84 mapped_ = true; |
| 81 return buffer.bits; | 85 return buffer.bits; |
| 82 } | 86 } |
| 83 | 87 |
| 84 void GpuMemoryBufferImplSurfaceTexture::Unmap() { | 88 void GpuMemoryBufferImplSurfaceTexture::Unmap() { |
| 85 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); | 89 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); |
| 86 | 90 |
| 87 DCHECK(mapped_); | 91 DCHECK(mapped_); |
| 88 ANativeWindow_unlockAndPost(native_window_); | 92 ANativeWindow_unlockAndPost(native_window_); |
| 89 mapped_ = false; | 93 mapped_ = false; |
| 90 } | 94 } |
| 91 | 95 |
| 92 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { | 96 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { |
| 93 return stride_; | 97 return stride_; |
| 94 } | 98 } |
| 95 | 99 |
| 96 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 100 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
| 97 const { | 101 const { |
| 98 gfx::GpuMemoryBufferHandle handle; | 102 gfx::GpuMemoryBufferHandle handle; |
| 99 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 103 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
| 100 handle.id = id_; | 104 handle.id = id_; |
| 101 return handle; | 105 return handle; |
| 102 } | 106 } |
| 103 | 107 |
| 104 } // namespace content | 108 } // namespace content |
| OLD | NEW |