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/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return 0; | 156 return 0; |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 void* GpuMemoryBufferImplSurfaceTexture::Map() { | 160 void* GpuMemoryBufferImplSurfaceTexture::Map() { |
161 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); | 161 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); |
162 | 162 |
163 DCHECK(!mapped_); | 163 DCHECK(!mapped_); |
164 DCHECK(native_window_); | 164 DCHECK(native_window_); |
165 ANativeWindow_Buffer buffer; | 165 ANativeWindow_Buffer buffer; |
166 int status = ANativeWindow_lock(native_window_, &buffer, NULL); | 166 int status = ANativeWindow_lock(native_window_, &buffer, nullptr); |
167 if (status) { | 167 if (status) { |
168 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; | 168 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; |
169 return NULL; | 169 return nullptr; |
170 } | 170 } |
171 | 171 |
172 DCHECK_LE(size_.width(), buffer.stride); | 172 DCHECK_LE(size_.width(), buffer.stride); |
173 stride_ = buffer.stride * BytesPerPixel(internalformat_); | 173 stride_ = buffer.stride * BytesPerPixel(internalformat_); |
174 mapped_ = true; | 174 mapped_ = true; |
175 return buffer.bits; | 175 return buffer.bits; |
176 } | 176 } |
177 | 177 |
178 void GpuMemoryBufferImplSurfaceTexture::Unmap() { | 178 void GpuMemoryBufferImplSurfaceTexture::Unmap() { |
179 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); | 179 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); |
180 | 180 |
181 DCHECK(mapped_); | 181 DCHECK(mapped_); |
182 ANativeWindow_unlockAndPost(native_window_); | 182 ANativeWindow_unlockAndPost(native_window_); |
183 mapped_ = false; | 183 mapped_ = false; |
184 } | 184 } |
185 | 185 |
186 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { return stride_; } | 186 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { return stride_; } |
187 | 187 |
188 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 188 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
189 const { | 189 const { |
190 gfx::GpuMemoryBufferHandle handle; | 190 gfx::GpuMemoryBufferHandle handle; |
191 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 191 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
192 handle.global_id = id_; | 192 handle.global_id = id_; |
193 return handle; | 193 return handle; |
194 } | 194 } |
195 | 195 |
196 } // namespace content | 196 } // namespace content |
OLD | NEW |