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 | |
82 DCHECK_LE(size_.width(), buffer.stride); | 78 DCHECK_LE(size_.width(), buffer.stride); |
83 stride_ = stride_in_bytes; | 79 stride_ = buffer.stride * BytesPerPixel(format_); |
84 mapped_ = true; | 80 mapped_ = true; |
85 return buffer.bits; | 81 return buffer.bits; |
86 } | 82 } |
87 | 83 |
88 void GpuMemoryBufferImplSurfaceTexture::Unmap() { | 84 void GpuMemoryBufferImplSurfaceTexture::Unmap() { |
89 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); | 85 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); |
90 | 86 |
91 DCHECK(mapped_); | 87 DCHECK(mapped_); |
92 ANativeWindow_unlockAndPost(native_window_); | 88 ANativeWindow_unlockAndPost(native_window_); |
93 mapped_ = false; | 89 mapped_ = false; |
94 } | 90 } |
95 | 91 |
96 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { | 92 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { |
97 return stride_; | 93 return stride_; |
98 } | 94 } |
99 | 95 |
100 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 96 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
101 const { | 97 const { |
102 gfx::GpuMemoryBufferHandle handle; | 98 gfx::GpuMemoryBufferHandle handle; |
103 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 99 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
104 handle.id = id_; | 100 handle.id = id_; |
105 return handle; | 101 return handle; |
106 } | 102 } |
107 | 103 |
108 } // namespace content | 104 } // namespace content |
OLD | NEW |