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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 return scoped_ptr<GpuMemoryBufferImpl>(); | 61 return scoped_ptr<GpuMemoryBufferImpl>(); |
62 | 62 |
63 ANativeWindow_setBuffersGeometry( | 63 ANativeWindow_setBuffersGeometry( |
64 native_window, size.width(), size.height(), WindowFormat(format)); | 64 native_window, size.width(), size.height(), WindowFormat(format)); |
65 | 65 |
66 return make_scoped_ptr<GpuMemoryBufferImpl>( | 66 return make_scoped_ptr<GpuMemoryBufferImpl>( |
67 new GpuMemoryBufferImplSurfaceTexture( | 67 new GpuMemoryBufferImplSurfaceTexture( |
68 handle.id, size, format, callback, native_window)); | 68 handle.id, size, format, callback, native_window)); |
69 } | 69 } |
70 | 70 |
71 void* GpuMemoryBufferImplSurfaceTexture::Map() { | 71 bool GpuMemoryBufferImplSurfaceTexture::Map(void** data) { |
72 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); | 72 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); |
73 | 73 |
74 DCHECK(!mapped_); | 74 DCHECK(!mapped_); |
75 DCHECK_EQ(num_planes_, 1u); | |
reveman
2015/03/24 20:13:59
Not needed as it would require us to create a buff
emircan
2015/03/24 21:43:44
Done.
| |
75 DCHECK(native_window_); | 76 DCHECK(native_window_); |
76 ANativeWindow_Buffer buffer; | 77 ANativeWindow_Buffer buffer; |
77 int status = ANativeWindow_lock(native_window_, &buffer, NULL); | 78 int status = ANativeWindow_lock(native_window_, &buffer, NULL); |
78 if (status) { | 79 if (status) { |
79 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; | 80 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; |
80 return NULL; | 81 return NULL; |
81 } | 82 } |
82 | 83 |
83 size_t stride_in_bytes = 0; | 84 size_t stride_in_bytes = 0; |
84 if (!StrideInBytes(buffer.stride, format_, &stride_in_bytes)) | 85 if (!StrideInBytes(buffer.stride, format_, &stride_in_bytes)) |
85 return NULL; | 86 return NULL; |
86 | 87 |
87 DCHECK_LE(size_.width(), buffer.stride); | 88 DCHECK_LE(size_.width(), buffer.stride); |
88 stride_ = stride_in_bytes; | 89 stride_ = stride_in_bytes; |
89 mapped_ = true; | 90 mapped_ = true; |
90 return buffer.bits; | 91 data[0] = buffer.bits; |
92 return true; | |
91 } | 93 } |
92 | 94 |
93 void GpuMemoryBufferImplSurfaceTexture::Unmap() { | 95 void GpuMemoryBufferImplSurfaceTexture::Unmap() { |
94 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); | 96 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); |
95 | 97 |
96 DCHECK(mapped_); | 98 DCHECK(mapped_); |
97 ANativeWindow_unlockAndPost(native_window_); | 99 ANativeWindow_unlockAndPost(native_window_); |
98 mapped_ = false; | 100 mapped_ = false; |
99 } | 101 } |
100 | 102 |
101 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { | 103 bool GpuMemoryBufferImplSurfaceTexture::GetStride(uint32* stride) const { |
102 return stride_; | 104 DCHECK_EQ(num_planes_, 1u); |
reveman
2015/03/24 20:13:59
Not needed as it would require us to create a buff
emircan
2015/03/24 21:43:44
Done.
| |
105 stride[0] = stride_; | |
106 return true; | |
103 } | 107 } |
104 | 108 |
105 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 109 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
106 const { | 110 const { |
107 gfx::GpuMemoryBufferHandle handle; | 111 gfx::GpuMemoryBufferHandle handle; |
108 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 112 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
109 handle.id = id_; | 113 handle.id = id_; |
110 return handle; | 114 return handle; |
111 } | 115 } |
112 | 116 |
113 } // namespace content | 117 } // namespace content |
OLD | NEW |