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/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 "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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 size_t stride_in_bytes = 0; | 83 size_t stride_in_bytes = 0; |
84 if (!StrideInBytes(buffer.stride, format_, &stride_in_bytes)) | 84 if (!StrideInBytes(buffer.stride, format_, &stride_in_bytes)) |
85 return NULL; | 85 return NULL; |
86 | 86 |
87 DCHECK_LE(size_.width(), buffer.stride); | 87 DCHECK_LE(size_.width(), buffer.stride); |
88 stride_ = stride_in_bytes; | 88 stride_ = stride_in_bytes; |
89 mapped_ = true; | 89 mapped_ = true; |
90 return buffer.bits; | 90 return buffer.bits; |
91 } | 91 } |
92 | 92 |
| 93 void* GpuMemoryBufferImplSurfaceTexture::Map(size_t plane_index) { |
| 94 if (plane_index >= num_planes_) |
| 95 return NULL; |
| 96 return Map(); |
| 97 } |
| 98 |
93 void GpuMemoryBufferImplSurfaceTexture::Unmap() { | 99 void GpuMemoryBufferImplSurfaceTexture::Unmap() { |
94 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); | 100 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); |
95 | 101 |
96 DCHECK(mapped_); | 102 DCHECK(mapped_); |
97 ANativeWindow_unlockAndPost(native_window_); | 103 ANativeWindow_unlockAndPost(native_window_); |
98 mapped_ = false; | 104 mapped_ = false; |
99 } | 105 } |
100 | 106 |
101 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { | 107 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { |
102 return stride_; | 108 return stride_; |
103 } | 109 } |
104 | 110 |
| 111 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride(size_t plane_index) const { |
| 112 if (plane_index >= num_planes_) |
| 113 return 0; |
| 114 return GetStride(); |
| 115 } |
| 116 |
105 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 117 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
106 const { | 118 const { |
107 gfx::GpuMemoryBufferHandle handle; | 119 gfx::GpuMemoryBufferHandle handle; |
108 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 120 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
109 handle.id = id_; | 121 handle.id = id_; |
110 return handle; | 122 return handle; |
111 } | 123 } |
112 | 124 |
113 } // namespace content | 125 } // namespace content |
OLD | NEW |